tar.texi 385 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232
  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. * quoting styles::
  153. How to Add Files to Existing Archives: @option{--append}
  154. * appending files:: Appending Files to an Archive
  155. * multiple::
  156. Updating an Archive
  157. * how to update::
  158. Options Used by @option{--create}
  159. * Ignore Failed Read::
  160. Options Used by @option{--extract}
  161. * Reading:: Options to Help Read Archives
  162. * Writing:: Changing How @command{tar} Writes Files
  163. * Scarce:: Coping with Scarce Resources
  164. Options to Help Read Archives
  165. * read full records::
  166. * Ignore Zeros::
  167. Changing How @command{tar} Writes Files
  168. * Dealing with Old Files::
  169. * Overwrite Old Files::
  170. * Keep Old Files::
  171. * Keep Newer Files::
  172. * Unlink First::
  173. * Recursive Unlink::
  174. * Data Modification Times::
  175. * Setting Access Permissions::
  176. * Writing to Standard Output::
  177. * remove files::
  178. Coping with Scarce Resources
  179. * Starting File::
  180. * Same Order::
  181. Performing Backups and Restoring Files
  182. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  183. * Incremental Dumps:: Using @command{tar} to Perform Incremental Dumps
  184. * Backup Levels:: Levels of Backups
  185. * Backup Parameters:: Setting Parameters for Backups and Restoration
  186. * Scripted Backups:: Using the Backup Scripts
  187. * Scripted Restoration:: Using the Restore Script
  188. Setting Parameters for Backups and Restoration
  189. * General-Purpose Variables::
  190. * Magnetic Tape Control::
  191. * User Hooks::
  192. * backup-specs example:: An Example Text of @file{Backup-specs}
  193. Choosing Files and Names for @command{tar}
  194. * file:: Choosing the Archive's Name
  195. * Selecting Archive Members::
  196. * files:: Reading Names from a File
  197. * exclude:: Excluding Some Files
  198. * Wildcards:: Wildcards Patterns and Matching
  199. * after:: Operating Only on New Files
  200. * recurse:: Descending into Directories
  201. * one:: Crossing File System Boundaries
  202. Reading Names from a File
  203. * nul::
  204. Excluding Some Files
  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. You can use @command{tar} archives in many ways. We want to stress a few
  367. of them: storage, backup, and transportation.
  368. @FIXME{the following table entries need a bit of work..}
  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 implementations of @command{tar} may not be so clever;
  980. they will enter an infinite loop when this happens, so you should not
  981. depend on this behavior unless you are certain you are running
  982. @GNUTAR{}. In general, it is wise to always place the archive outside
  983. of the directory being dumped.
  984. @node list
  985. @section How to List Archives
  986. @opindex list
  987. Frequently, you will find yourself wanting to determine exactly what a
  988. particular archive contains. You can use the @option{--list} (@option{-t}) operation
  989. to get the member names as they currently appear in the archive, as well
  990. as various attributes of the files at the time they were archived. For
  991. example, you can examine the archive @file{collection.tar} that you
  992. created in the last section with the command,
  993. @smallexample
  994. $ @kbd{tar --list --file=collection.tar}
  995. @end smallexample
  996. @noindent
  997. The output of @command{tar} would then be:
  998. @smallexample
  999. blues
  1000. folk
  1001. jazz
  1002. @end smallexample
  1003. @noindent
  1004. The archive @file{bfiles.tar} would list as follows:
  1005. @smallexample
  1006. ./birds
  1007. baboon
  1008. ./box
  1009. @end smallexample
  1010. @noindent
  1011. Be sure to use a @option{--file=@var{archive-name}} (@option{-f
  1012. @var{archive-name}}) option just as with @option{--create}
  1013. (@option{-c}) to specify the name of the archive.
  1014. @opindex list, using with @option{--verbose}
  1015. @opindex verbose, using with @option{--list}
  1016. If you use the @option{--verbose} (@option{-v}) option with
  1017. @option{--list}, then @command{tar} will print out a listing
  1018. reminiscent of @w{@samp{ls -l}}, showing owner, file size, and so forth.
  1019. If you had used @option{--verbose} (@option{-v}) mode, the example
  1020. above would look like:
  1021. @smallexample
  1022. $ @kbd{tar --list --verbose --file=collection.tar folk}
  1023. -rw-r--r-- myself user 62 1990-05-23 10:55 folk
  1024. @end smallexample
  1025. @cindex listing member and file names
  1026. @anchor{listing member and file names}
  1027. It is important to notice that the output of @kbd{tar --list
  1028. --verbose} does not necessarily match that produced by @kbd{tar
  1029. --create --verbose} while creating the archive. It is because
  1030. @GNUTAR{}, unless told explicitly not to do so, removes some directory
  1031. prefixes from file names before storing them in the archive
  1032. (@xref{absolute}, for more information). In other
  1033. words, in verbose mode @GNUTAR{} shows @dfn{file names} when creating
  1034. an archive and @dfn{member names} when listing it. Consider this
  1035. example:
  1036. @smallexample
  1037. @group
  1038. $ @kbd{tar cfv archive /etc/mail}
  1039. tar: Removing leading `/' from member names
  1040. /etc/mail/
  1041. /etc/mail/sendmail.cf
  1042. /etc/mail/aliases
  1043. $ @kbd{tar tf archive}
  1044. etc/mail/
  1045. etc/mail/sendmail.cf
  1046. etc/mail/aliases
  1047. @end group
  1048. @end smallexample
  1049. @opindex show-stored-names
  1050. This default behavior can sometimes be inconvenient. You can force
  1051. @GNUTAR{} show member names when creating archive by supplying
  1052. @option{--show-stored-names} option.
  1053. @table @option
  1054. @item --show-stored-names
  1055. Print member (as opposed to @emph{file}) names when creating the archive.
  1056. @end table
  1057. @cindex File name arguments, using @option{--list} with
  1058. @opindex list, using with file name arguments
  1059. You can specify one or more individual member names as arguments when
  1060. using @samp{list}. In this case, @command{tar} will only list the
  1061. names of members you identify. For example, @w{@kbd{tar --list
  1062. --file=afiles.tar apple}} would only print @file{apple}.
  1063. Because @command{tar} preserves paths, file names must be specified as
  1064. they appear in the archive (ie., relative to the directory from which
  1065. the archive was created). Therefore, it is essential when specifying
  1066. member names to @command{tar} that you give the exact member names.
  1067. For example, @w{@kbd{tar --list --file=bfiles.tar birds}} would produce an
  1068. error message something like @samp{tar: birds: Not found in archive},
  1069. because there is no member named @file{birds}, only one named
  1070. @file{./birds}. While the names @file{birds} and @file{./birds} name
  1071. the same file, @emph{member} names by default are compared verbatim.
  1072. However, @w{@kbd{tar --list --file=bfiles.tar baboon}} would respond
  1073. with @file{baboon}, because this exact member name is in the archive file
  1074. @file{bfiles.tar}. If you are not sure of the exact file name,
  1075. use @dfn{globbing patterns}, for example:
  1076. @smallexample
  1077. $ @kbd{tar --list --file=bfiles.tar --wildcards '*b*'}
  1078. @end smallexample
  1079. @noindent
  1080. will list all members whose name contains @samp{b}. @xref{Wildcards},
  1081. for a detailed discussion of globbing patterns and related
  1082. @command{tar} command line options.
  1083. @menu
  1084. * list dir::
  1085. @end menu
  1086. @node list dir
  1087. @unnumberedsubsec Listing the Contents of a Stored Directory
  1088. To get information about the contents of an archived directory,
  1089. use the directory name as a file name argument in conjunction with
  1090. @option{--list} (@option{-t}). To find out file attributes, include the
  1091. @option{--verbose} (@option{-v}) option.
  1092. For example, to find out about files in the directory @file{practice}, in
  1093. the archive file @file{music.tar}, type:
  1094. @smallexample
  1095. $ @kbd{tar --list --verbose --file=music.tar practice}
  1096. @end smallexample
  1097. @command{tar} responds:
  1098. @smallexample
  1099. drwxrwxrwx myself user 0 1990-05-31 21:49 practice/
  1100. -rw-r--r-- myself user 42 1990-05-21 13:29 practice/blues
  1101. -rw-r--r-- myself user 62 1990-05-23 10:55 practice/folk
  1102. -rw-r--r-- myself user 40 1990-05-21 13:30 practice/jazz
  1103. -rw-r--r-- myself user 10240 1990-05-31 21:49 practice/collection.tar
  1104. @end smallexample
  1105. When you use a directory name as a file name argument, @command{tar} acts on
  1106. all the files (including sub-directories) in that directory.
  1107. @node extract
  1108. @section How to Extract Members from an Archive
  1109. @UNREVISED
  1110. @cindex Extraction
  1111. @cindex Retrieving files from an archive
  1112. @cindex Resurrecting files from an archive
  1113. @opindex extract
  1114. Creating an archive is only half the job---there is no point in storing
  1115. files in an archive if you can't retrieve them. The act of retrieving
  1116. members from an archive so they can be used and manipulated as
  1117. unarchived files again is called @dfn{extraction}. To extract files
  1118. from an archive, use the @option{--extract} (@option{--get} or
  1119. @option{-x}) operation. As with @option{--create}, specify the name
  1120. of the archive with @option{--file} (@option{-f}) option. Extracting
  1121. an archive does not modify the archive in any way; you can extract it
  1122. multiple times if you want or need to.
  1123. Using @option{--extract}, you can extract an entire archive, or specific
  1124. files. The files can be directories containing other files, or not. As
  1125. with @option{--create} (@option{-c}) and @option{--list} (@option{-t}), you may use the short or the
  1126. long form of the operation without affecting the performance.
  1127. @menu
  1128. * extracting archives::
  1129. * extracting files::
  1130. * extract dir::
  1131. * extracting untrusted archives::
  1132. * failing commands::
  1133. @end menu
  1134. @node extracting archives
  1135. @subsection Extracting an Entire Archive
  1136. To extract an entire archive, specify the archive file name only, with
  1137. no individual file names as arguments. For example,
  1138. @smallexample
  1139. $ @kbd{tar -xvf collection.tar}
  1140. @end smallexample
  1141. @noindent
  1142. produces this:
  1143. @smallexample
  1144. -rw-r--r-- me user 28 1996-10-18 16:31 jazz
  1145. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  1146. -rw-r--r-- me user 20 1996-09-23 16:44 folk
  1147. @end smallexample
  1148. @node extracting files
  1149. @subsection Extracting Specific Files
  1150. To extract specific archive members, give their exact member names as
  1151. arguments, as printed by @option{--list} (@option{-t}). If you had
  1152. mistakenly deleted one of the files you had placed in the archive
  1153. @file{collection.tar} earlier (say, @file{blues}), you can extract it
  1154. from the archive without changing the archive's structure. Its
  1155. contents will be identical to the original file @file{blues} that you
  1156. 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
  1168. modification times, and owner.@footnote{This is only accidentally
  1169. true, but not in general. Whereas modification times are always
  1170. restored, in most cases, one has to be root for restoring the owner,
  1171. and use a special option for restoring permissions. Here, it just
  1172. happens that the restoring user is also the owner of the archived
  1173. members, and that the current @code{umask} is compatible with original
  1174. permissions.} (These parameters will be identical to those which
  1175. the file had when you originally placed it in the archive; any changes
  1176. you may have made before deleting the file from the file system,
  1177. however, will @emph{not} have been made to the archive member.) The
  1178. archive file, @samp{collection.tar}, is the same as it was before you
  1179. extracted @samp{blues}. You can confirm this by running @command{tar} with
  1180. @option{--list} (@option{-t}).
  1181. Remember that as with other operations, specifying the exact member
  1182. name is important. @w{@kbd{tar --extract --file=bfiles.tar birds}}
  1183. will fail, because there is no member named @file{birds}. To extract
  1184. the member named @file{./birds}, you must specify @w{@kbd{tar
  1185. --extract --file=bfiles.tar ./birds}}. If you don't remember the
  1186. exact member names, use @option{--list} (@option{-t}) option
  1187. (@pxref{list}). You can also extract those members that match a
  1188. specific @dfn{globbing pattern}. For example, to extract from
  1189. @file{bfiles.tar} all files that begin with @samp{b}, no matter their
  1190. directory prefix, you could type:
  1191. @smallexample
  1192. $ @kbd{tar -x -f bfiles.tar --wildcards --no-anchored 'b*'}
  1193. @end smallexample
  1194. @noindent
  1195. Here, @option{--wildcards} instructs @command{tar} to treat
  1196. command line arguments as globbing patterns and @option{--no-anchored}
  1197. informs it that the patterns apply to member names after any @samp{/}
  1198. delimiter. The use of globbing patterns is discussed in detail in
  1199. @xref{Wildcards}.
  1200. You can extract a file to standard output by combining the above options
  1201. with the @option{--to-stdout} (@option{-O}) option (@pxref{Writing to Standard
  1202. Output}).
  1203. If you give the @option{--verbose} option, then @option{--extract}
  1204. will print the names of the archive members as it extracts them.
  1205. @node extract dir
  1206. @subsection Extracting Files that are Directories
  1207. Extracting directories which are members of an archive is similar to
  1208. extracting other files. The main difference to be aware of is that if
  1209. the extracted directory has the same name as any directory already in
  1210. the working directory, then files in the extracted directory will be
  1211. placed into the directory of the same name. Likewise, if there are
  1212. files in the pre-existing directory with the same names as the members
  1213. which you extract, the files from the extracted archive will replace
  1214. the files already in the working directory (and possible
  1215. subdirectories). This will happen regardless of whether or not the
  1216. files in the working directory were more recent than those extracted
  1217. (there exist, however, special options that alter this behavior
  1218. @pxref{Writing}).
  1219. However, if a file was stored with a directory name as part of its file
  1220. name, and that directory does not exist under the working directory when
  1221. the file is extracted, @command{tar} will create the directory.
  1222. We can demonstrate how to use @option{--extract} to extract a directory
  1223. file with an example. Change to the @file{practice} directory if you
  1224. weren't there, and remove the files @file{folk} and @file{jazz}. Then,
  1225. go back to the parent directory and extract the archive
  1226. @file{music.tar}. You may either extract the entire archive, or you may
  1227. extract only the files you just deleted. To extract the entire archive,
  1228. don't give any file names as arguments after the archive name
  1229. @file{music.tar}. To extract only the files you deleted, use the
  1230. following command:
  1231. @smallexample
  1232. $ @kbd{tar -xvf music.tar practice/folk practice/jazz}
  1233. practice/folk
  1234. practice/jazz
  1235. @end smallexample
  1236. @noindent
  1237. If you were to specify two @option{--verbose} (@option{-v}) options, @command{tar}
  1238. would have displayed more detail about the extracted files, as shown
  1239. in the example below:
  1240. @smallexample
  1241. $ @kbd{tar -xvvf music.tar practice/folk practice/jazz}
  1242. -rw-r--r-- me user 28 1996-10-18 16:31 practice/jazz
  1243. -rw-r--r-- me user 20 1996-09-23 16:44 practice/folk
  1244. @end smallexample
  1245. @noindent
  1246. Because you created the directory with @file{practice} as part of the
  1247. file names of each of the files by archiving the @file{practice}
  1248. directory as @file{practice}, you must give @file{practice} as part
  1249. of the file names when you extract those files from the archive.
  1250. @node extracting untrusted archives
  1251. @subsection Extracting Archives from Untrusted Sources
  1252. Extracting files from archives can overwrite files that already exist.
  1253. If you receive an archive from an untrusted source, you should make a
  1254. new directory and extract into that directory, so that you don't have
  1255. to worry about the extraction overwriting one of your existing files.
  1256. For example, if @file{untrusted.tar} came from somewhere else on the
  1257. Internet, and you don't necessarily trust its contents, you can
  1258. extract it as follows:
  1259. @smallexample
  1260. $ @kbd{mkdir newdir}
  1261. $ @kbd{cd newdir}
  1262. $ @kbd{tar -xvf ../untrusted.tar}
  1263. @end smallexample
  1264. It is also a good practice to examine contents of the archive
  1265. before extracting it, using @option{--list} (@option{-t}) option, possibly combined
  1266. with @option{--verbose} (@option{-v}).
  1267. @node failing commands
  1268. @subsection Commands That Will Fail
  1269. Here are some sample commands you might try which will not work, and why
  1270. they won't work.
  1271. If you try to use this command,
  1272. @smallexample
  1273. $ @kbd{tar -xvf music.tar folk jazz}
  1274. @end smallexample
  1275. @noindent
  1276. you will get the following response:
  1277. @smallexample
  1278. tar: folk: Not found in archive
  1279. tar: jazz: Not found in archive
  1280. $
  1281. @end smallexample
  1282. @noindent
  1283. This is because these files were not originally @emph{in} the parent
  1284. directory @file{..}, where the archive is located; they were in the
  1285. @file{practice} directory, and their file names reflect this:
  1286. @smallexample
  1287. $ @kbd{tar -tvf music.tar}
  1288. practice/folk
  1289. practice/jazz
  1290. practice/rock
  1291. @end smallexample
  1292. @FIXME{make sure the above works when going through the examples in
  1293. order...}
  1294. @noindent
  1295. Likewise, if you try to use this command,
  1296. @smallexample
  1297. $ @kbd{tar -tvf music.tar folk jazz}
  1298. @end smallexample
  1299. @noindent
  1300. you would get a similar response. Members with those names are not in the
  1301. archive. You must use the correct member names, or wildcards, in order
  1302. to extract the files from the archive.
  1303. If you have forgotten the correct names of the files in the archive,
  1304. use @w{@kbd{tar --list --verbose}} to list them correctly.
  1305. @FIXME{more examples, here? hag thinks it's a good idea.}
  1306. @node going further
  1307. @section Going Further Ahead in this Manual
  1308. @FIXME{need to write up a node here about the things that are going to
  1309. be in the rest of the manual.}
  1310. @node tar invocation
  1311. @chapter Invoking @GNUTAR{}
  1312. @UNREVISED
  1313. This chapter is about how one invokes the @GNUTAR{}
  1314. command, from the command synopsis (@pxref{Synopsis}). There are
  1315. numerous options, and many styles for writing them. One mandatory
  1316. option specifies the operation @command{tar} should perform
  1317. (@pxref{Operation Summary}), other options are meant to detail how
  1318. this operation should be performed (@pxref{Option Summary}).
  1319. Non-option arguments are not always interpreted the same way,
  1320. depending on what the operation is.
  1321. You will find in this chapter everything about option styles and rules for
  1322. writing them (@pxref{Styles}). On the other hand, operations and options
  1323. are fully described elsewhere, in other chapters. Here, you will find
  1324. only synthetic descriptions for operations and options, together with
  1325. pointers to other parts of the @command{tar} manual.
  1326. Some options are so special they are fully described right in this
  1327. chapter. They have the effect of inhibiting the normal operation of
  1328. @command{tar} or else, they globally alter the amount of feedback the user
  1329. receives about what is going on. These are the @option{--help} and
  1330. @option{--version} (@pxref{help}), @option{--verbose} (@pxref{verbose})
  1331. and @option{--interactive} options (@pxref{interactive}).
  1332. @menu
  1333. * Synopsis::
  1334. * using tar options::
  1335. * Styles::
  1336. * All Options::
  1337. * help::
  1338. * defaults::
  1339. * verbose::
  1340. * interactive::
  1341. @end menu
  1342. @node Synopsis
  1343. @section General Synopsis of @command{tar}
  1344. The @GNUTAR{} program is invoked as either one of:
  1345. @smallexample
  1346. @kbd{tar @var{option}@dots{} [@var{name}]@dots{}}
  1347. @kbd{tar @var{letter}@dots{} [@var{argument}]@dots{} [@var{option}]@dots{} [@var{name}]@dots{}}
  1348. @end smallexample
  1349. The second form is for when old options are being used.
  1350. You can use @command{tar} to store files in an archive, to extract them from
  1351. an archive, and to do other types of archive manipulation. The primary
  1352. argument to @command{tar}, which is called the @dfn{operation}, specifies
  1353. which action to take. The other arguments to @command{tar} are either
  1354. @dfn{options}, which change the way @command{tar} performs an operation,
  1355. or file names or archive members, which specify the files or members
  1356. @command{tar} is to act on.
  1357. You can actually type in arguments in any order, even if in this manual
  1358. the options always precede the other arguments, to make examples easier
  1359. to understand. Further, the option stating the main operation mode
  1360. (the @command{tar} main command) is usually given first.
  1361. Each @var{name} in the synopsis above is interpreted as an archive member
  1362. name when the main command is one of @option{--compare}
  1363. (@option{--diff}, @option{-d}), @option{--delete}, @option{--extract}
  1364. (@option{--get}, @option{-x}), @option{--list} (@option{-t}) or
  1365. @option{--update} (@option{-u}). When naming archive members, you
  1366. must give the exact name of the member in the archive, as it is
  1367. printed by @option{--list}. For @option{--append} (@option{-r}) and
  1368. @option{--create} (@option{-c}), these @var{name} arguments specify
  1369. the names of either files or directory hierarchies to place in the archive.
  1370. These files or hierarchies should already exist in the file system,
  1371. prior to the execution of the @command{tar} command.
  1372. @command{tar} interprets relative file names as being relative to the
  1373. working directory. @command{tar} will make all file names relative
  1374. (by removing leading slashes when archiving or restoring files),
  1375. unless you specify otherwise (using the @option{--absolute-names}
  1376. option). @xref{absolute}, for more information about
  1377. @option{--absolute-names}.
  1378. If you give the name of a directory as either a file name or a member
  1379. name, then @command{tar} acts recursively on all the files and directories
  1380. beneath that directory. For example, the name @file{/} identifies all
  1381. the files in the file system to @command{tar}.
  1382. The distinction between file names and archive member names is especially
  1383. important when shell globbing is used, and sometimes a source of confusion
  1384. for newcomers. @xref{Wildcards}, for more information about globbing.
  1385. The problem is that shells may only glob using existing files in the
  1386. file system. Only @command{tar} itself may glob on archive members, so when
  1387. needed, you must ensure that wildcard characters reach @command{tar} without
  1388. being interpreted by the shell first. Using a backslash before @samp{*}
  1389. or @samp{?}, or putting the whole argument between quotes, is usually
  1390. sufficient for this.
  1391. Even if @var{name}s are often specified on the command line, they
  1392. can also be read from a text file in the file system, using the
  1393. @option{--files-from=@var{file-of-names}} (@option{-T @var{file-of-names}}) option.
  1394. If you don't use any file name arguments, @option{--append} (@option{-r}),
  1395. @option{--delete} and @option{--concatenate} (@option{--catenate},
  1396. @option{-A}) will do nothing, while @option{--create} (@option{-c})
  1397. will usually yield a diagnostic and inhibit @command{tar} execution.
  1398. The other operations of @command{tar} (@option{--list},
  1399. @option{--extract}, @option{--compare}, and @option{--update})
  1400. will act on the entire contents of the archive.
  1401. @cindex exit status
  1402. @cindex return status
  1403. Besides successful exits, @GNUTAR{} may fail for
  1404. many reasons. Some reasons correspond to bad usage, that is, when the
  1405. @command{tar} command is improperly written. Errors may be
  1406. encountered later, while encountering an error processing the archive
  1407. or the files. Some errors are recoverable, in which case the failure
  1408. is delayed until @command{tar} has completed all its work. Some
  1409. errors are such that it would not meaningful, or at least risky, to
  1410. continue processing: @command{tar} then aborts processing immediately.
  1411. All abnormal exits, whether immediate or delayed, should always be
  1412. clearly diagnosed on @code{stderr}, after a line stating the nature of
  1413. the error.
  1414. @GNUTAR{} returns only a few exit statuses. I'm really
  1415. aiming simplicity in that area, for now. If you are not using the
  1416. @option{--compare} @option{--diff}, @option{-d}) option, zero means
  1417. that everything went well, besides maybe innocuous warnings. Nonzero
  1418. means that something went wrong. Right now, as of today, ``nonzero''
  1419. is almost always 2, except for remote operations, where it may be
  1420. 128.
  1421. @node using tar options
  1422. @section Using @command{tar} Options
  1423. @GNUTAR{} has a total of eight operating modes which
  1424. allow you to perform a variety of tasks. You are required to choose
  1425. one operating mode each time you employ the @command{tar} program by
  1426. specifying one, and only one operation as an argument to the
  1427. @command{tar} command (two lists of four operations each may be found
  1428. at @ref{frequent operations} and @ref{Operations}). Depending on
  1429. circumstances, you may also wish to customize how the chosen operating
  1430. mode behaves. For example, you may wish to change the way the output
  1431. looks, or the format of the files that you wish to archive may require
  1432. you to do something special in order to make the archive look right.
  1433. You can customize and control @command{tar}'s performance by running
  1434. @command{tar} with one or more options (such as @option{--verbose}
  1435. (@option{-v}), which we used in the tutorial). As we said in the
  1436. tutorial, @dfn{options} are arguments to @command{tar} which are (as
  1437. their name suggests) optional. Depending on the operating mode, you
  1438. may specify one or more options. Different options will have different
  1439. effects, but in general they all change details of the operation, such
  1440. as archive format, archive name, or level of user interaction. Some
  1441. options make sense with all operating modes, while others are
  1442. meaningful only with particular modes. You will likely use some
  1443. options frequently, while you will only use others infrequently, or
  1444. not at all. (A full list of options is available in @pxref{All Options}.)
  1445. @vrindex TAR_OPTIONS, environment variable
  1446. @anchor{TAR_OPTIONS}
  1447. The @env{TAR_OPTIONS} environment variable specifies default options to
  1448. be placed in front of any explicit options. For example, if
  1449. @code{TAR_OPTIONS} is @samp{-v --unlink-first}, @command{tar} behaves as
  1450. if the two options @option{-v} and @option{--unlink-first} had been
  1451. specified before any explicit options. Option specifications are
  1452. separated by whitespace. A backslash escapes the next character, so it
  1453. can be used to specify an option containing whitespace or a backslash.
  1454. Note that @command{tar} options are case sensitive. For example, the
  1455. options @option{-T} and @option{-t} are different; the first requires an
  1456. argument for stating the name of a file providing a list of @var{name}s,
  1457. while the second does not require an argument and is another way to
  1458. write @option{--list} (@option{-t}).
  1459. In addition to the eight operations, there are many options to
  1460. @command{tar}, and three different styles for writing both: long (mnemonic)
  1461. form, short form, and old style. These styles are discussed below.
  1462. Both the options and the operations can be written in any of these three
  1463. styles.
  1464. @FIXME{menu at end of this node. need to think of an actual outline
  1465. for this chapter; probably do that after stuff from chapter 4 is
  1466. incorporated.}
  1467. @node Styles
  1468. @section The Three Option Styles
  1469. There are three styles for writing operations and options to the command
  1470. line invoking @command{tar}. The different styles were developed at
  1471. different times during the history of @command{tar}. These styles will be
  1472. presented below, from the most recent to the oldest.
  1473. Some options must take an argument. (For example, @option{--file}
  1474. (@option{-f})) takes the name of an archive file as an argument. If
  1475. you do not supply an archive file name, @command{tar} will use a
  1476. default, but this can be confusing; thus, we recommend that you always
  1477. supply a specific archive file name.) Where you @emph{place} the
  1478. arguments generally depends on which style of options you choose. We
  1479. will detail specific information relevant to each option style in the
  1480. sections on the different option styles, below. The differences are
  1481. subtle, yet can often be very important; incorrect option placement
  1482. can cause you to overwrite a number of important files. We urge you
  1483. to note these differences, and only use the option style(s) which
  1484. makes the most sense to you until you feel comfortable with the others.
  1485. Some options @emph{may} take an argument (currently, there are
  1486. two such options: @option{--backup} and @option{--occurrence}). Such
  1487. options may have at most long and short forms, they do not have old style
  1488. equivalent. The rules for specifying an argument for such options
  1489. are stricter than those for specifying mandatory arguments. Please,
  1490. pay special attention to them.
  1491. @menu
  1492. * Mnemonic Options:: Mnemonic Option Style
  1493. * Short Options:: Short Option Style
  1494. * Old Options:: Old Option Style
  1495. * Mixing:: Mixing Option Styles
  1496. @end menu
  1497. @node Mnemonic Options
  1498. @subsection Mnemonic Option Style
  1499. @FIXME{have to decide whether or not to replace other occurrences of
  1500. "mnemonic" with "long", or *ugh* vice versa.}
  1501. Each option has at least one long (or mnemonic) name starting with two
  1502. dashes in a row, e.g., @option{--list}. The long names are more clear than
  1503. their corresponding short or old names. It sometimes happens that a
  1504. single mnemonic option has many different different names which are
  1505. synonymous, such as @option{--compare} and @option{--diff}. In addition,
  1506. long option names can be given unique abbreviations. For example,
  1507. @option{--cre} can be used in place of @option{--create} because there is no
  1508. other mnemonic option which begins with @samp{cre}. (One way to find
  1509. this out is by trying it and seeing what happens; if a particular
  1510. abbreviation could represent more than one option, @command{tar} will tell
  1511. you that that abbreviation is ambiguous and you'll know that that
  1512. abbreviation won't work. You may also choose to run @samp{tar --help}
  1513. to see a list of options. Be aware that if you run @command{tar} with a
  1514. unique abbreviation for the long name of an option you didn't want to
  1515. use, you are stuck; @command{tar} will perform the command as ordered.)
  1516. Mnemonic options are meant to be obvious and easy to remember, and their
  1517. meanings are generally easier to discern than those of their
  1518. corresponding short options (see below). For example:
  1519. @smallexample
  1520. $ @kbd{tar --create --verbose --blocking-factor=20 --file=/dev/rmt0}
  1521. @end smallexample
  1522. @noindent
  1523. gives a fairly good set of hints about what the command does, even
  1524. for those not fully acquainted with @command{tar}.
  1525. Mnemonic options which require arguments take those arguments
  1526. immediately following the option name. There are two ways of
  1527. specifying a mandatory argument. It can be separated from the
  1528. option name either by an equal sign, or by any amount of
  1529. white space characters. For example, the @option{--file} option (which
  1530. tells the name of the @command{tar} archive) is given a file such as
  1531. @file{archive.tar} as argument by using any of the following notations:
  1532. @option{--file=archive.tar} or @option{--file archive.tar}.
  1533. In contrast, optional arguments must always be introduced using
  1534. an equal sign. For example, the @option{--backup} option takes
  1535. an optional argument specifying backup type. It must be used
  1536. as @option{--backup=@var{backup-type}}.
  1537. @node Short Options
  1538. @subsection Short Option Style
  1539. Most options also have a short option name. Short options start with
  1540. a single dash, and are followed by a single character, e.g., @option{-t}
  1541. (which is equivalent to @option{--list}). The forms are absolutely
  1542. identical in function; they are interchangeable.
  1543. The short option names are faster to type than long option names.
  1544. Short options which require arguments take their arguments immediately
  1545. following the option, usually separated by white space. It is also
  1546. possible to stick the argument right after the short option name, using
  1547. no intervening space. For example, you might write @w{@option{-f
  1548. archive.tar}} or @option{-farchive.tar} instead of using
  1549. @option{--file=archive.tar}. Both @option{--file=@var{archive-name}} and
  1550. @w{@option{-f @var{archive-name}}} denote the option which indicates a
  1551. specific archive, here named @file{archive.tar}.
  1552. Short options which take optional arguments take their arguments
  1553. immediately following the option letter, @emph{without any intervening
  1554. white space characters}.
  1555. Short options' letters may be clumped together, but you are not
  1556. required to do this (as compared to old options; see below). When
  1557. short options are clumped as a set, use one (single) dash for them
  1558. all, e.g., @w{@samp{@command{tar} -cvf}}. Only the last option in
  1559. such a set is allowed to have an argument@footnote{Clustering many
  1560. options, the last of which has an argument, is a rather opaque way to
  1561. write options. Some wonder if @acronym{GNU} @code{getopt} should not
  1562. even be made helpful enough for considering such usages as invalid.}.
  1563. When the options are separated, the argument for each option which requires
  1564. an argument directly follows that option, as is usual for Unix programs.
  1565. For example:
  1566. @smallexample
  1567. $ @kbd{tar -c -v -b 20 -f /dev/rmt0}
  1568. @end smallexample
  1569. If you reorder short options' locations, be sure to move any arguments
  1570. that belong to them. If you do not move the arguments properly, you may
  1571. end up overwriting files.
  1572. @node Old Options
  1573. @subsection Old Option Style
  1574. @UNREVISED
  1575. Like short options, old options are single letters. However, old options
  1576. must be written together as a single clumped set, without spaces separating
  1577. them or dashes preceding them@footnote{Beware that if you precede options
  1578. with a dash, you are announcing the short option style instead of the
  1579. old option style; short options are decoded differently.}. This set
  1580. of letters must be the first to appear on the command line, after the
  1581. @command{tar} program name and some white space; old options cannot appear
  1582. anywhere else. The letter of an old option is exactly the same letter as
  1583. the corresponding short option. For example, the old option @samp{t} is
  1584. the same as the short option @option{-t}, and consequently, the same as the
  1585. mnemonic option @option{--list}. So for example, the command @w{@samp{tar
  1586. cv}} specifies the option @option{-v} in addition to the operation @option{-c}.
  1587. When options that need arguments are given together with the command,
  1588. all the associated arguments follow, in the same order as the options.
  1589. Thus, the example given previously could also be written in the old
  1590. style as follows:
  1591. @smallexample
  1592. $ @kbd{tar cvbf 20 /dev/rmt0}
  1593. @end smallexample
  1594. @noindent
  1595. Here, @samp{20} is the argument of @option{-b} and @samp{/dev/rmt0} is
  1596. the argument of @option{-f}.
  1597. On the other hand, this old style syntax makes it difficult to match
  1598. option letters with their corresponding arguments, and is often
  1599. confusing. In the command @w{@samp{tar cvbf 20 /dev/rmt0}}, for example,
  1600. @samp{20} is the argument for @option{-b}, @samp{/dev/rmt0} is the
  1601. argument for @option{-f}, and @option{-v} does not have a corresponding
  1602. argument. Even using short options like in @w{@samp{tar -c -v -b 20 -f
  1603. /dev/rmt0}} is clearer, putting all arguments next to the option they
  1604. pertain to.
  1605. If you want to reorder the letters in the old option argument, be
  1606. sure to reorder any corresponding argument appropriately.
  1607. This old way of writing @command{tar} options can surprise even experienced
  1608. users. For example, the two commands:
  1609. @smallexample
  1610. @kbd{tar cfz archive.tar.gz file}
  1611. @kbd{tar -cfz archive.tar.gz file}
  1612. @end smallexample
  1613. @noindent
  1614. are quite different. The first example uses @file{archive.tar.gz} as
  1615. the value for option @samp{f} and recognizes the option @samp{z}. The
  1616. second example, however, uses @file{z} as the value for option
  1617. @samp{f} --- probably not what was intended.
  1618. Old options are kept for compatibility with old versions of @command{tar}.
  1619. This second example could be corrected in many ways, among which the
  1620. following are equivalent:
  1621. @smallexample
  1622. @kbd{tar -czf archive.tar.gz file}
  1623. @kbd{tar -cf archive.tar.gz -z file}
  1624. @kbd{tar cf archive.tar.gz -z file}
  1625. @end smallexample
  1626. @cindex option syntax, traditional
  1627. As far as we know, all @command{tar} programs, @acronym{GNU} and
  1628. non-@acronym{GNU}, support old options. @GNUTAR{}
  1629. supports them not only for historical reasons, but also because many
  1630. people are used to them. For compatibility with Unix @command{tar},
  1631. the first argument is always treated as containing command and option
  1632. letters even if it doesn't start with @samp{-}. Thus, @samp{tar c} is
  1633. equivalent to @w{@samp{tar -c}:} both of them specify the
  1634. @option{--create} (@option{-c}) command to create an archive.
  1635. @node Mixing
  1636. @subsection Mixing Option Styles
  1637. All three styles may be intermixed in a single @command{tar} command,
  1638. so long as the rules for each style are fully
  1639. respected@footnote{Before @GNUTAR{} version 1.11.6,
  1640. a bug prevented intermixing old style options with mnemonic options in
  1641. some cases.}. Old style options and either of the modern styles of
  1642. options may be mixed within a single @command{tar} command. However,
  1643. old style options must be introduced as the first arguments only,
  1644. following the rule for old options (old options must appear directly
  1645. after the @command{tar} command and some white space). Modern options
  1646. may be given only after all arguments to the old options have been
  1647. collected. If this rule is not respected, a modern option might be
  1648. falsely interpreted as the value of the argument to one of the old
  1649. style options.
  1650. For example, all the following commands are wholly equivalent, and
  1651. illustrate the many combinations and orderings of option styles.
  1652. @smallexample
  1653. @kbd{tar --create --file=archive.tar}
  1654. @kbd{tar --create -f archive.tar}
  1655. @kbd{tar --create -farchive.tar}
  1656. @kbd{tar --file=archive.tar --create}
  1657. @kbd{tar --file=archive.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 -cfarchive.tar}
  1663. @kbd{tar -f archive.tar --create}
  1664. @kbd{tar -f archive.tar -c}
  1665. @kbd{tar -farchive.tar --create}
  1666. @kbd{tar -farchive.tar -c}
  1667. @kbd{tar c --file=archive.tar}
  1668. @kbd{tar c -f archive.tar}
  1669. @kbd{tar c -farchive.tar}
  1670. @kbd{tar cf archive.tar}
  1671. @kbd{tar f archive.tar --create}
  1672. @kbd{tar f archive.tar -c}
  1673. @kbd{tar fc archive.tar}
  1674. @end smallexample
  1675. On the other hand, the following commands are @emph{not} equivalent to
  1676. the previous set:
  1677. @smallexample
  1678. @kbd{tar -f -c archive.tar}
  1679. @kbd{tar -fc archive.tar}
  1680. @kbd{tar -fcarchive.tar}
  1681. @kbd{tar -farchive.tarc}
  1682. @kbd{tar cfarchive.tar}
  1683. @end smallexample
  1684. @noindent
  1685. These last examples mean something completely different from what the
  1686. user intended (judging based on the example in the previous set which
  1687. uses long options, whose intent is therefore very clear). The first
  1688. four specify that the @command{tar} archive would be a file named
  1689. @option{-c}, @samp{c}, @samp{carchive.tar} or @samp{archive.tarc},
  1690. respectively. The first two examples also specify a single non-option,
  1691. @var{name} argument having the value @samp{archive.tar}. The last
  1692. example contains only old style option letters (repeating option
  1693. @samp{c} twice), not all of which are meaningful (eg., @samp{.},
  1694. @samp{h}, or @samp{i}), with no argument value. @FIXME{not sure i liked
  1695. the first sentence of this paragraph..}
  1696. @node All Options
  1697. @section All @command{tar} Options
  1698. The coming manual sections contain an alphabetical listing of all
  1699. @command{tar} operations and options, with brief descriptions and cross
  1700. references to more in-depth explanations in the body of the manual.
  1701. They also contain an alphabetically arranged table of the short option
  1702. forms with their corresponding long option. You can use this table as
  1703. a reference for deciphering @command{tar} commands in scripts.
  1704. @menu
  1705. * Operation Summary::
  1706. * Option Summary::
  1707. * Short Option Summary::
  1708. @end menu
  1709. @node Operation Summary
  1710. @subsection Operations
  1711. @table @option
  1712. @opindex append, summary
  1713. @item --append
  1714. @itemx -r
  1715. Appends files to the end of the archive. @xref{append}.
  1716. @opindex catenate, summary
  1717. @item --catenate
  1718. @itemx -A
  1719. Same as @option{--concatenate}. @xref{concatenate}.
  1720. @opindex compare, summary
  1721. @item --compare
  1722. @itemx -d
  1723. Compares archive members with their counterparts in the file
  1724. system, and reports differences in file size, mode, owner,
  1725. modification date and contents. @xref{compare}.
  1726. @opindex concatenate, summary
  1727. @item --concatenate
  1728. @itemx -A
  1729. Appends other @command{tar} archives to the end of the archive.
  1730. @xref{concatenate}.
  1731. @opindex create, summary
  1732. @item --create
  1733. @itemx -c
  1734. Creates a new @command{tar} archive. @xref{create}.
  1735. @opindex delete, summary
  1736. @item --delete
  1737. Deletes members from the archive. Don't try this on a archive on a
  1738. tape! @xref{delete}.
  1739. @opindex diff, summary
  1740. @item --diff
  1741. @itemx -d
  1742. Same @option{--compare}. @xref{compare}.
  1743. @opindex extract, summary
  1744. @item --extract
  1745. @itemx -x
  1746. Extracts members from the archive into the file system. @xref{extract}.
  1747. @opindex get, summary
  1748. @item --get
  1749. @itemx -x
  1750. Same as @option{--extract}. @xref{extract}.
  1751. @opindex list, summary
  1752. @item --list
  1753. @itemx -t
  1754. Lists the members in an archive. @xref{list}.
  1755. @opindex update, summary
  1756. @item --update
  1757. @itemx -u
  1758. Adds files to the end of the archive, but only if they are newer than
  1759. their counterparts already in the archive, or if they do not already
  1760. exist in the archive. @xref{update}.
  1761. @end table
  1762. @node Option Summary
  1763. @subsection @command{tar} Options
  1764. @table @option
  1765. @opindex absolute-names, summary
  1766. @item --absolute-names
  1767. @itemx -P
  1768. Normally when creating an archive, @command{tar} strips an initial
  1769. @samp{/} from member names. This option disables that behavior.
  1770. @xref{absolute}.
  1771. @opindex after-date, summary
  1772. @item --after-date
  1773. (See @option{--newer}, @pxref{after})
  1774. @opindex anchored, summary
  1775. @item --anchored
  1776. A pattern must match an initial subsequence of the name's components.
  1777. @xref{controlling pattern-matching}.
  1778. @opindex atime-preserve, summary
  1779. @item --atime-preserve
  1780. @itemx --atime-preserve=replace
  1781. @itemx --atime-preserve=system
  1782. Attempt to preserve the access time of files when reading them. This
  1783. option currently is effective only on files that you own, unless you
  1784. have superuser privileges.
  1785. @option{--atime-preserve=replace} remembers the access time of a file
  1786. before reading it, and then restores the access time afterwards. This
  1787. may cause problems if other programs are reading the file at the same
  1788. time, as the times of their accesses will be lost. On most platforms
  1789. restoring the access time also requires @command{tar} to restore the
  1790. data modification time too, so this option may also cause problems if
  1791. other programs are writing the file at the same time. (Tar attempts
  1792. to detect this situation, but cannot do so reliably due to race
  1793. conditions.) Worse, on most platforms restoring the access time also
  1794. updates the status change time, which means that this option is
  1795. incompatible with incremental backups.
  1796. @option{--atime-preserve=system} avoids changing time stamps on files,
  1797. without interfering with time stamp updates
  1798. caused by other programs, so it works better with incremental backups.
  1799. However, it requires a special @code{O_NOATIME} option from the
  1800. underlying operating and file system implementation, and it also requires
  1801. that searching directories does not update their access times. As of
  1802. this writing (November 2005) this works only with Linux, and only with
  1803. Linux kernels 2.6.8 and later. Worse, there is currently no reliable
  1804. way to know whether this feature actually works. Sometimes
  1805. @command{tar} knows that it does not work, and if you use
  1806. @option{--atime-preserve=system} then @command{tar} complains and
  1807. exits right away. But other times @command{tar} might think that the
  1808. option works when it actually does not.
  1809. Currently @option{--atime-preserve} with no operand defaults to
  1810. @option{--atime-preserve=replace}, but this may change in the future
  1811. as support for @option{--atime-preserve=system} improves.
  1812. If your operating system does not support
  1813. @option{--atime-preserve=system}, you might be able to preserve access
  1814. times reliably by by using the @command{mount} command. For example,
  1815. you can mount the file system read-only, or access the file system via
  1816. a read-only loopback mount, or use the @samp{noatime} mount option
  1817. available on some systems. However, mounting typically requires
  1818. superuser privileges and can be a pain to manage.
  1819. @opindex backup, summary
  1820. @item --backup=@var{backup-type}
  1821. Rather than deleting files from the file system, @command{tar} will
  1822. back them up using simple or numbered backups, depending upon
  1823. @var{backup-type}. @xref{backup}.
  1824. @opindex block-number, summary
  1825. @item --block-number
  1826. @itemx -R
  1827. With this option present, @command{tar} prints error messages for read errors
  1828. with the block number in the archive file. @xref{block-number}.
  1829. @opindex blocking-factor, summary
  1830. @item --blocking-factor=@var{blocking}
  1831. @itemx -b @var{blocking}
  1832. Sets the blocking factor @command{tar} uses to @var{blocking} x 512 bytes per
  1833. record. @xref{Blocking Factor}.
  1834. @opindex bzip2, summary
  1835. @item --bzip2
  1836. @itemx -j
  1837. This option tells @command{tar} to read or write archives through
  1838. @code{bzip2}. @xref{gzip}.
  1839. @opindex checkpoint, summary
  1840. @item --checkpoint
  1841. This option directs @command{tar} to print periodic checkpoint messages as it
  1842. reads through the archive. It is intended for when you want a visual
  1843. indication that @command{tar} is still running, but don't want to see
  1844. @option{--verbose} output. @FIXME-xref{}
  1845. @opindex check-links, summary
  1846. @item --check-links
  1847. @itemx -l
  1848. If this option was given, @command{tar} will check the number of links
  1849. dumped for each processed file. If this number does not match the
  1850. total number of hard links for the file, a warning message will be
  1851. output @footnote{Earlier versions of @GNUTAR{} understood @option{-l} as a
  1852. synonym for @option{--one-file-system}. The current semantics, wich
  1853. complies to UNIX98, was introduced with version
  1854. 1.15.91. @xref{Changes}, for more information.}.
  1855. @opindex compress, summary
  1856. @opindex uncompress, summary
  1857. @item --compress
  1858. @itemx --uncompress
  1859. @itemx -Z
  1860. @command{tar} will use the @command{compress} program when reading or
  1861. writing the archive. This allows you to directly act on archives
  1862. while saving space. @xref{gzip}.
  1863. @opindex confirmation, summary
  1864. @item --confirmation
  1865. (See @option{--interactive}.) @xref{interactive}.
  1866. @opindex delay-directory-restore, summary
  1867. @item --delay-directory-restore
  1868. Delay setting modification times and permissions of extracted
  1869. directories until the end of extraction. @xref{Directory Modification Times and Permissions}.
  1870. @opindex dereference, summary
  1871. @item --dereference
  1872. @itemx -h
  1873. When creating a @command{tar} archive, @command{tar} will archive the
  1874. file that a symbolic link points to, rather than archiving the
  1875. symlink. @xref{dereference}.
  1876. @opindex directory, summary
  1877. @item --directory=@var{dir}
  1878. @itemx -C @var{dir}
  1879. When this option is specified, @command{tar} will change its current directory
  1880. to @var{dir} before performing any operations. When this option is used
  1881. during archive creation, it is order sensitive. @xref{directory}.
  1882. @opindex exclude, summary
  1883. @item --exclude=@var{pattern}
  1884. When performing operations, @command{tar} will skip files that match
  1885. @var{pattern}. @xref{exclude}.
  1886. @opindex exclude-from, summary
  1887. @item --exclude-from=@var{file}
  1888. @itemx -X @var{file}
  1889. Similar to @option{--exclude}, except @command{tar} will use the list of
  1890. patterns in the file @var{file}. @xref{exclude}.
  1891. @opindex exclude-caches, summary
  1892. @item --exclude-caches
  1893. Automatically excludes all directories
  1894. containing a cache directory tag. @xref{exclude}.
  1895. @opindex file, summary
  1896. @item --file=@var{archive}
  1897. @itemx -f @var{archive}
  1898. @command{tar} will use the file @var{archive} as the @command{tar} archive it
  1899. performs operations on, rather than @command{tar}'s compilation dependent
  1900. default. @xref{file tutorial}.
  1901. @opindex files-from, summary
  1902. @item --files-from=@var{file}
  1903. @itemx -T @var{file}
  1904. @command{tar} will use the contents of @var{file} as a list of archive members
  1905. or files to operate on, in addition to those specified on the
  1906. command-line. @xref{files}.
  1907. @opindex force-local, summary
  1908. @item --force-local
  1909. Forces @command{tar} to interpret the filename given to @option{--file}
  1910. as a local file, even if it looks like a remote tape drive name.
  1911. @xref{local and remote archives}.
  1912. @opindex format, summary
  1913. @item --format=@var{format}
  1914. Selects output archive format. @var{Format} may be one of the
  1915. following:
  1916. @table @samp
  1917. @item v7
  1918. Creates an archive that is compatible with Unix V7 @command{tar}.
  1919. @item oldgnu
  1920. Creates an archive that is compatible with GNU @command{tar} version
  1921. 1.12 or earlier.
  1922. @item gnu
  1923. Creates archive in GNU tar 1.13 format. Basically it is the same as
  1924. @samp{oldgnu} with the only difference in the way it handles long
  1925. numeric fields.
  1926. @item ustar
  1927. Creates a @acronym{POSIX.1-1988} compatible archive.
  1928. @item posix
  1929. Creates a @acronym{POSIX.1-2001 archive}.
  1930. @end table
  1931. @xref{Formats}, for a detailed discussion of these formats.
  1932. @opindex group, summary
  1933. @item --group=@var{group}
  1934. Files added to the @command{tar} archive will have a group id of @var{group},
  1935. rather than the group from the source file. @var{group} is first decoded
  1936. as a group symbolic name, but if this interpretation fails, it has to be
  1937. a decimal numeric group ID. @FIXME-xref{}
  1938. Also see the comments for the @option{--owner=@var{user}} option.
  1939. @opindex gzip, summary
  1940. @opindex gunzip, summary
  1941. @opindex ungzip, summary
  1942. @item --gzip
  1943. @itemx --gunzip
  1944. @itemx --ungzip
  1945. @itemx -z
  1946. This option tells @command{tar} to read or write archives through
  1947. @command{gzip}, allowing @command{tar} to directly operate on several
  1948. kinds of compressed archives transparently. @xref{gzip}.
  1949. @opindex help, summary
  1950. @item --help
  1951. @command{tar} will print out a short message summarizing the operations and
  1952. options to @command{tar} and exit. @xref{help}.
  1953. @opindex ignore-case, summary
  1954. @item --ignore-case
  1955. Ignore case when matching member or file names with
  1956. patterns. @xref{controlling pattern-matching}.
  1957. @opindex ignore-command-error, summary
  1958. @item --ignore-command-error
  1959. Ignore exit codes of subprocesses. @xref{Writing to an External Program}.
  1960. @opindex ignore-failed-read, summary
  1961. @item --ignore-failed-read
  1962. Do not exit unsuccessfully merely because an unreadable file was encountered.
  1963. @xref{Reading}.
  1964. @opindex ignore-zeros, summary
  1965. @item --ignore-zeros
  1966. @itemx -i
  1967. With this option, @command{tar} will ignore zeroed blocks in the
  1968. archive, which normally signals EOF. @xref{Reading}.
  1969. @opindex incremental, summary
  1970. @item --incremental
  1971. @itemx -G
  1972. Used to inform @command{tar} that it is working with an old
  1973. @acronym{GNU}-format incremental backup archive. It is intended
  1974. primarily for backwards compatibility only. @xref{Incremental Dumps},
  1975. for a detailed discussion of incremental archives.
  1976. @opindex index-file, summary
  1977. @item --index-file=@var{file}
  1978. Send verbose output to @var{file} instead of to standard output.
  1979. @opindex info-script, summary
  1980. @opindex new-volume-script, summary
  1981. @item --info-script=@var{script-file}
  1982. @itemx --new-volume-script=@var{script-file}
  1983. @itemx -F @var{script-file}
  1984. When @command{tar} is performing multi-tape backups, @var{script-file} is run
  1985. at the end of each tape. If @var{script-file} exits with nonzero status,
  1986. @command{tar} fails immediately. @xref{info-script}, for a detailed
  1987. discussion of @var{script-file}.
  1988. @opindex interactive, summary
  1989. @item --interactive
  1990. @itemx --confirmation
  1991. @itemx -w
  1992. Specifies that @command{tar} should ask the user for confirmation before
  1993. performing potentially destructive options, such as overwriting files.
  1994. @xref{interactive}.
  1995. @opindex keep-newer-files, summary
  1996. @item --keep-newer-files
  1997. Do not replace existing files that are newer than their archive copies
  1998. when extracting files from an archive.
  1999. @opindex keep-old-files, summary
  2000. @item --keep-old-files
  2001. @itemx -k
  2002. Do not overwrite existing files when extracting files from an archive.
  2003. @xref{Keep Old Files}.
  2004. @opindex label, summary
  2005. @item --label=@var{name}
  2006. @itemx -V @var{name}
  2007. When creating an archive, instructs @command{tar} to write @var{name}
  2008. as a name record in the archive. When extracting or listing archives,
  2009. @command{tar} will only operate on archives that have a label matching
  2010. the pattern specified in @var{name}. @xref{Tape Files}.
  2011. @opindex listed-incremental, summary
  2012. @item --listed-incremental=@var{snapshot-file}
  2013. @itemx -g @var{snapshot-file}
  2014. During a @option{--create} operation, specifies that the archive that
  2015. @command{tar} creates is a new @acronym{GNU}-format incremental
  2016. backup, using @var{snapshot-file} to determine which files to backup.
  2017. With other operations, informs @command{tar} that the archive is in
  2018. incremental format. @xref{Incremental Dumps}.
  2019. @opindex mode, summary
  2020. @item --mode=@var{permissions}
  2021. When adding files to an archive, @command{tar} will use
  2022. @var{permissions} for the archive members, rather than the permissions
  2023. from the files. The program @command{chmod} and this @command{tar}
  2024. option share the same syntax for what @var{permissions} might be.
  2025. @xref{File permissions, Permissions, File permissions, fileutils,
  2026. @acronym{GNU} file utilities}. This reference also has useful
  2027. information for those not being overly familiar with the Unix
  2028. permission system.
  2029. Of course, @var{permissions} might be plainly specified as an octal number.
  2030. However, by using generic symbolic modifications to mode bits, this allows
  2031. more flexibility. For example, the value @samp{a+rw} adds read and write
  2032. permissions for everybody, while retaining executable bits on directories
  2033. or on any other file already marked as executable.
  2034. @opindex multi-volume, summary
  2035. @item --multi-volume
  2036. @itemx -M
  2037. Informs @command{tar} that it should create or otherwise operate on a
  2038. multi-volume @command{tar} archive. @xref{Using Multiple Tapes}.
  2039. @opindex new-volume-script, summary
  2040. @item --new-volume-script
  2041. (see --info-script)
  2042. @opindex seek, summary
  2043. @item --seek
  2044. @itemx -n
  2045. Assume that the archive media supports seeks to arbitrary
  2046. locations. Usually @command{tar} determines automatically whether
  2047. the archive can be seeked or not. This option is intended for use
  2048. in cases when such recognition fails.
  2049. @opindex newer, summary
  2050. @item --newer=@var{date}
  2051. @itemx --after-date=@var{date}
  2052. @itemx -N
  2053. When creating an archive, @command{tar} will only add files that have changed
  2054. since @var{date}. If @var{date} begins with @samp{/} or @samp{.}, it
  2055. is taken to be the name of a file whose data modification time specifies
  2056. the date. @xref{after}.
  2057. @opindex newer-mtime, summary
  2058. @item --newer-mtime=@var{date}
  2059. Like @option{--newer}, but add only files whose
  2060. contents have changed (as opposed to just @option{--newer}, which will
  2061. also back up files for which any status information has changed).
  2062. @opindex no-anchored, summary
  2063. @item --no-anchored
  2064. An exclude pattern can match any subsequence of the name's components.
  2065. @xref{controlling pattern-matching}.
  2066. @opindex no-delay-directory-restore, summary
  2067. @item --no-delay-directory-restore
  2068. Setting modification times and permissions of extracted
  2069. directories when all files from this directory has been
  2070. extracted. This is the default. @xref{Directory Modification Times and Permissions}.
  2071. @opindex no-ignore-case, summary
  2072. @item --no-ignore-case
  2073. Use case-sensitive matching.
  2074. @xref{controlling pattern-matching}.
  2075. @opindex no-ignore-command-error, summary
  2076. @item --no-ignore-command-error
  2077. Print warnings about subprocesses terminated with a non-zero exit
  2078. code. @xref{Writing to an External Program}.
  2079. @opindex no-quote-chars, summary
  2080. @item --no-quote-chars=@var{string}
  2081. Remove characters listed in @var{string} from the list of quoted
  2082. characters set by the previous @option{--quote-chars} option
  2083. (@pxref{quoting styles}).
  2084. @opindex no-recursion, summary
  2085. @item --no-recursion
  2086. With this option, @command{tar} will not recurse into directories.
  2087. @xref{recurse}.
  2088. @opindex no-same-owner, summary
  2089. @item --no-same-owner
  2090. @itemx -o
  2091. When extracting an archive, do not attempt to preserve the owner
  2092. specified in the @command{tar} archive. This the default behavior
  2093. for ordinary users.
  2094. @opindex no-same-permissions, summary
  2095. @item --no-same-permissions
  2096. When extracting an archive, subtract the user's umask from files from
  2097. the permissions specified in the archive. This is the default behavior
  2098. for ordinary users.
  2099. @opindex no-wildcards, summary
  2100. @item --no-wildcards
  2101. Do not use wildcards.
  2102. @xref{controlling pattern-matching}.
  2103. @opindex no-wildcards-match-slash, summary
  2104. @item --no-wildcards-match-slash
  2105. Wildcards do not match @samp{/}.
  2106. @xref{controlling pattern-matching}.
  2107. @opindex null, summary
  2108. @item --null
  2109. When @command{tar} is using the @option{--files-from} option, this option
  2110. instructs @command{tar} to expect filenames terminated with @option{NUL}, so
  2111. @command{tar} can correctly work with file names that contain newlines.
  2112. @xref{nul}.
  2113. @opindex numeric-owner, summary
  2114. @item --numeric-owner
  2115. This option will notify @command{tar} that it should use numeric user
  2116. and group IDs when creating a @command{tar} file, rather than names.
  2117. @xref{Attributes}.
  2118. @item -o
  2119. When extracting files, this option is a synonym for
  2120. @option{--no-same-owner}, i.e. it prevents @command{tar} from
  2121. restoring ownership of files being extracted.
  2122. When creating an archive, @option{-o} is a synonym for
  2123. @option{--old-archive}. This behavior is for compatibility
  2124. with previous versions of @GNUTAR{}, and will be
  2125. removed in the future releases.
  2126. @xref{Changes}, for more information.
  2127. @opindex occurrence, summary
  2128. @item --occurrence[=@var{number}]
  2129. This option can be used in conjunction with one of the subcommands
  2130. @option{--delete}, @option{--diff}, @option{--extract} or
  2131. @option{--list} when a list of files is given either on the command
  2132. line or via @option{-T} option.
  2133. This option instructs @command{tar} to process only the @var{number}th
  2134. occurrence of each named file. @var{Number} defaults to 1, so
  2135. @smallexample
  2136. tar -x -f archive.tar --occurrence filename
  2137. @end smallexample
  2138. @noindent
  2139. will extract the first occurrence of @file{filename} from @file{archive.tar}
  2140. and will terminate without scanning to the end of the archive.
  2141. @opindex old-archive, summary
  2142. @item --old-archive
  2143. Synonym for @option{--format=v7}.
  2144. @opindex one-file-system, summary
  2145. @item --one-file-system
  2146. Used when creating an archive. Prevents @command{tar} from recursing into
  2147. directories that are on different file systems from the current
  2148. directory @footnote{Earlier versions of @GNUTAR{} understood @option{-l} as a
  2149. synonym for @option{--one-file-system}. This has changed in version
  2150. 1.15.91. @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 transform, summary
  2172. @item --transform=@var{sed-expr}
  2173. Transform file or member names using @command{sed} replacement expression
  2174. @var{sed-expr}. For example,
  2175. @smallexample
  2176. $ @kbd{tar cf archive.tar --transform 's,^\./,usr/,' .}
  2177. @end smallexample
  2178. @noindent
  2179. will add to @file{archive} files from the current working directory,
  2180. replacing initial @samp{./} prefix with @samp{usr/}. For the detailed
  2181. discussion, see @FIXME-xref{transform}
  2182. To see transformed member names in verbose listings, use
  2183. @option{--show-transformed-names} option
  2184. (@FIXME-pxref{show-transformed-names}).
  2185. @opindex quote-chars, summary
  2186. @item --quote-chars=@var{string}
  2187. Always quote characters from @var{string}, even if the selected
  2188. quoting style would not quote them (@pxref{quoting styles}).
  2189. @opindex quoting-style, summary
  2190. @item --quoting-style=@var{style}
  2191. Set quoting style to use when printing member and file names
  2192. (@pxref{quoting styles}). Valid @var{style} values are:
  2193. @code{literal}, @code{shell}, @code{shell-always}, @code{c},
  2194. @code{escape}, @code{locale}, and @code{clocale}. Default quoting
  2195. style is @code{escape}, unless overridden while configuring the
  2196. package.
  2197. @opindex pax-option, summary
  2198. @item --pax-option=@var{keyword-list}
  2199. @FIXME{Such a detailed description does not belong there, move it elsewhere.}
  2200. This option is meaningful only with @acronym{POSIX.1-2001} archives
  2201. (@pxref{posix}). It modifies the way @command{tar} handles the
  2202. extended header keywords. @var{Keyword-list} is a comma-separated
  2203. list of keyword options, each keyword option taking one of
  2204. the following forms:
  2205. @table @asis
  2206. @item delete=@var{pattern}
  2207. When used with one of archive-creation commands,
  2208. this option instructs @command{tar} to omit from extended header records
  2209. that it produces any keywords matching the string @var{pattern}.
  2210. When used in extract or list mode, this option instructs tar
  2211. to ignore any keywords matching the given @var{pattern} in the extended
  2212. header records. In both cases, matching is performed using the pattern
  2213. matching notation described in @acronym{POSIX 1003.2}, 3.13
  2214. (See @cite{glob(7)}). For example:
  2215. @smallexample
  2216. --pax-option delete=security.*
  2217. @end smallexample
  2218. would suppress security-related information.
  2219. @item exthdr.name=@var{string}
  2220. This keyword allows user control over the name that is written into the
  2221. ustar header blocks for the extended headers. The name is obtained
  2222. from @var{string} after making the following substitutions:
  2223. @multitable @columnfractions .30 .70
  2224. @headitem Meta-character @tab Replaced By
  2225. @item %d @tab The directory name of the file, equivalent to the
  2226. result of the @command{dirname} utility on the translated pathname.
  2227. @item %f @tab The filename of the file, equivalent to the result
  2228. of the @command{basename} utility on the translated pathname.
  2229. @item %p @tab The process ID of the @command{tar} process.
  2230. @item %% @tab A @samp{%} character.
  2231. @end multitable
  2232. Any other @samp{%} characters in @var{string} produce undefined
  2233. results.
  2234. If no option @samp{exthdr.name=string} is specified, @command{tar}
  2235. will use the following default value:
  2236. @smallexample
  2237. %d/PaxHeaders.%p/%f
  2238. @end smallexample
  2239. @item globexthdr.name=@var{string}
  2240. This keyword allows user control over the name that is written into
  2241. the ustar header blocks for global extended header records. The name
  2242. is obtained from the contents of @var{string}, after making
  2243. the following substitutions:
  2244. @multitable @columnfractions .30 .70
  2245. @headitem Meta-character @tab Replaced By
  2246. @item %n @tab An integer that represents the
  2247. sequence number of the global extended header record in the archive,
  2248. starting at 1.
  2249. @item %p @tab The process ID of the @command{tar} process.
  2250. @item %% @tab A @samp{%} character.
  2251. @end multitable
  2252. Any other @samp{%} characters in @var{string} produce undefined results.
  2253. If no option @samp{globexthdr.name=string} is specified, @command{tar}
  2254. will use the following default value:
  2255. @smallexample
  2256. $TMPDIR/GlobalHead.%p.%n
  2257. @end smallexample
  2258. @noindent
  2259. where @samp{$TMPDIR} represents the value of the @var{TMPDIR}
  2260. environment variable. If @var{TMPDIR} is not set, @command{tar}
  2261. uses @samp{/tmp}.
  2262. @item @var{keyword}=@var{value}
  2263. When used with one of archive-creation commands, these keyword/value pairs
  2264. will be included at the beginning of the archive in a global extended
  2265. header record. When used with one of archive-reading commands,
  2266. @command{tar} will behave as if it has encountered these keyword/value
  2267. pairs at the beginning of the archive in a global extended header
  2268. record.
  2269. @item @var{keyword}:=@var{value}
  2270. When used with one of archive-creation commands, these keyword/value pairs
  2271. will be included as records at the beginning of an extended header for
  2272. each file. This is effectively equivalent to @var{keyword}=@var{value}
  2273. form except that it creates no global extended header records.
  2274. When used with one of archive-reading commands, @command{tar} will
  2275. behave as if these keyword/value pairs were included as records at the
  2276. end of each extended header; thus, they will override any global or
  2277. file-specific extended header record keywords of the same names.
  2278. For example, in the command:
  2279. @smallexample
  2280. tar --format=posix --create \
  2281. --file archive --pax-option gname:=user .
  2282. @end smallexample
  2283. the group name will be forced to a new value for all files
  2284. stored in the archive.
  2285. @end table
  2286. @opindex portability, summary
  2287. @item --portability
  2288. @itemx --old-archive
  2289. Synonym for @option{--format=v7}.
  2290. @opindex posix, summary
  2291. @item --posix
  2292. Same as @option{--format=posix}.
  2293. @opindex preserve, summary
  2294. @item --preserve
  2295. Synonymous with specifying both @option{--preserve-permissions} and
  2296. @option{--same-order}. @xref{Setting Access Permissions}.
  2297. @opindex preserve-order, summary
  2298. @item --preserve-order
  2299. (See @option{--same-order}; @pxref{Reading}.)
  2300. @opindex preserve-permissions, summary
  2301. @opindex same-permissions, summary
  2302. @item --preserve-permissions
  2303. @itemx --same-permissions
  2304. @itemx -p
  2305. When @command{tar} is extracting an archive, it normally subtracts the
  2306. users' umask from the permissions specified in the archive and uses
  2307. that number as the permissions to create the destination file.
  2308. Specifying this option instructs @command{tar} that it should use the
  2309. permissions directly from the archive. @xref{Setting Access Permissions}.
  2310. @opindex read-full-records, summary
  2311. @item --read-full-records
  2312. @itemx -B
  2313. Specifies that @command{tar} should reblock its input, for reading
  2314. from pipes on systems with buggy implementations. @xref{Reading}.
  2315. @opindex record-size, summary
  2316. @item --record-size=@var{size}
  2317. Instructs @command{tar} to use @var{size} bytes per record when accessing the
  2318. archive. @xref{Blocking Factor}.
  2319. @opindex recursion, summary
  2320. @item --recursion
  2321. With this option, @command{tar} recurses into directories.
  2322. @xref{recurse}.
  2323. @opindex recursive-unlink, summary
  2324. @item --recursive-unlink
  2325. Remove existing
  2326. directory hierarchies before extracting directories of the same name
  2327. from the archive. @xref{Recursive Unlink}.
  2328. @opindex remove-files, summary
  2329. @item --remove-files
  2330. Directs @command{tar} to remove the source file from the file system after
  2331. appending it to an archive. @xref{remove files}.
  2332. @opindex restrict, summary
  2333. @item --restrict
  2334. Disable use of some potentially harmful @command{tar} options.
  2335. Currently this option disables shell invocaton from multi-volume menu
  2336. (@pxref{Using Multiple Tapes}).
  2337. @opindex rmt-command, summary
  2338. @item --rmt-command=@var{cmd}
  2339. Notifies @command{tar} that it should use @var{cmd} instead of
  2340. the default @file{/usr/libexec/rmt} (@pxref{Remote Tape Server}).
  2341. @opindex rsh-command, summary
  2342. @item --rsh-command=@var{cmd}
  2343. Notifies @command{tar} that is should use @var{cmd} to communicate with remote
  2344. devices. @xref{Device}.
  2345. @opindex same-order, summary
  2346. @item --same-order
  2347. @itemx --preserve-order
  2348. @itemx -s
  2349. This option is an optimization for @command{tar} when running on machines with
  2350. small amounts of memory. It informs @command{tar} that the list of file
  2351. arguments has already been sorted to match the order of files in the
  2352. archive. @xref{Reading}.
  2353. @opindex same-owner, summary
  2354. @item --same-owner
  2355. When extracting an archive, @command{tar} will attempt to preserve the owner
  2356. specified in the @command{tar} archive with this option present.
  2357. This is the default behavior for the superuser; this option has an
  2358. effect only for ordinary users. @xref{Attributes}.
  2359. @opindex same-permissions, summary
  2360. @item --same-permissions
  2361. (See @option{--preserve-permissions}; @pxref{Setting Access Permissions}.)
  2362. @opindex show-defaults, summary
  2363. @item --show-defaults
  2364. Displays the default options used by @command{tar} and exits
  2365. successfully. This option is intended for use in shell scripts.
  2366. Here is an example of what you can see using this option:
  2367. @smallexample
  2368. $ tar --show-defaults
  2369. --format=gnu -f- -b20 --quoting-style=escape \
  2370. --rmt-command=/usr/libexec/rmt --rsh-command=/usr/bin/rsh
  2371. @end smallexample
  2372. @opindex show-omitted-dirs, summary
  2373. @item --show-omitted-dirs
  2374. Instructs @command{tar} to mention directories its skipping over when
  2375. operating on a @command{tar} archive. @xref{show-omitted-dirs}.
  2376. @opindex show-transformed-names, summary
  2377. @opindex show-stored-names, summary
  2378. @item --show-transformed-names
  2379. @itemx --show-stored-names
  2380. Display file or member names after applying any transformations
  2381. (@FIXME-pxref{}). In particular, when used in conjunction with one of
  2382. archive creation operations it instructs tar to list the member names
  2383. stored in the archive, as opposed to the actual file
  2384. names. @xref{listing member and file names}.
  2385. @opindex sparse, summary
  2386. @item --sparse
  2387. @itemx -S
  2388. Invokes a @acronym{GNU} extension when adding files to an archive that handles
  2389. sparse files efficiently. @xref{sparse}.
  2390. @opindex starting-file, summary
  2391. @item --starting-file=@var{name}
  2392. @itemx -K @var{name}
  2393. This option affects extraction only; @command{tar} will skip extracting
  2394. files in the archive until it finds one that matches @var{name}.
  2395. @xref{Scarce}.
  2396. @opindex strip-components, summary
  2397. @item --strip-components=@var{number}
  2398. Strip given @var{number} of leading components from file names before
  2399. extraction.@footnote{This option was called @option{--strip-path} in
  2400. version 1.14.} For example, if archive @file{archive.tar} contained
  2401. @file{/some/file/name}, then running
  2402. @smallexample
  2403. tar --extract --file archive.tar --strip-components=2
  2404. @end smallexample
  2405. @noindent
  2406. would extracted this file to file @file{name}.
  2407. @opindex suffix, summary
  2408. @item --suffix=@var{suffix}
  2409. Alters the suffix @command{tar} uses when backing up files from the default
  2410. @samp{~}. @xref{backup}.
  2411. @opindex tape-length, summary
  2412. @item --tape-length=@var{num}
  2413. @itemx -L @var{num}
  2414. Specifies the length of tapes that @command{tar} is writing as being
  2415. @w{@var{num} x 1024} bytes long. @xref{Using Multiple Tapes}.
  2416. @opindex test-label, summary
  2417. @item --test-label
  2418. Reads the volume label. If an argument is specified, test whether it
  2419. matches the volume label. @xref{--test-label option}.
  2420. @opindex to-command, summary
  2421. @item --to-command=@var{command}
  2422. During extraction @command{tar} will pipe extracted files to the
  2423. standard input of @var{command}. @xref{Writing to an External Program}.
  2424. @opindex to-stdout, summary
  2425. @item --to-stdout
  2426. @itemx -O
  2427. During extraction, @command{tar} will extract files to stdout rather
  2428. than to the file system. @xref{Writing to Standard Output}.
  2429. @opindex totals, summary
  2430. @item --totals
  2431. Displays the total number of bytes written after creating an archive.
  2432. @xref{verbose}.
  2433. @opindex touch, summary
  2434. @item --touch
  2435. @itemx -m
  2436. Sets the data modification time of extracted files to the extraction time,
  2437. rather than the data modification time stored in the archive.
  2438. @xref{Data Modification Times}.
  2439. @opindex uncompress, summary
  2440. @item --uncompress
  2441. (See @option{--compress}. @pxref{gzip})
  2442. @opindex ungzip, summary
  2443. @item --ungzip
  2444. (See @option{--gzip}. @pxref{gzip})
  2445. @opindex unlink-first, summary
  2446. @item --unlink-first
  2447. @itemx -U
  2448. Directs @command{tar} to remove the corresponding file from the file
  2449. system before extracting it from the archive. @xref{Unlink First}.
  2450. @opindex use-compress-program, summary
  2451. @item --use-compress-program=@var{prog}
  2452. Instructs @command{tar} to access the archive through @var{prog}, which is
  2453. presumed to be a compression program of some sort. @xref{gzip}.
  2454. @opindex utc, summary
  2455. @item --utc
  2456. Display file modification dates in @acronym{UTC}. This option implies
  2457. @option{--verbose}.
  2458. @opindex verbose, summary
  2459. @item --verbose
  2460. @itemx -v
  2461. Specifies that @command{tar} should be more verbose about the operations its
  2462. performing. This option can be specified multiple times for some
  2463. operations to increase the amount of information displayed.
  2464. @xref{verbose}.
  2465. @opindex verify, summary
  2466. @item --verify
  2467. @itemx -W
  2468. Verifies that the archive was correctly written when creating an
  2469. archive. @xref{verify}.
  2470. @opindex version, summary
  2471. @item --version
  2472. Print information about the program's name, version, origin and legal
  2473. status, all on standard output, and then exit successfully.
  2474. @xref{help}.
  2475. @opindex volno-file, summary
  2476. @item --volno-file=@var{file}
  2477. Used in conjunction with @option{--multi-volume}. @command{tar} will keep track
  2478. of which volume of a multi-volume archive its working in @var{file}.
  2479. @xref{volno-file}.
  2480. @opindex wildcards, summary
  2481. @item --wildcards
  2482. Use wildcards when matching member names with patterns.
  2483. @xref{controlling pattern-matching}.
  2484. @opindex wildcards-match-slash, summary
  2485. @item --wildcards-match-slash
  2486. Wildcards match @samp{/}.
  2487. @xref{controlling pattern-matching}.
  2488. @end table
  2489. @node Short Option Summary
  2490. @subsection Short Options Cross Reference
  2491. Here is an alphabetized list of all of the short option forms, matching
  2492. them with the equivalent long option.
  2493. @table @option
  2494. @item -A
  2495. @option{--concatenate}
  2496. @item -B
  2497. @option{--read-full-records}
  2498. @item -C
  2499. @option{--directory}
  2500. @item -F
  2501. @option{--info-script}
  2502. @item -G
  2503. @option{--incremental}
  2504. @item -K
  2505. @option{--starting-file}
  2506. @item -L
  2507. @option{--tape-length}
  2508. @item -M
  2509. @option{--multi-volume}
  2510. @item -N
  2511. @option{--newer}
  2512. @item -O
  2513. @option{--to-stdout}
  2514. @item -P
  2515. @option{--absolute-names}
  2516. @item -R
  2517. @option{--block-number}
  2518. @item -S
  2519. @option{--sparse}
  2520. @item -T
  2521. @option{--files-from}
  2522. @item -U
  2523. @option{--unlink-first}
  2524. @item -V
  2525. @option{--label}
  2526. @item -W
  2527. @option{--verify}
  2528. @item -X
  2529. @option{--exclude-from}
  2530. @item -Z
  2531. @option{--compress}
  2532. @item -b
  2533. @option{--blocking-factor}
  2534. @item -c
  2535. @option{--create}
  2536. @item -d
  2537. @option{--compare}
  2538. @item -f
  2539. @option{--file}
  2540. @item -g
  2541. @option{--listed-incremental}
  2542. @item -h
  2543. @option{--dereference}
  2544. @item -i
  2545. @option{--ignore-zeros}
  2546. @item -j
  2547. @option{--bzip2}
  2548. @item -k
  2549. @option{--keep-old-files}
  2550. @item -l
  2551. @option{--one-file-system}. Use of this short option is deprecated. It
  2552. is retained for compatibility with the earlier versions of GNU
  2553. @command{tar}, and will be changed in future releases.
  2554. @xref{Changes}, for more information.
  2555. @item -m
  2556. @option{--touch}
  2557. @item -o
  2558. When creating --- @option{--no-same-owner}, when extracting ---
  2559. @option{--portability}.
  2560. The later usage is deprecated. It is retained for compatibility with
  2561. the earlier versions of @GNUTAR{}. In the future releases
  2562. @option{-o} will be equivalent to @option{--no-same-owner} only.
  2563. @item -p
  2564. @option{--preserve-permissions}
  2565. @item -r
  2566. @option{--append}
  2567. @item -s
  2568. @option{--same-order}
  2569. @item -t
  2570. @option{--list}
  2571. @item -u
  2572. @option{--update}
  2573. @item -v
  2574. @option{--verbose}
  2575. @item -w
  2576. @option{--interactive}
  2577. @item -x
  2578. @option{--extract}
  2579. @item -z
  2580. @option{--gzip}
  2581. @end table
  2582. @node help
  2583. @section @GNUTAR{} documentation
  2584. @cindex Getting program version number
  2585. @opindex version
  2586. @cindex Version of the @command{tar} program
  2587. Being careful, the first thing is really checking that you are using
  2588. @GNUTAR{}, indeed. The @option{--version} option
  2589. causes @command{tar} to print information about its name, version,
  2590. origin and legal status, all on standard output, and then exit
  2591. successfully. For example, @w{@samp{tar --version}} might print:
  2592. @smallexample
  2593. tar (GNU tar) 1.15.2
  2594. Copyright (C) 2006 Free Software Foundation, Inc.
  2595. This is free software. You may redistribute copies of it under the terms of
  2596. the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
  2597. There is NO WARRANTY, to the extent permitted by law.
  2598. Written by John Gilmore and Jay Fenlason.
  2599. @end smallexample
  2600. @noindent
  2601. The first occurrence of @samp{tar} in the result above is the program
  2602. name in the package (for example, @command{rmt} is another program),
  2603. while the second occurrence of @samp{tar} is the name of the package
  2604. itself, containing possibly many programs. The package is currently
  2605. named @samp{tar}, after the name of the main program it
  2606. contains@footnote{There are plans to merge the @command{cpio} and
  2607. @command{tar} packages into a single one which would be called
  2608. @code{paxutils}. So, who knows if, one of this days, the
  2609. @option{--version} would not output @w{@samp{tar (@acronym{GNU}
  2610. paxutils) 3.2}}}.
  2611. @cindex Obtaining help
  2612. @cindex Listing all @command{tar} options
  2613. @opindex help, introduction
  2614. Another thing you might want to do is checking the spelling or meaning
  2615. of some particular @command{tar} option, without resorting to this
  2616. manual, for once you have carefully read it. @GNUTAR{}
  2617. has a short help feature, triggerable through the
  2618. @option{--help} option. By using this option, @command{tar} will
  2619. print a usage message listing all available options on standard
  2620. output, then exit successfully, without doing anything else and
  2621. ignoring all other options. Even if this is only a brief summary, it
  2622. may be several screens long. So, if you are not using some kind of
  2623. scrollable window, you might prefer to use something like:
  2624. @smallexample
  2625. $ @kbd{tar --help | less}
  2626. @end smallexample
  2627. @noindent
  2628. presuming, here, that you like using @command{less} for a pager. Other
  2629. popular pagers are @command{more} and @command{pg}. If you know about some
  2630. @var{keyword} which interests you and do not want to read all the
  2631. @option{--help} output, another common idiom is doing:
  2632. @smallexample
  2633. tar --help | grep @var{keyword}
  2634. @end smallexample
  2635. @noindent
  2636. for getting only the pertinent lines. Notice, however, that some
  2637. @command{tar} options have long description lines and the above
  2638. command will list only the first of them.
  2639. The exact look of the option summary displayed by @kbd{tar --help} is
  2640. configurable. @xref{Configuring Help Summary}, for a detailed description.
  2641. @opindex usage
  2642. If you only wish to check the spelling of an option, running @kbd{tar
  2643. --usage} may be a better choice. This will display a terse list of
  2644. @command{tar} option without accompanying explanations.
  2645. The short help output is quite succinct, and you might have to get
  2646. back to the full documentation for precise points. If you are reading
  2647. this paragraph, you already have the @command{tar} manual in some
  2648. form. This manual is available in a variety of forms from
  2649. @url{http://www.gnu.org/software/tar/manual}. It may printed out of the @GNUTAR{}
  2650. distribution, provided you have @TeX{} already installed somewhere,
  2651. and a laser printer around. Just configure the distribution, execute
  2652. the command @w{@samp{make dvi}}, then print @file{doc/tar.dvi} the
  2653. usual way (contact your local guru to know how). If @GNUTAR{}
  2654. has been conveniently installed at your place, this
  2655. manual is also available in interactive, hypertextual form as an Info
  2656. file. Just call @w{@samp{info tar}} or, if you do not have the
  2657. @command{info} program handy, use the Info reader provided within
  2658. @acronym{GNU} Emacs, calling @samp{tar} from the main Info menu.
  2659. There is currently no @code{man} page for @GNUTAR{}.
  2660. If you observe such a @code{man} page on the system you are running,
  2661. either it does not belong to @GNUTAR{}, or it has not
  2662. been produced by @acronym{GNU}. Some package maintainers convert
  2663. @kbd{tar --help} output to a man page, using @command{help2man}. In
  2664. any case, please bear in mind that the authoritative source of
  2665. information about @GNUTAR{} is this Texinfo documentation.
  2666. @node defaults
  2667. @section Obtaining @GNUTAR{} default values
  2668. @opindex show-defaults
  2669. @GNUTAR{} has some predefined defaults that are used when you do not
  2670. explicitely specify another values. To obtain a list of such
  2671. defaults, use @option{--show-defaults} option. This will output the
  2672. values in the form of @command{tar} command line options:
  2673. @smallexample
  2674. @group
  2675. @kbd{tar --show-defaults}
  2676. --format=gnu -f- -b20 --rmt-command=/etc/rmt --rsh-command=/usr/bin/rsh
  2677. @end group
  2678. @end smallexample
  2679. @noindent
  2680. The above output shows that this version of @GNUTAR{} defaults to
  2681. using @samp{gnu} archive format (@pxref{Formats}), it uses standard
  2682. output as the archive, if no @option{--file} option has been given
  2683. (@pxref{file tutorial}), the default blocking factor is 20
  2684. (@pxref{Blocking Factor}). It also shows the default locations where
  2685. @command{tar} will look for @command{rmt} and @command{rsh} binaries.
  2686. @node verbose
  2687. @section Checking @command{tar} progress
  2688. Typically, @command{tar} performs most operations without reporting any
  2689. information to the user except error messages. When using @command{tar}
  2690. with many options, particularly ones with complicated or
  2691. difficult-to-predict behavior, it is possible to make serious mistakes.
  2692. @command{tar} provides several options that make observing @command{tar}
  2693. easier. These options cause @command{tar} to print information as it
  2694. progresses in its job, and you might want to use them just for being
  2695. more careful about what is going on, or merely for entertaining
  2696. yourself. If you have encountered a problem when operating on an
  2697. archive, however, you may need more information than just an error
  2698. message in order to solve the problem. The following options can be
  2699. helpful diagnostic tools.
  2700. @cindex Verbose operation
  2701. @opindex verbose
  2702. Normally, the @option{--list} (@option{-t}) command to list an archive
  2703. prints just the file names (one per line) and the other commands are
  2704. silent. When used with most operations, the @option{--verbose}
  2705. (@option{-v}) option causes @command{tar} to print the name of each
  2706. file or archive member as it is processed. This and the other options
  2707. which make @command{tar} print status information can be useful in
  2708. monitoring @command{tar}.
  2709. With @option{--create} or @option{--extract}, @option{--verbose} used
  2710. once just prints the names of the files or members as they are processed.
  2711. Using it twice causes @command{tar} to print a longer listing
  2712. (reminiscent of @samp{ls -l}) for each member. Since @option{--list}
  2713. already prints the names of the members, @option{--verbose} used once
  2714. with @option{--list} causes @command{tar} to print an @samp{ls -l}
  2715. type listing of the files in the archive. The following examples both
  2716. extract members with long list output:
  2717. @smallexample
  2718. $ @kbd{tar --extract --file=archive.tar --verbose --verbose}
  2719. $ @kbd{tar xvvf archive.tar}
  2720. @end smallexample
  2721. Verbose output appears on the standard output except when an archive is
  2722. being written to the standard output, as with @samp{tar --create
  2723. --file=- --verbose} (@samp{tar cfv -}, or even @samp{tar cv}---if the
  2724. installer let standard output be the default archive). In that case
  2725. @command{tar} writes verbose output to the standard error stream.
  2726. If @option{--index-file=@var{file}} is specified, @command{tar} sends
  2727. verbose output to @var{file} rather than to standard output or standard
  2728. error.
  2729. @cindex Obtaining total status information
  2730. @opindex totals
  2731. The @option{--totals} option---which is only meaningful when used with
  2732. @option{--create} (@option{-c})---causes @command{tar} to print the total
  2733. amount written to the archive, after it has been fully created.
  2734. @cindex Progress information
  2735. @opindex checkpoint
  2736. The @option{--checkpoint} option prints an occasional message
  2737. as @command{tar} reads or writes the archive. In fact, it prints
  2738. a message each 10 records read or written. It is designed for
  2739. those who don't need the more detailed (and voluminous) output of
  2740. @option{--block-number} (@option{-R}), but do want visual confirmation
  2741. that @command{tar} is actually making forward progress.
  2742. @FIXME{There is some confusion here. It seems that -R once wrote a
  2743. message at @samp{every} record read or written.}
  2744. @opindex show-omitted-dirs
  2745. @anchor{show-omitted-dirs}
  2746. The @option{--show-omitted-dirs} option, when reading an archive---with
  2747. @option{--list} or @option{--extract}, for example---causes a message
  2748. to be printed for each directory in the archive which is skipped.
  2749. This happens regardless of the reason for skipping: the directory might
  2750. not have been named on the command line (implicitly or explicitly),
  2751. it might be excluded by the use of the @option{--exclude=@var{pattern}} option, or
  2752. some other reason.
  2753. @opindex block-number
  2754. @cindex Block number where error occurred
  2755. @anchor{block-number}
  2756. If @option{--block-number} (@option{-R}) is used, @command{tar} prints, along with
  2757. every message it would normally produce, the block number within the
  2758. archive where the message was triggered. Also, supplementary messages
  2759. are triggered when reading blocks full of NULs, or when hitting end of
  2760. file on the archive. As of now, if the archive if properly terminated
  2761. with a NUL block, the reading of the file may stop before end of file
  2762. is met, so the position of end of file will not usually show when
  2763. @option{--block-number} (@option{-R}) is used. Note that @GNUTAR{}
  2764. drains the archive before exiting when reading the
  2765. archive from a pipe.
  2766. @cindex Error message, block number of
  2767. This option is especially useful when reading damaged archives, since
  2768. it helps pinpoint the damaged sections. It can also be used with
  2769. @option{--list} (@option{-t}) when listing a file-system backup tape, allowing you to
  2770. choose among several backup tapes when retrieving a file later, in
  2771. favor of the tape where the file appears earliest (closest to the
  2772. front of the tape). @xref{backup}.
  2773. @node interactive
  2774. @section Asking for Confirmation During Operations
  2775. @cindex Interactive operation
  2776. Typically, @command{tar} carries out a command without stopping for
  2777. further instructions. In some situations however, you may want to
  2778. exclude some files and archive members from the operation (for instance
  2779. if disk or storage space is tight). You can do this by excluding
  2780. certain files automatically (@pxref{Choosing}), or by performing
  2781. an operation interactively, using the @option{--interactive} (@option{-w}) option.
  2782. @command{tar} also accepts @option{--confirmation} for this option.
  2783. @opindex interactive
  2784. When the @option{--interactive} (@option{-w}) option is specified, before
  2785. reading, writing, or deleting files, @command{tar} first prints a message
  2786. for each such file, telling what operation it intends to take, then asks
  2787. for confirmation on the terminal. The actions which require
  2788. confirmation include adding a file to the archive, extracting a file
  2789. from the archive, deleting a file from the archive, and deleting a file
  2790. from disk. To confirm the action, you must type a line of input
  2791. beginning with @samp{y}. If your input line begins with anything other
  2792. than @samp{y}, @command{tar} skips that file.
  2793. If @command{tar} is reading the archive from the standard input,
  2794. @command{tar} opens the file @file{/dev/tty} to support the interactive
  2795. communications.
  2796. Verbose output is normally sent to standard output, separate from
  2797. other error messages. However, if the archive is produced directly
  2798. on standard output, then verbose output is mixed with errors on
  2799. @code{stderr}. Producing the archive on standard output may be used
  2800. as a way to avoid using disk space, when the archive is soon to be
  2801. consumed by another process reading it, say. Some people felt the need
  2802. of producing an archive on stdout, still willing to segregate between
  2803. verbose output and error output. A possible approach would be using a
  2804. named pipe to receive the archive, and having the consumer process to
  2805. read from that named pipe. This has the advantage of letting standard
  2806. output free to receive verbose output, all separate from errors.
  2807. @node operations
  2808. @chapter @GNUTAR{} Operations
  2809. @menu
  2810. * Basic tar::
  2811. * Advanced tar::
  2812. * create options::
  2813. * extract options::
  2814. * backup::
  2815. * Applications::
  2816. * looking ahead::
  2817. @end menu
  2818. @node Basic tar
  2819. @section Basic @GNUTAR{} Operations
  2820. The basic @command{tar} operations, @option{--create} (@option{-c}),
  2821. @option{--list} (@option{-t}) and @option{--extract} (@option{--get},
  2822. @option{-x}), are currently presented and described in the tutorial
  2823. chapter of this manual. This section provides some complementary notes
  2824. for these operations.
  2825. @table @option
  2826. @opindex create, complementary notes
  2827. @item --create
  2828. @itemx -c
  2829. Creating an empty archive would have some kind of elegance. One can
  2830. initialize an empty archive and later use @option{--append}
  2831. (@option{-r}) for adding all members. Some applications would not
  2832. welcome making an exception in the way of adding the first archive
  2833. member. On the other hand, many people reported that it is
  2834. dangerously too easy for @command{tar} to destroy a magnetic tape with
  2835. an empty archive@footnote{This is well described in @cite{Unix-haters
  2836. Handbook}, by Simson Garfinkel, Daniel Weise & Steven Strassmann, IDG
  2837. Books, ISBN 1-56884-203-1.}. The two most common errors are:
  2838. @enumerate
  2839. @item
  2840. Mistakingly using @code{create} instead of @code{extract}, when the
  2841. intent was to extract the full contents of an archive. This error
  2842. is likely: keys @kbd{c} and @kbd{x} are right next to each other on
  2843. the QWERTY keyboard. Instead of being unpacked, the archive then
  2844. gets wholly destroyed. When users speak about @dfn{exploding} an
  2845. archive, they usually mean something else :-).
  2846. @item
  2847. Forgetting the argument to @code{file}, when the intent was to create
  2848. an archive with a single file in it. This error is likely because a
  2849. tired user can easily add the @kbd{f} key to the cluster of option
  2850. letters, by the mere force of habit, without realizing the full
  2851. consequence of doing so. The usual consequence is that the single
  2852. file, which was meant to be saved, is rather destroyed.
  2853. @end enumerate
  2854. So, recognizing the likelihood and the catastrophical nature of these
  2855. errors, @GNUTAR{} now takes some distance from elegance, and
  2856. cowardly refuses to create an archive when @option{--create} option is
  2857. given, there are no arguments besides options, and
  2858. @option{--files-from} (@option{-T}) option is @emph{not} used. To get
  2859. around the cautiousness of @GNUTAR{} and nevertheless create an
  2860. archive with nothing in it, one may still use, as the value for the
  2861. @option{--files-from} option, a file with no names in it, as shown in
  2862. the following commands:
  2863. @smallexample
  2864. @kbd{tar --create --file=empty-archive.tar --files-from=/dev/null}
  2865. @kbd{tar cfT empty-archive.tar /dev/null}
  2866. @end smallexample
  2867. @opindex extract, complementary notes
  2868. @item --extract
  2869. @itemx --get
  2870. @itemx -x
  2871. A socket is stored, within a @GNUTAR{} archive, as a pipe.
  2872. @item @option{--list} (@option{-t})
  2873. @GNUTAR{} now shows dates as @samp{1996-08-30},
  2874. while it used to show them as @samp{Aug 30 1996}. Preferably,
  2875. people should get used to ISO 8601 dates. Local American dates should
  2876. be made available again with full date localization support, once
  2877. ready. In the meantime, programs not being localizable for dates
  2878. should prefer international dates, that's really the way to go.
  2879. Look up @url{http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html} if you
  2880. are curious, it contains a detailed explanation of the ISO 8601 standard.
  2881. @end table
  2882. @node Advanced tar
  2883. @section Advanced @GNUTAR{} Operations
  2884. Now that you have learned the basics of using @GNUTAR{}, you may want
  2885. to learn about further ways in which @command{tar} can help you.
  2886. This chapter presents five, more advanced operations which you probably
  2887. won't use on a daily basis, but which serve more specialized functions.
  2888. We also explain the different styles of options and why you might want
  2889. to use one or another, or a combination of them in your @command{tar}
  2890. commands. Additionally, this chapter includes options which allow you to
  2891. define the output from @command{tar} more carefully, and provide help and
  2892. error correction in special circumstances.
  2893. @FIXME{check this after the chapter is actually revised to make sure
  2894. it still introduces the info in the chapter correctly : ).}
  2895. @menu
  2896. * Operations::
  2897. * append::
  2898. * update::
  2899. * concatenate::
  2900. * delete::
  2901. * compare::
  2902. * quoting styles::
  2903. @end menu
  2904. @node Operations
  2905. @subsection The Five Advanced @command{tar} Operations
  2906. @UNREVISED
  2907. In the last chapter, you learned about the first three operations to
  2908. @command{tar}. This chapter presents the remaining five operations to
  2909. @command{tar}: @option{--append}, @option{--update}, @option{--concatenate},
  2910. @option{--delete}, and @option{--compare}.
  2911. You are not likely to use these operations as frequently as those
  2912. covered in the last chapter; however, since they perform specialized
  2913. functions, they are quite useful when you do need to use them. We
  2914. will give examples using the same directory and files that you created
  2915. in the last chapter. As you may recall, the directory is called
  2916. @file{practice}, the files are @samp{jazz}, @samp{blues}, @samp{folk},
  2917. @samp{rock}, and the two archive files you created are
  2918. @samp{collection.tar} and @samp{music.tar}.
  2919. We will also use the archive files @samp{afiles.tar} and
  2920. @samp{bfiles.tar}. @samp{afiles.tar} contains the members @samp{apple},
  2921. @samp{angst}, and @samp{aspic}. @samp{bfiles.tar} contains the members
  2922. @samp{./birds}, @samp{baboon}, and @samp{./box}.
  2923. Unless we state otherwise, all practicing you do and examples you follow
  2924. in this chapter will take place in the @file{practice} directory that
  2925. you created in the previous chapter; see @ref{prepare for examples}.
  2926. (Below in this section, we will remind you of the state of the examples
  2927. where the last chapter left them.)
  2928. The five operations that we will cover in this chapter are:
  2929. @table @option
  2930. @item --append
  2931. @itemx -r
  2932. Add new entries to an archive that already exists.
  2933. @item --update
  2934. @itemx -r
  2935. Add more recent copies of archive members to the end of an archive, if
  2936. they exist.
  2937. @item --concatenate
  2938. @itemx --catenate
  2939. @itemx -A
  2940. Add one or more pre-existing archives to the end of another archive.
  2941. @item --delete
  2942. Delete items from an archive (does not work on tapes).
  2943. @item --compare
  2944. @itemx --diff
  2945. @itemx -d
  2946. Compare archive members to their counterparts in the file system.
  2947. @end table
  2948. @node append
  2949. @subsection How to Add Files to Existing Archives: @option{--append}
  2950. @UNREVISED
  2951. @opindex append
  2952. If you want to add files to an existing archive, you don't need to
  2953. create a new archive; you can use @option{--append} (@option{-r}).
  2954. The archive must already exist in order to use @option{--append}. (A
  2955. related operation is the @option{--update} operation; you can use this
  2956. to add newer versions of archive members to an existing archive. To learn how to
  2957. do this with @option{--update}, @pxref{update}.)
  2958. If you use @option{--append} to add a file that has the same name as an
  2959. archive member to an archive containing that archive member, then the
  2960. old member is not deleted. What does happen, however, is somewhat
  2961. complex. @command{tar} @emph{allows} you to have infinite number of files
  2962. with the same name. Some operations treat these same-named members no
  2963. differently than any other set of archive members: for example, if you
  2964. view an archive with @option{--list} (@option{-t}), you will see all
  2965. of those members listed, with their data modification times, owners, etc.
  2966. Other operations don't deal with these members as perfectly as you might
  2967. prefer; if you were to use @option{--extract} to extract the archive,
  2968. only the most recently added copy of a member with the same name as four
  2969. other members would end up in the working directory. This is because
  2970. @option{--extract} extracts an archive in the order the members appeared
  2971. in the archive; the most recently archived members will be extracted
  2972. last. Additionally, an extracted member will @emph{replace} a file of
  2973. the same name which existed in the directory already, and @command{tar}
  2974. will not prompt you about this@footnote{Unless you give it
  2975. @option{--keep-old-files} option, or the disk copy is newer than the
  2976. the one in the archive and you invoke @command{tar} with
  2977. @option{--keep-newer-files} option}. Thus, only the most recently archived
  2978. member will end up being extracted, as it will replace the one
  2979. extracted before it, and so on.
  2980. There exists a special option that allows you to get around this
  2981. behavior and extract (or list) only a particular copy of the file.
  2982. This is @option{--occurrence} option. If you run @command{tar} with
  2983. this option, it will extract only the first copy of the file. You
  2984. may also give this option an argument specifying the number of
  2985. copy to be extracted. Thus, for example if the archive
  2986. @file{archive.tar} contained three copies of file @file{myfile}, then
  2987. the command
  2988. @smallexample
  2989. tar --extract --file archive.tar --occurrence=2 myfile
  2990. @end smallexample
  2991. @noindent
  2992. would extract only the second copy. @xref{Option
  2993. Summary,---occurrence}, for the description of @option{--occurrence}
  2994. option.
  2995. @FIXME{ hag -- you might want to incorporate some of the above into the
  2996. MMwtSN node; not sure. i didn't know how to make it simpler...
  2997. There are a few ways to get around this. (maybe xref Multiple Members
  2998. with the Same Name.}
  2999. @cindex Members, replacing with other members
  3000. @cindex Replacing members with other members
  3001. If you want to replace an archive member, use @option{--delete} to
  3002. delete the member you want to remove from the archive, , and then use
  3003. @option{--append} to add the member you want to be in the archive. Note
  3004. that you can not change the order of the archive; the most recently
  3005. added member will still appear last. In this sense, you cannot truly
  3006. ``replace'' one member with another. (Replacing one member with another
  3007. will not work on certain types of media, such as tapes; see @ref{delete}
  3008. and @ref{Media}, for more information.)
  3009. @menu
  3010. * appending files:: Appending Files to an Archive
  3011. * multiple::
  3012. @end menu
  3013. @node appending files
  3014. @subsubsection Appending Files to an Archive
  3015. @UNREVISED
  3016. @cindex Adding files to an Archive
  3017. @cindex Appending files to an Archive
  3018. @cindex Archives, Appending files to
  3019. The simplest way to add a file to an already existing archive is the
  3020. @option{--append} (@option{-r}) operation, which writes specified
  3021. files into the archive whether or not they are already among the
  3022. archived files.
  3023. When you use @option{--append}, you @emph{must} specify file name
  3024. arguments, as there is no default. If you specify a file that already
  3025. exists in the archive, another copy of the file will be added to the
  3026. end of the archive. As with other operations, the member names of the
  3027. newly added files will be exactly the same as their names given on the
  3028. command line. The @option{--verbose} (@option{-v}) option will print
  3029. out the names of the files as they are written into the archive.
  3030. @option{--append} cannot be performed on some tape drives, unfortunately,
  3031. due to deficiencies in the formats those tape drives use. The archive
  3032. must be a valid @command{tar} archive, or else the results of using this
  3033. operation will be unpredictable. @xref{Media}.
  3034. To demonstrate using @option{--append} to add a file to an archive,
  3035. create a file called @file{rock} in the @file{practice} directory.
  3036. Make sure you are in the @file{practice} directory. Then, run the
  3037. following @command{tar} command to add @file{rock} to
  3038. @file{collection.tar}:
  3039. @smallexample
  3040. $ @kbd{tar --append --file=collection.tar rock}
  3041. @end smallexample
  3042. @noindent
  3043. If you now use the @option{--list} (@option{-t}) operation, you will see that
  3044. @file{rock} has been added to the archive:
  3045. @smallexample
  3046. $ @kbd{tar --list --file=collection.tar}
  3047. -rw-r--r-- me user 28 1996-10-18 16:31 jazz
  3048. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  3049. -rw-r--r-- me user 20 1996-09-23 16:44 folk
  3050. -rw-r--r-- me user 20 1996-09-23 16:44 rock
  3051. @end smallexample
  3052. @node multiple
  3053. @subsubsection Multiple Files with the Same Name
  3054. You can use @option{--append} (@option{-r}) to add copies of files
  3055. which have been updated since the archive was created. (However, we
  3056. do not recommend doing this since there is another @command{tar}
  3057. option called @option{--update}; @xref{update}, for more information.
  3058. We describe this use of @option{--append} here for the sake of
  3059. completeness.) When you extract the archive, the older version will
  3060. be effectively lost. This works because files are extracted from an
  3061. archive in the order in which they were archived. Thus, when the
  3062. archive is extracted, a file archived later in time will replace a
  3063. file of the same name which was archived earlier, even though the
  3064. older version of the file will remain in the archive unless you delete
  3065. all versions of the file.
  3066. Supposing you change the file @file{blues} and then append the changed
  3067. version to @file{collection.tar}. As you saw above, the original
  3068. @file{blues} is in the archive @file{collection.tar}. If you change the
  3069. file and append the new version of the file to the archive, there will
  3070. be two copies in the archive. When you extract the archive, the older
  3071. version of the file will be extracted first, and then replaced by the
  3072. newer version when it is extracted.
  3073. You can append the new, changed copy of the file @file{blues} to the
  3074. archive in this way:
  3075. @smallexample
  3076. $ @kbd{tar --append --verbose --file=collection.tar blues}
  3077. blues
  3078. @end smallexample
  3079. @noindent
  3080. Because you specified the @option{--verbose} option, @command{tar} has
  3081. printed the name of the file being appended as it was acted on. Now
  3082. list the contents of the archive:
  3083. @smallexample
  3084. $ @kbd{tar --list --verbose --file=collection.tar}
  3085. -rw-r--r-- me user 28 1996-10-18 16:31 jazz
  3086. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  3087. -rw-r--r-- me user 20 1996-09-23 16:44 folk
  3088. -rw-r--r-- me user 20 1996-09-23 16:44 rock
  3089. -rw-r--r-- me user 58 1996-10-24 18:30 blues
  3090. @end smallexample
  3091. @noindent
  3092. The newest version of @file{blues} is now at the end of the archive
  3093. (note the different creation dates and file sizes). If you extract
  3094. the archive, the older version of the file @file{blues} will be
  3095. replaced by the newer version. You can confirm this by extracting
  3096. the archive and running @samp{ls} on the directory.
  3097. If you wish to extract the first occurrence of the file @file{blues}
  3098. from the archive, use @option{--occurrence} option, as shown in
  3099. the following example:
  3100. @smallexample
  3101. $ @kbd{tar --extract -vv --occurrence --file=collection.tar blues}
  3102. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  3103. @end smallexample
  3104. @xref{Writing}, for more information on @option{--extract} and
  3105. @xref{Option Summary, --occurrence}, for the description of
  3106. @option{--occurrence} option.
  3107. @node update
  3108. @subsection Updating an Archive
  3109. @UNREVISED
  3110. @cindex Updating an archive
  3111. @opindex update
  3112. In the previous section, you learned how to use @option{--append} to
  3113. add a file to an existing archive. A related operation is
  3114. @option{--update} (@option{-u}). The @option{--update} operation
  3115. updates a @command{tar} archive by comparing the date of the specified
  3116. archive members against the date of the file with the same name. If
  3117. the file has been modified more recently than the archive member, then
  3118. the newer version of the file is added to the archive (as with
  3119. @option{--append}).
  3120. Unfortunately, you cannot use @option{--update} with magnetic tape drives.
  3121. The operation will fail.
  3122. @FIXME{other examples of media on which --update will fail? need to ask
  3123. charles and/or mib/thomas/dave shevett..}
  3124. Both @option{--update} and @option{--append} work by adding to the end
  3125. of the archive. When you extract a file from the archive, only the
  3126. version stored last will wind up in the file system, unless you use
  3127. the @option{--backup} option. @FIXME-ref{Multiple Members with the
  3128. Same Name}
  3129. @menu
  3130. * how to update::
  3131. @end menu
  3132. @node how to update
  3133. @subsubsection How to Update an Archive Using @option{--update}
  3134. You must use file name arguments with the @option{--update}
  3135. (@option{-u}) operation. If you don't specify any files,
  3136. @command{tar} won't act on any files and won't tell you that it didn't
  3137. do anything (which may end up confusing you).
  3138. @c note: the above parenthetical added because in fact, this
  3139. @c behavior just confused the author. :-)
  3140. To see the @option{--update} option at work, create a new file,
  3141. @file{classical}, in your practice directory, and some extra text to the
  3142. file @file{blues}, using any text editor. Then invoke @command{tar} with
  3143. the @samp{update} operation and the @option{--verbose} (@option{-v})
  3144. option specified, using the names of all the files in the practice
  3145. directory as file name arguments:
  3146. @smallexample
  3147. $ @kbd{tar --update -v -f collection.tar blues folk rock classical}
  3148. blues
  3149. classical
  3150. $
  3151. @end smallexample
  3152. @noindent
  3153. Because we have specified verbose mode, @command{tar} prints out the names
  3154. of the files it is working on, which in this case are the names of the
  3155. files that needed to be updated. If you run @samp{tar --list} and look
  3156. at the archive, you will see @file{blues} and @file{classical} at its
  3157. end. There will be a total of two versions of the member @samp{blues};
  3158. the one at the end will be newer and larger, since you added text before
  3159. updating it.
  3160. (The reason @command{tar} does not overwrite the older file when updating
  3161. it is because writing to the middle of a section of tape is a difficult
  3162. process. Tapes are not designed to go backward. @xref{Media}, for more
  3163. information about tapes.
  3164. @option{--update} (@option{-u}) is not suitable for performing backups for two
  3165. reasons: it does not change directory content entries, and it
  3166. lengthens the archive every time it is used. The @GNUTAR{}
  3167. options intended specifically for backups are more
  3168. efficient. If you need to run backups, please consult @ref{Backups}.
  3169. @node concatenate
  3170. @subsection Combining Archives with @option{--concatenate}
  3171. @cindex Adding archives to an archive
  3172. @cindex Concatenating Archives
  3173. @opindex concatenate
  3174. @opindex catenate
  3175. @c @cindex @option{-A} described
  3176. Sometimes it may be convenient to add a second archive onto the end of
  3177. an archive rather than adding individual files to the archive. To add
  3178. one or more archives to the end of another archive, you should use the
  3179. @option{--concatenate} (@option{--catenate}, @option{-A}) operation.
  3180. To use @option{--concatenate}, give the first archive with
  3181. @option{--file} option and name the rest of archives to be
  3182. concatenated on the command line. The members, and their member
  3183. names, will be copied verbatim from those archives to the first one.
  3184. @FIXME-ref{This can cause multiple members to have the same name, for
  3185. information on how this affects reading the archive, Multiple
  3186. Members with the Same Name.}
  3187. The new, concatenated archive will be called by the same name as the
  3188. one given with the @option{--file} option. As usual, if you omit
  3189. @option{--file}, @command{tar} will use the value of the environment
  3190. variable @env{TAPE}, or, if this has not been set, the default archive name.
  3191. @FIXME{There is no way to specify a new name...}
  3192. To demonstrate how @option{--concatenate} works, create two small archives
  3193. called @file{bluesrock.tar} and @file{folkjazz.tar}, using the relevant
  3194. files from @file{practice}:
  3195. @smallexample
  3196. $ @kbd{tar -cvf bluesrock.tar blues rock}
  3197. blues
  3198. rock
  3199. $ @kbd{tar -cvf folkjazz.tar folk jazz}
  3200. folk
  3201. jazz
  3202. @end smallexample
  3203. @noindent
  3204. If you like, You can run @samp{tar --list} to make sure the archives
  3205. contain what they are supposed to:
  3206. @smallexample
  3207. $ @kbd{tar -tvf bluesrock.tar}
  3208. -rw-r--r-- melissa user 105 1997-01-21 19:42 blues
  3209. -rw-r--r-- melissa user 33 1997-01-20 15:34 rock
  3210. $ @kbd{tar -tvf jazzfolk.tar}
  3211. -rw-r--r-- melissa user 20 1996-09-23 16:44 folk
  3212. -rw-r--r-- melissa user 65 1997-01-30 14:15 jazz
  3213. @end smallexample
  3214. We can concatenate these two archives with @command{tar}:
  3215. @smallexample
  3216. $ @kbd{cd ..}
  3217. $ @kbd{tar --concatenate --file=bluesrock.tar jazzfolk.tar}
  3218. @end smallexample
  3219. If you now list the contents of the @file{bluesrock.tar}, you will see
  3220. that now it also contains the archive members of @file{jazzfolk.tar}:
  3221. @smallexample
  3222. $ @kbd{tar --list --file=bluesrock.tar}
  3223. blues
  3224. rock
  3225. folk
  3226. jazz
  3227. @end smallexample
  3228. When you use @option{--concatenate}, the source and target archives must
  3229. already exist and must have been created using compatible format
  3230. parameters. Notice, that @command{tar} does not check whether the
  3231. archives it concatenates have compatible formats, it does not
  3232. even check if the files are really tar archives.
  3233. Like @option{--append} (@option{-r}), this operation cannot be performed on some
  3234. tape drives, due to deficiencies in the formats those tape drives use.
  3235. @cindex @code{concatenate} vs @command{cat}
  3236. @cindex @command{cat} vs @code{concatenate}
  3237. It may seem more intuitive to you to want or try to use @command{cat} to
  3238. concatenate two archives instead of using the @option{--concatenate}
  3239. operation; after all, @command{cat} is the utility for combining files.
  3240. However, @command{tar} archives incorporate an end-of-file marker which
  3241. must be removed if the concatenated archives are to be read properly as
  3242. one archive. @option{--concatenate} removes the end-of-archive marker
  3243. from the target archive before each new archive is appended. If you use
  3244. @command{cat} to combine the archives, the result will not be a valid
  3245. @command{tar} format archive. If you need to retrieve files from an
  3246. archive that was added to using the @command{cat} utility, use the
  3247. @option{--ignore-zeros} (@option{-i}) option. @xref{Ignore Zeros}, for further
  3248. information on dealing with archives improperly combined using the
  3249. @command{cat} shell utility.
  3250. @node delete
  3251. @subsection Removing Archive Members Using @option{--delete}
  3252. @UNREVISED
  3253. @cindex Deleting files from an archive
  3254. @cindex Removing files from an archive
  3255. @opindex delete
  3256. You can remove members from an archive by using the @option{--delete}
  3257. option. Specify the name of the archive with @option{--file}
  3258. (@option{-f}) and then specify the names of the members to be deleted;
  3259. if you list no member names, nothing will be deleted. The
  3260. @option{--verbose} option will cause @command{tar} to print the names
  3261. of the members as they are deleted. As with @option{--extract}, you
  3262. must give the exact member names when using @samp{tar --delete}.
  3263. @option{--delete} will remove all versions of the named file from the
  3264. archive. The @option{--delete} operation can run very slowly.
  3265. Unlike other operations, @option{--delete} has no short form.
  3266. @cindex Tapes, using @option{--delete} and
  3267. @cindex Deleting from tape archives
  3268. This operation will rewrite the archive. You can only use
  3269. @option{--delete} on an archive if the archive device allows you to
  3270. write to any point on the media, such as a disk; because of this, it
  3271. does not work on magnetic tapes. Do not try to delete an archive member
  3272. from a magnetic tape; the action will not succeed, and you will be
  3273. likely to scramble the archive and damage your tape. There is no safe
  3274. way (except by completely re-writing the archive) to delete files from
  3275. most kinds of magnetic tape. @xref{Media}.
  3276. To delete all versions of the file @file{blues} from the archive
  3277. @file{collection.tar} in the @file{practice} directory, make sure you
  3278. are in that directory, and then,
  3279. @smallexample
  3280. $ @kbd{tar --list --file=collection.tar}
  3281. blues
  3282. folk
  3283. jazz
  3284. rock
  3285. $ @kbd{tar --delete --file=collection.tar blues}
  3286. $ @kbd{tar --list --file=collection.tar}
  3287. folk
  3288. jazz
  3289. rock
  3290. $
  3291. @end smallexample
  3292. @FIXME{Check if the above listing is actually produced after running
  3293. all the examples on collection.tar.}
  3294. The @option{--delete} option has been reported to work properly when
  3295. @command{tar} acts as a filter from @code{stdin} to @code{stdout}.
  3296. @node compare
  3297. @subsection Comparing Archive Members with the File System
  3298. @cindex Verifying the currency of an archive
  3299. @UNREVISED
  3300. @opindex compare
  3301. The @option{--compare} (@option{-d}), or @option{--diff} operation compares
  3302. specified archive members against files with the same names, and then
  3303. reports differences in file size, mode, owner, modification date and
  3304. contents. You should @emph{only} specify archive member names, not file
  3305. names. If you do not name any members, then @command{tar} will compare the
  3306. entire archive. If a file is represented in the archive but does not
  3307. exist in the file system, @command{tar} reports a difference.
  3308. You have to specify the record size of the archive when modifying an
  3309. archive with a non-default record size.
  3310. @command{tar} ignores files in the file system that do not have
  3311. corresponding members in the archive.
  3312. The following example compares the archive members @file{rock},
  3313. @file{blues} and @file{funk} in the archive @file{bluesrock.tar} with
  3314. files of the same name in the file system. (Note that there is no file,
  3315. @file{funk}; @command{tar} will report an error message.)
  3316. @smallexample
  3317. $ @kbd{tar --compare --file=bluesrock.tar rock blues funk}
  3318. rock
  3319. blues
  3320. tar: funk not found in archive
  3321. @end smallexample
  3322. The spirit behind the @option{--compare} (@option{--diff},
  3323. @option{-d}) option is to check whether the archive represents the
  3324. current state of files on disk, more than validating the integrity of
  3325. the archive media. For this later goal, @xref{verify}.
  3326. @node quoting styles
  3327. @subsection Quoting Member Names
  3328. When displaying member names, @command{tar} takes care to avoid
  3329. ambiguities caused by certain characters. This is called @dfn{name
  3330. quoting}. The characters in question are:
  3331. @itemize @bullet
  3332. @item Non-printable control characters:
  3333. @multitable @columnfractions 0.20 0.10 0.60
  3334. @headitem Character @tab ASCII @tab Character name
  3335. @item \a @tab 7 @tab Audible bell
  3336. @item \b @tab 8 @tab Backspace
  3337. @item \f @tab 12 @tab Form feed
  3338. @item \n @tab 10 @tab New line
  3339. @item \r @tab 13 @tab Carriage return
  3340. @item \t @tab 9 @tab Horizontal tabulation
  3341. @item \v @tab 11 @tab Vertical tabulation
  3342. @end multitable
  3343. @item Space (ASCII 32)
  3344. @item Single and double quotes (@samp{'} and @samp{"})
  3345. @item Backslash (@samp{\})
  3346. @end itemize
  3347. The exact way @command{tar} uses to quote these characters depends on
  3348. the @dfn{quoting style}. The default quoting style, called
  3349. @dfn{escape} (see below), uses backslash notation to represent control
  3350. characters, space and backslash. Using this quoting style, control
  3351. characters are represented as listed in column @samp{Character} in the
  3352. above table, a space is printed as @samp{\ } and a backslash as @samp{\\}.
  3353. @GNUTAR{} offers seven distinct quoting styles, which can be selected
  3354. using @option{--quoting-style} option:
  3355. @table @option
  3356. @item --quoting-style=@var{style}
  3357. @opindex quoting-style
  3358. Sets quoting style. Valid values for @var{style} argument are:
  3359. literal, shell, shell-always, c, escape, locale, clocale.
  3360. @end table
  3361. These styles are described in detail below. To illustrate their
  3362. effect, we will use an imaginary tar archive @file{arch.tar}
  3363. containing the following members:
  3364. @smallexample
  3365. @group
  3366. # 1. Contains horizontal tabulation character.
  3367. a tab
  3368. # 2. Contains newline character
  3369. a
  3370. newline
  3371. # 3. Contains a space
  3372. a space
  3373. # 4. Contains double quotes
  3374. a"double"quote
  3375. # 5. Contains single quotes
  3376. a'single'quote
  3377. # 6. Contains a backslash character:
  3378. a\backslash
  3379. @end group
  3380. @end smallexample
  3381. Here is how usual @command{ls} command would have listed them, if they
  3382. had existed in the current working directory:
  3383. @smallexample
  3384. @group
  3385. $ @kbd{ls}
  3386. a\ttab
  3387. a\nnewline
  3388. a\ space
  3389. a"double"quote
  3390. a'single'quote
  3391. a\\backslash
  3392. @end group
  3393. @end smallexample
  3394. Quoting styles:
  3395. @table @samp
  3396. @item literal
  3397. No quoting, display each character as is:
  3398. @smallexample
  3399. @group
  3400. $ @kbd{tar tf arch.tar --quoting-style=literal}
  3401. ./
  3402. ./a space
  3403. ./a'single'quote
  3404. ./a"double"quote
  3405. ./a\backslash
  3406. ./a tab
  3407. ./a
  3408. newline
  3409. @end group
  3410. @end smallexample
  3411. @item shell
  3412. Display characters the same way Bourne shell does:
  3413. control characters, except @samp{\t} and @samp{\n}, are printed using
  3414. backslash escapes, @samp{\t} and @samp{\n} are printed as is, and a
  3415. single quote is printed as @samp{\'}. If a name contains any quoted
  3416. characters, it is enclosed in single quotes. In particular, if a name
  3417. contains single quotes, it is printed as several single-quoted strings:
  3418. @smallexample
  3419. @group
  3420. $ @kbd{tar tf arch.tar --quoting-style=shell}
  3421. ./
  3422. './a space'
  3423. './a'\''single'\''quote'
  3424. './a"double"quote'
  3425. './a\backslash'
  3426. './a tab'
  3427. './a
  3428. newline'
  3429. @end group
  3430. @end smallexample
  3431. @item shell-always
  3432. Same as @samp{shell}, but the names are always enclosed in single
  3433. quotes:
  3434. @smallexample
  3435. @group
  3436. $ @kbd{tar tf arch.tar --quoting-style=shell-always}
  3437. './'
  3438. './a space'
  3439. './a'\''single'\''quote'
  3440. './a"double"quote'
  3441. './a\backslash'
  3442. './a tab'
  3443. './a
  3444. newline'
  3445. @end group
  3446. @end smallexample
  3447. @item c
  3448. Use the notation of the C programming language. All names are
  3449. enclosed in double quotes. Control characters are quoted using
  3450. backslash notations, double quotes are represented as @samp{\"},
  3451. backslash characters are represented as @samp{\\}. Single quotes and
  3452. spaces are not quoted:
  3453. @smallexample
  3454. @group
  3455. $ @kbd{tar tf arch.tar --quoting-style=c}
  3456. "./"
  3457. "./a space"
  3458. "./a'single'quote"
  3459. "./a\"double\"quote"
  3460. "./a\\backslash"
  3461. "./a\ttab"
  3462. "./a\nnewline"
  3463. @end group
  3464. @end smallexample
  3465. @item escape
  3466. Control characters are printed using backslash notation, a space is
  3467. printed as @samp{\ } and a backslash as @samp{\\}. This is the
  3468. default quoting style, unless it was changed when configured the
  3469. package.
  3470. @smallexample
  3471. @group
  3472. $ @kbd{tar tf arch.tar --quoting-style=escape}
  3473. ./
  3474. ./a space
  3475. ./a'single'quote
  3476. ./a"double"quote
  3477. ./a\\backslash
  3478. ./a\ttab
  3479. ./a\nnewline
  3480. @end group
  3481. @end smallexample
  3482. @item locale
  3483. Control characters, single quote and backslash are printed using
  3484. backslash notation. All names are quoted using left and right
  3485. quotation marks, appropriate to the current locale. If it does not
  3486. define quotation marks, use @samp{`} as left and @samp{'} as right
  3487. quotation marks. Any occurrences of the right quotation mark in a
  3488. name are escaped with @samp{\}, for example:
  3489. For example:
  3490. @smallexample
  3491. @group
  3492. $ @kbd{tar tf arch.tar --quoting-style=locale}
  3493. `./'
  3494. `./a space'
  3495. `./a\'single\'quote'
  3496. `./a"double"quote'
  3497. `./a\\backslash'
  3498. `./a\ttab'
  3499. `./a\nnewline'
  3500. @end group
  3501. @end smallexample
  3502. @item clocale
  3503. Same as @samp{locale}, but @samp{"} is used for both left and right
  3504. quotation marks, if not provided by the currently selected locale:
  3505. @smallexample
  3506. @group
  3507. $ @kbd{tar tf arch.tar --quoting-style=clocale}
  3508. "./"
  3509. "./a space"
  3510. "./a'single'quote"
  3511. "./a\"double\"quote"
  3512. "./a\\backslash"
  3513. "./a\ttab"
  3514. "./a\nnewline"
  3515. @end group
  3516. @end smallexample
  3517. @end table
  3518. You can specify which characters should be quoted in addition to those
  3519. implied by the current quoting style:
  3520. @table @option
  3521. @item --quote-chars=@var{string}
  3522. Always quote characters from @var{string}, even if the selected
  3523. quoting style would not quote them.
  3524. @end table
  3525. For example, using @samp{escape} quoting (compare with the usual
  3526. escape listing above):
  3527. @smallexample
  3528. @group
  3529. $ @kbd{tar tf arch.tar --quoting-style=escape --quote-chars=' "'}
  3530. ./
  3531. ./a\ space
  3532. ./a'single'quote
  3533. ./a\"double\"quote
  3534. ./a\\backslash
  3535. ./a\ttab
  3536. ./a\nnewline
  3537. @end group
  3538. @end smallexample
  3539. To disable quoting of such additional characters, use the following
  3540. option:
  3541. @table @option
  3542. @item --no-quote-chars=@var{string}
  3543. Remove characters listed in @var{string} from the list of quoted
  3544. characters set by the previous @option{--quote-chars} option.
  3545. @end table
  3546. This option is particularly useful if you have added
  3547. @option{--quote-chars} to your @env{TAR_OPTIONS} (@pxref{TAR_OPTIONS})
  3548. and wish to disable it for the current invocation.
  3549. Note, that @option{--no-quote-chars} does @emph{not} disable those
  3550. characters that are quoted by default in the selected quoting style.
  3551. @node create options
  3552. @section Options Used by @option{--create}
  3553. @opindex create, additional options
  3554. The previous chapter described the basics of how to use
  3555. @option{--create} (@option{-c}) to create an archive from a set of files.
  3556. @xref{create}. This section described advanced options to be used with
  3557. @option{--create}.
  3558. @menu
  3559. * Ignore Failed Read::
  3560. @end menu
  3561. @node Ignore Failed Read
  3562. @subsection Ignore Fail Read
  3563. @table @option
  3564. @item --ignore-failed-read
  3565. Do not exit with nonzero on unreadable files or directories.
  3566. @end table
  3567. @node extract options
  3568. @section Options Used by @option{--extract}
  3569. @UNREVISED
  3570. @opindex extract, additional options
  3571. The previous chapter showed how to use @option{--extract} to extract
  3572. an archive into the file system. Various options cause @command{tar} to
  3573. extract more information than just file contents, such as the owner,
  3574. the permissions, the modification date, and so forth. This section
  3575. presents options to be used with @option{--extract} when certain special
  3576. considerations arise. You may review the information presented in
  3577. @ref{extract} for more basic information about the
  3578. @option{--extract} operation.
  3579. @menu
  3580. * Reading:: Options to Help Read Archives
  3581. * Writing:: Changing How @command{tar} Writes Files
  3582. * Scarce:: Coping with Scarce Resources
  3583. @end menu
  3584. @node Reading
  3585. @subsection Options to Help Read Archives
  3586. @cindex Options when reading archives
  3587. @UNREVISED
  3588. @cindex Reading incomplete records
  3589. @cindex Records, incomplete
  3590. @opindex read-full-records
  3591. Normally, @command{tar} will request data in full record increments from
  3592. an archive storage device. If the device cannot return a full record,
  3593. @command{tar} will report an error. However, some devices do not always
  3594. return full records, or do not require the last record of an archive to
  3595. be padded out to the next record boundary. To keep reading until you
  3596. obtain a full record, or to accept an incomplete record if it contains
  3597. an end-of-archive marker, specify the @option{--read-full-records} (@option{-B}) option
  3598. in conjunction with the @option{--extract} or @option{--list} operations.
  3599. @xref{Blocking}.
  3600. The @option{--read-full-records} (@option{-B}) option is turned on by default when
  3601. @command{tar} reads an archive from standard input, or from a remote
  3602. machine. This is because on BSD Unix systems, attempting to read a
  3603. pipe returns however much happens to be in the pipe, even if it is
  3604. less than was requested. If this option were not enabled, @command{tar}
  3605. would fail as soon as it read an incomplete record from the pipe.
  3606. If you're not sure of the blocking factor of an archive, you can
  3607. read the archive by specifying @option{--read-full-records} (@option{-B}) and
  3608. @option{--blocking-factor=@var{512-size}} (@option{-b
  3609. @var{512-size}}), using a blocking factor larger than what the archive
  3610. uses. This lets you avoid having to determine the blocking factor
  3611. of an archive. @xref{Blocking Factor}.
  3612. @menu
  3613. * read full records::
  3614. * Ignore Zeros::
  3615. @end menu
  3616. @node read full records
  3617. @unnumberedsubsubsec Reading Full Records
  3618. @FIXME{need sentence or so of intro here}
  3619. @table @option
  3620. @opindex read-full-records
  3621. @item --read-full-records
  3622. @item -B
  3623. Use in conjunction with @option{--extract} (@option{--get},
  3624. @option{-x}) to read an archive which contains incomplete records, or
  3625. one which has a blocking factor less than the one specified.
  3626. @end table
  3627. @node Ignore Zeros
  3628. @unnumberedsubsubsec Ignoring Blocks of Zeros
  3629. @cindex End-of-archive blocks, ignoring
  3630. @cindex Ignoring end-of-archive blocks
  3631. @opindex ignore-zeros
  3632. Normally, @command{tar} stops reading when it encounters a block of zeros
  3633. between file entries (which usually indicates the end of the archive).
  3634. @option{--ignore-zeros} (@option{-i}) allows @command{tar} to
  3635. completely read an archive which contains a block of zeros before the
  3636. end (i.e., a damaged archive, or one that was created by concatenating
  3637. several archives together).
  3638. The @option{--ignore-zeros} (@option{-i}) option is turned off by default because many
  3639. versions of @command{tar} write garbage after the end-of-archive entry,
  3640. since that part of the media is never supposed to be read. @GNUTAR{}
  3641. does not write after the end of an archive, but seeks to
  3642. maintain compatiblity among archiving utilities.
  3643. @table @option
  3644. @item --ignore-zeros
  3645. @itemx -i
  3646. To ignore blocks of zeros (i.e., end-of-archive entries) which may be
  3647. encountered while reading an archive. Use in conjunction with
  3648. @option{--extract} or @option{--list}.
  3649. @end table
  3650. @node Writing
  3651. @subsection Changing How @command{tar} Writes Files
  3652. @UNREVISED
  3653. @FIXME{Introductory paragraph}
  3654. @menu
  3655. * Dealing with Old Files::
  3656. * Overwrite Old Files::
  3657. * Keep Old Files::
  3658. * Keep Newer Files::
  3659. * Unlink First::
  3660. * Recursive Unlink::
  3661. * Data Modification Times::
  3662. * Setting Access Permissions::
  3663. * Directory Modification Times and Permissions::
  3664. * Writing to Standard Output::
  3665. * Writing to an External Program::
  3666. * remove files::
  3667. @end menu
  3668. @node Dealing with Old Files
  3669. @unnumberedsubsubsec Options Controlling the Overwriting of Existing Files
  3670. @opindex overwrite-dir, introduced
  3671. When extracting files, if @command{tar} discovers that the extracted
  3672. file already exists, it normally replaces the file by removing it before
  3673. extracting it, to prevent confusion in the presence of hard or symbolic
  3674. links. (If the existing file is a symbolic link, it is removed, not
  3675. followed.) However, if a directory cannot be removed because it is
  3676. nonempty, @command{tar} normally overwrites its metadata (ownership,
  3677. permission, etc.). The @option{--overwrite-dir} option enables this
  3678. default behavior. To be more cautious and preserve the metadata of
  3679. such a directory, use the @option{--no-overwrite-dir} option.
  3680. @cindex Overwriting old files, prevention
  3681. @opindex keep-old-files, introduced
  3682. To be even more cautious and prevent existing files from being replaced, use
  3683. the @option{--keep-old-files} (@option{-k}) option. It causes @command{tar} to refuse
  3684. to replace or update a file that already exists, i.e., a file with the
  3685. same name as an archive member prevents extraction of that archive
  3686. member. Instead, it reports an error.
  3687. @opindex overwrite, introduced
  3688. To be more aggressive about altering existing files, use the
  3689. @option{--overwrite} option. It causes @command{tar} to overwrite
  3690. existing files and to follow existing symbolic links when extracting.
  3691. @cindex Protecting old files
  3692. Some people argue that @GNUTAR{} should not hesitate
  3693. to overwrite files with other files when extracting. When extracting
  3694. a @command{tar} archive, they expect to see a faithful copy of the
  3695. state of the file system when the archive was created. It is debatable
  3696. that this would always be a proper behavior. For example, suppose one
  3697. has an archive in which @file{usr/local} is a link to
  3698. @file{usr/local2}. Since then, maybe the site removed the link and
  3699. renamed the whole hierarchy from @file{/usr/local2} to
  3700. @file{/usr/local}. Such things happen all the time. I guess it would
  3701. not be welcome at all that @GNUTAR{} removes the
  3702. whole hierarchy just to make room for the link to be reinstated
  3703. (unless it @emph{also} simultaneously restores the full
  3704. @file{/usr/local2}, of course!) @GNUTAR{} is indeed
  3705. able to remove a whole hierarchy to reestablish a symbolic link, for
  3706. example, but @emph{only if} @option{--recursive-unlink} is specified
  3707. to allow this behavior. In any case, single files are silently
  3708. removed.
  3709. @opindex unlink-first, introduced
  3710. Finally, the @option{--unlink-first} (@option{-U}) option can improve performance in
  3711. some cases by causing @command{tar} to remove files unconditionally
  3712. before extracting them.
  3713. @node Overwrite Old Files
  3714. @unnumberedsubsubsec Overwrite Old Files
  3715. @table @option
  3716. @opindex overwrite
  3717. @item --overwrite
  3718. Overwrite existing files and directory metadata when extracting files
  3719. from an archive.
  3720. This causes @command{tar} to write extracted files into the file system without
  3721. regard to the files already on the system; i.e., files with the same
  3722. names as archive members are overwritten when the archive is extracted.
  3723. It also causes @command{tar} to extract the ownership, permissions,
  3724. and time stamps onto any preexisting files or directories.
  3725. If the name of a corresponding file name is a symbolic link, the file
  3726. pointed to by the symbolic link will be overwritten instead of the
  3727. symbolic link itself (if this is possible). Moreover, special devices,
  3728. empty directories and even symbolic links are automatically removed if
  3729. they are in the way of extraction.
  3730. Be careful when using the @option{--overwrite} option, particularly when
  3731. combined with the @option{--absolute-names} (@option{-P}) option, as this combination
  3732. can change the contents, ownership or permissions of any file on your
  3733. system. Also, many systems do not take kindly to overwriting files that
  3734. are currently being executed.
  3735. @opindex overwrite-dir
  3736. @item --overwrite-dir
  3737. Overwrite the metadata of directories when extracting files from an
  3738. archive, but remove other files before extracting.
  3739. @end table
  3740. @node Keep Old Files
  3741. @unnumberedsubsubsec Keep Old Files
  3742. @table @option
  3743. @opindex keep-old-files
  3744. @item --keep-old-files
  3745. @itemx -k
  3746. Do not replace existing files from archive. The
  3747. @option{--keep-old-files} (@option{-k}) option prevents @command{tar}
  3748. from replacing existing files with files with the same name from the
  3749. archive. The @option{--keep-old-files} option is meaningless with
  3750. @option{--list} (@option{-t}). Prevents @command{tar} from replacing
  3751. files in the file system during extraction.
  3752. @end table
  3753. @node Keep Newer Files
  3754. @unnumberedsubsubsec Keep Newer Files
  3755. @table @option
  3756. @opindex keep-newer-files
  3757. @item --keep-newer-files
  3758. Do not replace existing files that are newer than their archive
  3759. copies. This option is meaningless with @option{--list} (@option{-t}).
  3760. @end table
  3761. @node Unlink First
  3762. @unnumberedsubsubsec Unlink First
  3763. @table @option
  3764. @opindex unlink-first
  3765. @item --unlink-first
  3766. @itemx -U
  3767. Remove files before extracting over them.
  3768. This can make @command{tar} run a bit faster if you know in advance
  3769. that the extracted files all need to be removed. Normally this option
  3770. slows @command{tar} down slightly, so it is disabled by default.
  3771. @end table
  3772. @node Recursive Unlink
  3773. @unnumberedsubsubsec Recursive Unlink
  3774. @table @option
  3775. @opindex recursive-unlink
  3776. @item --recursive-unlink
  3777. When this option is specified, try removing files and directory hierarchies
  3778. before extracting over them. @emph{This is a dangerous option!}
  3779. @end table
  3780. If you specify the @option{--recursive-unlink} option,
  3781. @command{tar} removes @emph{anything} that keeps you from extracting a file
  3782. as far as current permissions will allow it. This could include removal
  3783. of the contents of a full directory hierarchy.
  3784. @node Data Modification Times
  3785. @unnumberedsubsubsec Setting Data Modification Times
  3786. @cindex Data modification times of extracted files
  3787. @cindex Modification times of extracted files
  3788. Normally, @command{tar} sets the data modification times of extracted
  3789. files to the corresponding times recorded for the files in the archive, but
  3790. limits the permissions of extracted files by the current @code{umask}
  3791. setting.
  3792. To set the data modification times of extracted files to the time when
  3793. the files were extracted, use the @option{--touch} (@option{-m}) option in
  3794. conjunction with @option{--extract} (@option{--get}, @option{-x}).
  3795. @table @option
  3796. @opindex touch
  3797. @item --touch
  3798. @itemx -m
  3799. Sets the data modification time of extracted archive members to the time
  3800. they were extracted, not the time recorded for them in the archive.
  3801. Use in conjunction with @option{--extract} (@option{--get}, @option{-x}).
  3802. @end table
  3803. @node Setting Access Permissions
  3804. @unnumberedsubsubsec Setting Access Permissions
  3805. @cindex Permissions of extracted files
  3806. @cindex Modes of extracted files
  3807. To set the modes (access permissions) of extracted files to those
  3808. recorded for those files in the archive, use @option{--same-permissions}
  3809. in conjunction with the @option{--extract} (@option{--get},
  3810. @option{-x}) operation.
  3811. @table @option
  3812. @opindex preserve-permission
  3813. @opindex same-permission
  3814. @item --preserve-permission
  3815. @itemx --same-permission
  3816. @c @itemx --ignore-umask
  3817. @itemx -p
  3818. Set modes of extracted archive members to those recorded in the
  3819. archive, instead of current umask settings. Use in conjunction with
  3820. @option{--extract} (@option{--get}, @option{-x}).
  3821. @end table
  3822. @node Directory Modification Times and Permissions
  3823. @unnumberedsubsubsec Directory Modification Times and Permissions
  3824. After sucessfully extracting a file member, @GNUTAR{} normally
  3825. restores its permissions and modification times, as described in the
  3826. previous sections. This cannot be done for directories, because
  3827. after extracting a directory @command{tar} will almost certainly
  3828. extract files into that directory and this will cause the directory
  3829. modification time to be updated. Moreover, restoring that directory
  3830. permissions may not permit file creation within it. Thus, restoring
  3831. directory permissions and modification times must be delayed at least
  3832. until all files have been extracted into that directory. @GNUTAR{}
  3833. restores directories using the following approach.
  3834. The extracted directories are created with the mode specified in the
  3835. archive, as modified by the umask of the user, which gives sufficient
  3836. permissions to allow file creation. The meta-information about the
  3837. directory is recorded in the temporary list of directories. When
  3838. preparing to extract next archive member, @GNUTAR{} checks if the
  3839. directory prefix of this file contains the remembered directory. If
  3840. it does not, the program assumes that all files have been extracted
  3841. into that directory, restores its modification time and permissions
  3842. and removes its entry from the internal list. This approach allows
  3843. to correctly restore directory meta-information in the majority of
  3844. cases, while keeping memory requirements sufficiently small. It is
  3845. based on the fact, that most @command{tar} archives use the predefined
  3846. order of members: first the directory, then all the files and
  3847. subdirectories in that directory.
  3848. However, this is not always true. The most important exception are
  3849. incremental archives (@pxref{Incremental Dumps}). The member order in
  3850. an incremental archive is reversed: first all directory members are
  3851. stored, followed by other (non-directory) members. So, when extracting
  3852. from incremental archives, @GNUTAR{} alters the above procedure. It
  3853. remebers all restored directories, and restores their meta-data
  3854. only after the entire archive has been processed. Notice, that you do
  3855. not need to specity any special options for that, as @GNUTAR{}
  3856. automatically detects archives in incremental format.
  3857. There may be cases, when such processing is required for normal archives
  3858. too. Consider the following example:
  3859. @smallexample
  3860. @group
  3861. $ @kbd{tar --no-recursion -cvf archive \
  3862. foo foo/file1 bar bar/file foo/file2}
  3863. foo/
  3864. foo/file1
  3865. bar/
  3866. bar/file
  3867. foo/file2
  3868. @end group
  3869. @end smallexample
  3870. During the normal operation, after encountering @file{bar}
  3871. @GNUTAR{} will assume that all files from the directory @file{foo}
  3872. were already extracted and will therefore restore its timestamp and
  3873. permission bits. However, after extracting @file{foo/file2} the
  3874. directory timestamp will be offset again.
  3875. To correctly restore directory meta-information in such cases, use
  3876. @option{delay-directory-restore} command line option:
  3877. @table @option
  3878. @opindex delay-directory-restore
  3879. @item --delay-directory-restore
  3880. Delays restoring of the modification times and permissions of extracted
  3881. directories until the end of extraction. This way, correct
  3882. meta-information is restored even if the archive has unusual member
  3883. ordering.
  3884. @opindex no-delay-directory-restore
  3885. @item --no-delay-directory-restore
  3886. Cancel the effect of the previous @option{--delay-directory-restore}.
  3887. Use this option if you have used @option{--delay-directory-restore} in
  3888. @env{TAR_OPTIONS} variable (@pxref{TAR_OPTIONS}) and wish to
  3889. temporarily disable it.
  3890. @end table
  3891. @node Writing to Standard Output
  3892. @unnumberedsubsubsec Writing to Standard Output
  3893. @cindex Writing extracted files to standard output
  3894. @cindex Standard output, writing extracted files to
  3895. To write the extracted files to the standard output, instead of
  3896. creating the files on the file system, use @option{--to-stdout} (@option{-O}) in
  3897. conjunction with @option{--extract} (@option{--get}, @option{-x}). This option is useful if you are
  3898. extracting files to send them through a pipe, and do not need to
  3899. preserve them in the file system. If you extract multiple members,
  3900. they appear on standard output concatenated, in the order they are
  3901. found in the archive.
  3902. @table @option
  3903. @opindex to-stdout
  3904. @item --to-stdout
  3905. @itemx -O
  3906. Writes files to the standard output. Use only in conjunction with
  3907. @option{--extract} (@option{--get}, @option{-x}). When this option is
  3908. used, instead of creating the files specified, @command{tar} writes
  3909. the contents of the files extracted to its standard output. This may
  3910. be useful if you are only extracting the files in order to send them
  3911. through a pipe. This option is meaningless with @option{--list}
  3912. (@option{-t}).
  3913. @end table
  3914. This can be useful, for example, if you have a tar archive containing
  3915. a big file and don't want to store the file on disk before processing
  3916. it. You can use a command like this:
  3917. @smallexample
  3918. tar -xOzf foo.tgz bigfile | process
  3919. @end smallexample
  3920. or even like this if you want to process the concatenation of the files:
  3921. @smallexample
  3922. tar -xOzf foo.tgz bigfile1 bigfile2 | process
  3923. @end smallexample
  3924. Hovewer, @option{--to-command} may be more convenient for use with
  3925. multiple files. See the next section.
  3926. @node Writing to an External Program
  3927. @unnumberedsubsubsec Writing to an External Program
  3928. You can instruct @command{tar} to send the contents of each extracted
  3929. file to the standard input of an external program:
  3930. @table @option
  3931. @opindex to-command
  3932. @item --to-command=@var{command}
  3933. Extract files and pipe their contents to the standard input of
  3934. @var{command}. When this option is used, instead of creating the
  3935. files specified, @command{tar} invokes @var{command} and pipes the
  3936. contents of the files to its standard output. @var{Command} may
  3937. contain command line arguments. The program is executed via
  3938. @code{sh -c}. Notice, that @var{command} is executed once for each regular file
  3939. extracted. Non-regular files (directories, etc.) are ignored when this
  3940. option is used.
  3941. @end table
  3942. The command can obtain the information about the file it processes
  3943. from the following environment variables:
  3944. @table @var
  3945. @vrindex TAR_FILETYPE, to-command environment
  3946. @item TAR_FILETYPE
  3947. Type of the file. It is a single letter with the following meaning:
  3948. @multitable @columnfractions 0.10 0.90
  3949. @item f @tab Regular file
  3950. @item d @tab Directory
  3951. @item l @tab Symbolic link
  3952. @item h @tab Hard link
  3953. @item b @tab Block device
  3954. @item c @tab Character device
  3955. @end multitable
  3956. Currently only regular files are supported.
  3957. @vrindex TAR_MODE, to-command environment
  3958. @item TAR_MODE
  3959. File mode, an octal number.
  3960. @vrindex TAR_FILENAME, to-command environment
  3961. @item TAR_FILENAME
  3962. The name of the file.
  3963. @vrindex TAR_REALNAME, to-command environment
  3964. @item TAR_REALNAME
  3965. Name of the file as stored in the archive.
  3966. @vrindex TAR_UNAME, to-command environment
  3967. @item TAR_UNAME
  3968. Name of the file owner.
  3969. @vrindex TAR_GNAME, to-command environment
  3970. @item TAR_GNAME
  3971. Name of the file owner group.
  3972. @vrindex TAR_ATIME, to-command environment
  3973. @item TAR_ATIME
  3974. Time of last access. It is a decimal number, representing seconds
  3975. since the epoch. If the archive provides times with nanosecond
  3976. precision, the nanoseconds are appended to the timestamp after a
  3977. decimal point.
  3978. @vrindex TAR_MTIME, to-command environment
  3979. @item TAR_MTIME
  3980. Time of last modification.
  3981. @vrindex TAR_CTIME, to-command environment
  3982. @item TAR_CTIME
  3983. Time of last status change.
  3984. @vrindex TAR_SIZE, to-command environment
  3985. @item TAR_SIZE
  3986. Size of the file.
  3987. @vrindex TAR_UID, to-command environment
  3988. @item TAR_UID
  3989. UID of the file owner.
  3990. @vrindex TAR_GID, to-command environment
  3991. @item TAR_GID
  3992. GID of the file owner.
  3993. @end table
  3994. In addition to these variables, @env{TAR_VERSION} contains the
  3995. @GNUTAR{} version number.
  3996. If @var{command} exits with a non-0 status, @command{tar} will print
  3997. an error message similar to the following:
  3998. @smallexample
  3999. tar: 2345: Child returned status 1
  4000. @end smallexample
  4001. Here, @samp{2345} is the PID of the finished process.
  4002. If this behavior is not wanted, use @option{--ignore-command-error}:
  4003. @table @option
  4004. @opindex ignore-command-error
  4005. @item --ignore-command-error
  4006. Ignore exit codes of subprocesses. Notice that if the program
  4007. exits on signal or otherwise terminates abnormally, the error message
  4008. will be printed even if this option is used.
  4009. @opindex no-ignore-command-error
  4010. @item --no-ignore-command-error
  4011. Cancel the effect of any previous @option{--ignore-command-error}
  4012. option. This option is useful if you have set
  4013. @option{--ignore-command-error} in @env{TAR_OPTIONS}
  4014. (@pxref{TAR_OPTIONS}) and wish to temporarily cancel it.
  4015. @end table
  4016. @node remove files
  4017. @unnumberedsubsubsec Removing Files
  4018. @FIXME{The section is too terse. Something more to add? An example,
  4019. maybe?}
  4020. @table @option
  4021. @opindex remove-files
  4022. @item --remove-files
  4023. Remove files after adding them to the archive.
  4024. @end table
  4025. @node Scarce
  4026. @subsection Coping with Scarce Resources
  4027. @UNREVISED
  4028. @cindex Small memory
  4029. @cindex Running out of space
  4030. @menu
  4031. * Starting File::
  4032. * Same Order::
  4033. @end menu
  4034. @node Starting File
  4035. @unnumberedsubsubsec Starting File
  4036. @table @option
  4037. @opindex starting-file
  4038. @item --starting-file=@var{name}
  4039. @itemx -K @var{name}
  4040. Starts an operation in the middle of an archive. Use in conjunction
  4041. with @option{--extract} (@option{--get}, @option{-x}) or @option{--list} (@option{-t}).
  4042. @end table
  4043. @cindex Middle of the archive, starting in the
  4044. If a previous attempt to extract files failed due to lack of disk
  4045. space, you can use @option{--starting-file=@var{name}} (@option{-K
  4046. @var{name}}) to start extracting only after member @var{name} of the
  4047. archive. This assumes, of course, that there is now free space, or
  4048. that you are now extracting into a different file system. (You could
  4049. also choose to suspend @command{tar}, remove unnecessary files from
  4050. the file system, and then restart the same @command{tar} operation.
  4051. In this case, @option{--starting-file} is not necessary.
  4052. @xref{Incremental Dumps}, @xref{interactive}, and @ref{exclude}.)
  4053. @node Same Order
  4054. @unnumberedsubsubsec Same Order
  4055. @table @option
  4056. @cindex Large lists of file names on small machines
  4057. @opindex same-order
  4058. @opindex preserve-order
  4059. @item --same-order
  4060. @itemx --preserve-order
  4061. @itemx -s
  4062. To process large lists of file names on machines with small amounts of
  4063. memory. Use in conjunction with @option{--compare} (@option{--diff},
  4064. @option{-d}), @option{--list} (@option{-t}) or @option{--extract}
  4065. (@option{--get}, @option{-x}).
  4066. @end table
  4067. The @option{--same-order} (@option{--preserve-order}, @option{-s}) option tells @command{tar} that the list of file
  4068. names to be listed or extracted is sorted in the same order as the
  4069. files in the archive. This allows a large list of names to be used,
  4070. even on a small machine that would not otherwise be able to hold all
  4071. the names in memory at the same time. Such a sorted list can easily be
  4072. created by running @samp{tar -t} on the archive and editing its output.
  4073. This option is probably never needed on modern computer systems.
  4074. @node backup
  4075. @section Backup options
  4076. @cindex backup options
  4077. @GNUTAR{} offers options for making backups of files
  4078. before writing new versions. These options control the details of
  4079. these backups. They may apply to the archive itself before it is
  4080. created or rewritten, as well as individual extracted members. Other
  4081. @acronym{GNU} programs (@command{cp}, @command{install}, @command{ln},
  4082. and @command{mv}, for example) offer similar options.
  4083. Backup options may prove unexpectedly useful when extracting archives
  4084. containing many members having identical name, or when extracting archives
  4085. on systems having file name limitations, making different members appear
  4086. has having similar names through the side-effect of name truncation.
  4087. (This is true only if we have a good scheme for truncated backup names,
  4088. which I'm not sure at all: I suspect work is needed in this area.)
  4089. When any existing file is backed up before being overwritten by extraction,
  4090. then clashing files are automatically be renamed to be unique, and the
  4091. true name is kept for only the last file of a series of clashing files.
  4092. By using verbose mode, users may track exactly what happens.
  4093. At the detail level, some decisions are still experimental, and may
  4094. change in the future, we are waiting comments from our users. So, please
  4095. do not learn to depend blindly on the details of the backup features.
  4096. For example, currently, directories themselves are never renamed through
  4097. using these options, so, extracting a file over a directory still has
  4098. good chances to fail. Also, backup options apply to created archives,
  4099. not only to extracted members. For created archives, backups will not
  4100. be attempted when the archive is a block or character device, or when it
  4101. refers to a remote file.
  4102. For the sake of simplicity and efficiency, backups are made by renaming old
  4103. files prior to creation or extraction, and not by copying. The original
  4104. name is restored if the file creation fails. If a failure occurs after a
  4105. partial extraction of a file, both the backup and the partially extracted
  4106. file are kept.
  4107. @table @samp
  4108. @item --backup[=@var{method}]
  4109. @opindex backup
  4110. @vindex VERSION_CONTROL
  4111. @cindex backups
  4112. Back up files that are about to be overwritten or removed.
  4113. Without this option, the original versions are destroyed.
  4114. Use @var{method} to determine the type of backups made.
  4115. If @var{method} is not specified, use the value of the @env{VERSION_CONTROL}
  4116. environment variable. And if @env{VERSION_CONTROL} is not set,
  4117. use the @samp{existing} method.
  4118. @vindex version-control @r{Emacs variable}
  4119. This option corresponds to the Emacs variable @samp{version-control};
  4120. the same values for @var{method} are accepted as in Emacs. This option
  4121. also allows more descriptive names. The valid @var{method}s are:
  4122. @table @samp
  4123. @item t
  4124. @itemx numbered
  4125. @cindex numbered @r{backup method}
  4126. Always make numbered backups.
  4127. @item nil
  4128. @itemx existing
  4129. @cindex existing @r{backup method}
  4130. Make numbered backups of files that already have them, simple backups
  4131. of the others.
  4132. @item never
  4133. @itemx simple
  4134. @cindex simple @r{backup method}
  4135. Always make simple backups.
  4136. @end table
  4137. @item --suffix=@var{suffix}
  4138. @opindex suffix
  4139. @cindex backup suffix
  4140. @vindex SIMPLE_BACKUP_SUFFIX
  4141. Append @var{suffix} to each backup file made with @option{--backup}. If this
  4142. option is not specified, the value of the @env{SIMPLE_BACKUP_SUFFIX}
  4143. environment variable is used. And if @env{SIMPLE_BACKUP_SUFFIX} is not
  4144. set, the default is @samp{~}, just as in Emacs.
  4145. @end table
  4146. Some people express the desire to @emph{always} use the @option{--backup}
  4147. option, by defining some kind of alias or script. This is not as easy
  4148. as one may think, due to the fact that old style options should appear first
  4149. and consume arguments a bit unpredictably for an alias or script. But,
  4150. if you are ready to give up using old style options, you may resort to
  4151. using something like (a Bourne shell function here):
  4152. @smallexample
  4153. tar () @{ /usr/local/bin/tar --backup $*; @}
  4154. @end smallexample
  4155. @node Applications
  4156. @section Notable @command{tar} Usages
  4157. @UNREVISED
  4158. @FIXME{Using Unix file linking capability to recreate directory
  4159. structures---linking files into one subdirectory and then
  4160. @command{tar}ring that directory.}
  4161. @FIXME{Nice hairy example using absolute-names, newer, etc.}
  4162. @findex uuencode
  4163. You can easily use archive files to transport a group of files from
  4164. one system to another: put all relevant files into an archive on one
  4165. computer system, transfer the archive to another system, and extract
  4166. the contents there. The basic transfer medium might be magnetic tape,
  4167. Internet FTP, or even electronic mail (though you must encode the
  4168. archive with @command{uuencode} in order to transport it properly by
  4169. mail). Both machines do not have to use the same operating system, as
  4170. long as they both support the @command{tar} program.
  4171. For example, here is how you might copy a directory's contents from
  4172. one disk to another, while preserving the dates, modes, owners and
  4173. link-structure of all the files therein. In this case, the transfer
  4174. medium is a @dfn{pipe}, which is one a Unix redirection mechanism:
  4175. @smallexample
  4176. $ @kbd{(cd sourcedir; tar -cf - .) | (cd targetdir; tar -xf -)}
  4177. @end smallexample
  4178. @noindent
  4179. You can avoid subshells by using @option{-C} option:
  4180. @smallexample
  4181. $ @kbd{tar -C sourcedir -cf - . | tar -C targetdir -xf -}
  4182. @end smallexample
  4183. @noindent
  4184. The command also works using short option forms:
  4185. @smallexample
  4186. $ @kbd{(cd sourcedir; tar --create --file=- . ) \
  4187. | (cd targetdir; tar --extract --file=-)}
  4188. # Or:
  4189. $ @kbd{tar --directory sourcedir --create --file=- . ) \
  4190. | tar --directory targetdir --extract --file=-}
  4191. @end smallexample
  4192. @noindent
  4193. This is one of the easiest methods to transfer a @command{tar} archive.
  4194. @node looking ahead
  4195. @section Looking Ahead: The Rest of this Manual
  4196. You have now seen how to use all eight of the operations available to
  4197. @command{tar}, and a number of the possible options. The next chapter
  4198. explains how to choose and change file and archive names, how to use
  4199. files to store names of other files which you can then call as
  4200. arguments to @command{tar} (this can help you save time if you expect to
  4201. archive the same list of files a number of times), and so forth.
  4202. @FIXME{in case it's not obvious, i'm making this up in some sense
  4203. based on my limited memory of what the next chapter *really* does. i
  4204. just wanted to flesh out this final section a little bit so i'd
  4205. remember to stick it in here. :-)}
  4206. If there are too many files to conveniently list on the command line,
  4207. you can list the names in a file, and @command{tar} will read that file.
  4208. @xref{files}.
  4209. There are various ways of causing @command{tar} to skip over some files,
  4210. and not archive them. @xref{Choosing}.
  4211. @node Backups
  4212. @chapter Performing Backups and Restoring Files
  4213. @UNREVISED
  4214. @GNUTAR{} is distributed along with the scripts
  4215. which the Free Software Foundation uses for performing backups. There
  4216. is no corresponding scripts available yet for doing restoration of
  4217. files. Even if there is a good chance those scripts may be satisfying
  4218. to you, they are not the only scripts or methods available for doing
  4219. backups and restore. You may well create your own, or use more
  4220. sophisticated packages dedicated to that purpose.
  4221. Some users are enthusiastic about @code{Amanda} (The Advanced Maryland
  4222. Automatic Network Disk Archiver), a backup system developed by James
  4223. da Silva @file{jds@@cs.umd.edu} and available on many Unix systems.
  4224. This is free software, and it is available at these places:
  4225. @smallexample
  4226. http://www.cs.umd.edu/projects/amanda/amanda.html
  4227. ftp://ftp.cs.umd.edu/pub/amanda
  4228. @end smallexample
  4229. @FIXME{
  4230. Here is a possible plan for a future documentation about the backuping
  4231. scripts which are provided within the @GNUTAR{}
  4232. distribution.
  4233. @itemize @bullet
  4234. @item dumps
  4235. @itemize @minus
  4236. @item what are dumps
  4237. @item different levels of dumps
  4238. @itemize +
  4239. @item full dump = dump everything
  4240. @item level 1, level 2 dumps etc
  4241. A level @var{n} dump dumps everything changed since the last level
  4242. @var{n}-1 dump (?)
  4243. @end itemize
  4244. @item how to use scripts for dumps (ie, the concept)
  4245. @itemize +
  4246. @item scripts to run after editing backup specs (details)
  4247. @end itemize
  4248. @item Backup Specs, what is it.
  4249. @itemize +
  4250. @item how to customize
  4251. @item actual text of script [/sp/dump/backup-specs]
  4252. @end itemize
  4253. @item Problems
  4254. @itemize +
  4255. @item rsh doesn't work
  4256. @item rtape isn't installed
  4257. @item (others?)
  4258. @end itemize
  4259. @item the @option{--incremental} option of tar
  4260. @item tapes
  4261. @itemize +
  4262. @item write protection
  4263. @item types of media, different sizes and types, useful for different things
  4264. @item files and tape marks
  4265. one tape mark between files, two at end.
  4266. @item positioning the tape
  4267. MT writes two at end of write,
  4268. backspaces over one when writing again.
  4269. @end itemize
  4270. @end itemize
  4271. @end itemize
  4272. }
  4273. This chapter documents both the provided shell scripts and @command{tar}
  4274. options which are more specific to usage as a backup tool.
  4275. To @dfn{back up} a file system means to create archives that contain
  4276. all the files in that file system. Those archives can then be used to
  4277. restore any or all of those files (for instance if a disk crashes or a
  4278. file is accidentally deleted). File system @dfn{backups} are also
  4279. called @dfn{dumps}.
  4280. @menu
  4281. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  4282. * Incremental Dumps:: Using @command{tar} to Perform Incremental Dumps
  4283. * Backup Levels:: Levels of Backups
  4284. * Backup Parameters:: Setting Parameters for Backups and Restoration
  4285. * Scripted Backups:: Using the Backup Scripts
  4286. * Scripted Restoration:: Using the Restore Script
  4287. @end menu
  4288. @node Full Dumps
  4289. @section Using @command{tar} to Perform Full Dumps
  4290. @UNREVISED
  4291. @cindex full dumps
  4292. @cindex dumps, full
  4293. @cindex corrupted archives
  4294. Full dumps should only be made when no other people or programs
  4295. are modifying files in the file system. If files are modified while
  4296. @command{tar} is making the backup, they may not be stored properly in
  4297. the archive, in which case you won't be able to restore them if you
  4298. have to. (Files not being modified are written with no trouble, and do
  4299. not corrupt the entire archive.)
  4300. You will want to use the @option{--label=@var{archive-label}}
  4301. (@option{-V @var{archive-label}}) option to give the archive a
  4302. volume label, so you can tell what this archive is even if the label
  4303. falls off the tape, or anything like that.
  4304. Unless the file system you are dumping is guaranteed to fit on
  4305. one volume, you will need to use the @option{--multi-volume} (@option{-M}) option.
  4306. Make sure you have enough tapes on hand to complete the backup.
  4307. If you want to dump each file system separately you will need to use
  4308. the @option{--one-file-system} option to prevent
  4309. @command{tar} from crossing file system boundaries when storing
  4310. (sub)directories.
  4311. The @option{--incremental} (@option{-G}) (@pxref{Incremental Dumps})
  4312. option is not needed, since this is a complete copy of everything in
  4313. the file system, and a full restore from this backup would only be
  4314. done onto a completely
  4315. empty disk.
  4316. Unless you are in a hurry, and trust the @command{tar} program (and your
  4317. tapes), it is a good idea to use the @option{--verify} (@option{-W})
  4318. option, to make sure your files really made it onto the dump properly.
  4319. This will also detect cases where the file was modified while (or just
  4320. after) it was being archived. Not all media (notably cartridge tapes)
  4321. are capable of being verified, unfortunately.
  4322. @node Incremental Dumps
  4323. @section Using @command{tar} to Perform Incremental Dumps
  4324. @dfn{Incremental backup} is a special form of @GNUTAR{} archive that
  4325. stores additional metadata so that exact state of the file system
  4326. can be restored when extracting the archive.
  4327. @GNUTAR{} currently offers two options for handling incremental
  4328. backups: @option{--listed-incremental=@var{snapshot-file}} (@option{-g
  4329. @var{snapshot-file}}) and @option{--incremental} (@option{-G}).
  4330. @opindex listed-incremental
  4331. The option @option{--listed-incremental} instructs tar to operate on
  4332. an incremental archive with additional metadata stored in a standalone
  4333. file, called a @dfn{snapshot file}. The purpose of this file is to help
  4334. determine which files have been changed, added or deleted since the
  4335. last backup, so that the next incremental backup will contain only
  4336. modified files. The name of the snapshot file is given as an argument
  4337. to the option:
  4338. @table @option
  4339. @item --listed-incremental=@var{file}
  4340. @itemx -g @var{file}
  4341. Handle incremental backups with snapshot data in @var{file}.
  4342. @end table
  4343. To create an incremental backup, you would use
  4344. @option{--listed-incremental} together with @option{--create}
  4345. (@pxref{create}). For example:
  4346. @smallexample
  4347. $ @kbd{tar --create \
  4348. --file=archive.1.tar \
  4349. --listed-incremental=/var/log/usr.snar \
  4350. /usr}
  4351. @end smallexample
  4352. This will create in @file{archive.1.tar} an incremental backup of
  4353. the @file{/usr} file system, storing additional metadata in the file
  4354. @file{/var/log/usr.snar}. If this file does not exist, it will be
  4355. created. The created archive will then be a @dfn{level 0 backup};
  4356. please see the next section for more on backup levels.
  4357. Otherwise, if the file @file{/var/log/usr.snar} exists, it
  4358. determines which files are modified. In this case only these files will be
  4359. stored in the archive. Suppose, for example, that after running the
  4360. above command, you delete file @file{/usr/doc/old} and create
  4361. directory @file{/usr/local/db} with the following contents:
  4362. @smallexample
  4363. $ @kbd{ls /usr/local/db}
  4364. /usr/local/db/data
  4365. /usr/local/db/index
  4366. @end smallexample
  4367. Some time later you create another incremental backup. You will
  4368. then see:
  4369. @smallexample
  4370. $ @kbd{tar --create \
  4371. --file=archive.2.tar \
  4372. --listed-incremental=/var/log/usr.snar \
  4373. /usr}
  4374. tar: usr/local/db: Directory is new
  4375. usr/local/db/
  4376. usr/local/db/data
  4377. usr/local/db/index
  4378. @end smallexample
  4379. @noindent
  4380. The created archive @file{archive.2.tar} will contain only these
  4381. three members. This archive is called a @dfn{level 1 backup}. Notice
  4382. that @file{/var/log/usr.snar} will be updated with the new data, so if
  4383. you plan to create more @samp{level 1} backups, it is necessary to
  4384. create a working copy of the snapshot file before running
  4385. @command{tar}. The above example will then be modified as follows:
  4386. @smallexample
  4387. $ @kbd{cp /var/log/usr.snar /var/log/usr.snar-1}
  4388. $ @kbd{tar --create \
  4389. --file=archive.2.tar \
  4390. --listed-incremental=/var/log/usr.snar-1 \
  4391. /usr}
  4392. @end smallexample
  4393. Incremental dumps depend crucially on time stamps, so the results are
  4394. unreliable if you modify a file's time stamps during dumping (e.g.,
  4395. with the @option{--atime-preserve=replace} option), or if you set the clock
  4396. backwards.
  4397. Metadata stored in snapshot files include device numbers, which,
  4398. obviously is supposed to be a non-volatile value. However, it turns
  4399. out that NFS devices have undependable values when an automounter
  4400. gets in the picture. This can lead to a great deal of spurious
  4401. redumping in incremental dumps, so it is somewhat useless to compare
  4402. two NFS devices numbers over time. The solution implemented currently
  4403. is to considers all NFS devices as being equal when it comes to
  4404. comparing directories; this is fairly gross, but there does not seem
  4405. to be a better way to go.
  4406. Note that incremental archives use @command{tar} extensions and may
  4407. not be readable by non-@acronym{GNU} versions of the @command{tar} program.
  4408. @opindex listed-incremental, using with @option{--extract}
  4409. @opindex extract, using with @option{--listed-incremental}
  4410. To extract from the incremental dumps, use
  4411. @option{--listed-incremental} together with @option{--extract}
  4412. option (@pxref{extracting files}). In this case, @command{tar} does
  4413. not need to access snapshot file, since all the data necessary for
  4414. extraction are stored in the archive itself. So, when extracting, you
  4415. can give whatever argument to @option{--listed-incremental}, the usual
  4416. practice is to use @option{--listed-incremental=/dev/null}.
  4417. Alternatively, you can use @option{--incremental}, which needs no
  4418. arguments. In general, @option{--incremental} (@option{-G}) can be
  4419. used as a shortcut for @option{--listed-incremental} when listing or
  4420. extracting incremental backups (for more information, regarding this
  4421. option, @pxref{incremental-op}).
  4422. When extracting from the incremental backup @GNUTAR{} attempts to
  4423. restore the exact state the file system had when the archive was
  4424. created. In particular, it will @emph{delete} those files in the file
  4425. system that did not exist in their directories when the archive was
  4426. created. If you have created several levels of incremental files,
  4427. then in order to restore the exact contents the file system had when
  4428. the last level was created, you will need to restore from all backups
  4429. in turn. Continuing our example, to restore the state of @file{/usr}
  4430. file system, one would do@footnote{Notice, that since both archives
  4431. were created withouth @option{-P} option (@pxref{absolute}), these
  4432. commands should be run from the root file system.}:
  4433. @smallexample
  4434. $ @kbd{tar --extract \
  4435. --listed-incremental=/dev/null \
  4436. --file archive.1.tar}
  4437. $ @kbd{tar --extract \
  4438. --listed-incremental=/dev/null \
  4439. --file archive.2.tar}
  4440. @end smallexample
  4441. To list the contents of an incremental archive, use @option{--list}
  4442. (@pxref{list}), as usual. To obtain more information about the
  4443. archive, use @option{--listed-incremental} or @option{--incremental}
  4444. combined with two @option{--verbose} options@footnote{Two
  4445. @option{--verbose} options were selected to avoid breaking usual
  4446. verbose listing output (@option{--list --verbose}) when using in
  4447. scripts.
  4448. @opindex incremental, using with @option{--list}
  4449. @opindex listed-incremental, using with @option{--list}
  4450. @opindex list, using with @option{--incremental}
  4451. @opindex list, using with @option{--listed-incremental}
  4452. Versions of @GNUTAR{} up to 1.15.1 used to dump verbatim binary
  4453. contents of the DUMPDIR header (with terminating nulls) when
  4454. @option{--incremental} or @option{--listed-incremental} option was
  4455. given, no matter what the verbosity level. This behavior, and,
  4456. especially, the binary output it produced were considered incovenient
  4457. and were changed in version 1.16}:
  4458. @smallexample
  4459. @kbd{tar --list --incremental --verbose --verbose archive.tar}
  4460. @end smallexample
  4461. This command will print, for each directory in the archive, the list
  4462. of files in that directory at the time the archive was created. This
  4463. information is put out in a format which is both human-readable and
  4464. unambiguous for a program: each file name is printed as
  4465. @smallexample
  4466. @var{x} @var{file}
  4467. @end smallexample
  4468. @noindent
  4469. where @var{x} is a letter describing the status of the file: @samp{Y}
  4470. if the file is present in the archive, @samp{N} if the file is not
  4471. included in the archive, or a @samp{D} if the file is a directory (and
  4472. is included in the archive).@FIXME-xref{dumpdir format}. Each such
  4473. line is terminated by a newline character. The last line is followed
  4474. by an additional newline to indicate the end of the data.
  4475. @anchor{incremental-op}The option @option{--incremental} (@option{-G})
  4476. gives the same behavior as @option{--listed-incremental} when used
  4477. with @option{--list} and @option{--extract} options. When used with
  4478. @option{--create} option, it creates an incremental archive without
  4479. creating snapshot file. Thus, it is impossible to create several
  4480. levels of incremental backups with @option{--incremental} option.
  4481. @node Backup Levels
  4482. @section Levels of Backups
  4483. An archive containing all the files in the file system is called a
  4484. @dfn{full backup} or @dfn{full dump}. You could insure your data by
  4485. creating a full dump every day. This strategy, however, would waste a
  4486. substantial amount of archive media and user time, as unchanged files
  4487. are daily re-archived.
  4488. It is more efficient to do a full dump only occasionally. To back up
  4489. files between full dumps, you can use @dfn{incremental dumps}. A @dfn{level
  4490. one} dump archives all the files that have changed since the last full
  4491. dump.
  4492. A typical dump strategy would be to perform a full dump once a week,
  4493. and a level one dump once a day. This means some versions of files
  4494. will in fact be archived more than once, but this dump strategy makes
  4495. it possible to restore a file system to within one day of accuracy by
  4496. only extracting two archives---the last weekly (full) dump and the
  4497. last daily (level one) dump. The only information lost would be in
  4498. files changed or created since the last daily backup. (Doing dumps
  4499. more than once a day is usually not worth the trouble).
  4500. @GNUTAR{} comes with scripts you can use to do full
  4501. and level-one (actually, even level-two and so on) dumps. Using
  4502. scripts (shell programs) to perform backups and restoration is a
  4503. convenient and reliable alternative to typing out file name lists
  4504. and @command{tar} commands by hand.
  4505. Before you use these scripts, you need to edit the file
  4506. @file{backup-specs}, which specifies parameters used by the backup
  4507. scripts and by the restore script. This file is usually located
  4508. in @file{/etc/backup} directory. @xref{Backup Parameters}, for its
  4509. detailed description. Once the backup parameters are set, you can
  4510. perform backups or restoration by running the appropriate script.
  4511. The name of the backup script is @code{backup}. The name of the
  4512. restore script is @code{restore}. The following sections describe
  4513. their use in detail.
  4514. @emph{Please Note:} The backup and restoration scripts are
  4515. designed to be used together. While it is possible to restore files by
  4516. hand from an archive which was created using a backup script, and to create
  4517. an archive by hand which could then be extracted using the restore script,
  4518. it is easier to use the scripts. @xref{Incremental Dumps}, before
  4519. making such an attempt.
  4520. @node Backup Parameters
  4521. @section Setting Parameters for Backups and Restoration
  4522. The file @file{backup-specs} specifies backup parameters for the
  4523. backup and restoration scripts provided with @command{tar}. You must
  4524. edit @file{backup-specs} to fit your system configuration and schedule
  4525. before using these scripts.
  4526. Syntactically, @file{backup-specs} is a shell script, containing
  4527. mainly variable assignments. However, any valid shell construct
  4528. is allowed in this file. Particularly, you may wish to define
  4529. functions within that script (e.g., see @code{RESTORE_BEGIN} below).
  4530. For more information about shell script syntax, please refer to
  4531. @url{http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#ta
  4532. g_02, the definition of the Shell Command Language}. See also
  4533. @ref{Top,,Bash Features,bashref,Bash Reference Manual}.
  4534. The shell variables controlling behavior of @code{backup} and
  4535. @code{restore} are described in the following subsections.
  4536. @menu
  4537. * General-Purpose Variables::
  4538. * Magnetic Tape Control::
  4539. * User Hooks::
  4540. * backup-specs example:: An Example Text of @file{Backup-specs}
  4541. @end menu
  4542. @node General-Purpose Variables
  4543. @subsection General-Purpose Variables
  4544. @defvr {Backup variable} ADMINISTRATOR
  4545. The user name of the backup administrator. @code{Backup} scripts
  4546. sends a backup report to this address.
  4547. @end defvr
  4548. @defvr {Backup variable} BACKUP_HOUR
  4549. The hour at which the backups are done. This can be a number from 0
  4550. to 23, or the time specification in form @var{hours}:@var{minutes},
  4551. or the string @samp{now}.
  4552. This variable is used by @code{backup}. Its value may be overridden
  4553. using @option{--time} option (@pxref{Scripted Backups}).
  4554. @end defvr
  4555. @defvr {Backup variable} TAPE_FILE
  4556. The device @command{tar} writes the archive to. If @var{TAPE_FILE}
  4557. is a remote archive (@pxref{remote-dev}), backup script will suppose
  4558. that your @command{mt} is able to access remote devices. If @var{RSH}
  4559. (@pxref{RSH}) is set, @option{--rsh-command} option will be added to
  4560. invocations of @command{mt}.
  4561. @end defvr
  4562. @defvr {Backup variable} BLOCKING
  4563. The blocking factor @command{tar} will use when writing the dump archive.
  4564. @xref{Blocking Factor}.
  4565. @end defvr
  4566. @defvr {Backup variable} BACKUP_DIRS
  4567. A list of file systems to be dumped (for @code{backup}), or restored
  4568. (for @code{restore}). You can include any directory
  4569. name in the list --- subdirectories on that file system will be
  4570. included, regardless of how they may look to other networked machines.
  4571. Subdirectories on other file systems will be ignored.
  4572. The host name specifies which host to run @command{tar} on, and should
  4573. normally be the host that actually contains the file system. However,
  4574. the host machine must have @GNUTAR{} installed, and
  4575. must be able to access the directory containing the backup scripts and
  4576. their support files using the same file name that is used on the
  4577. machine where the scripts are run (ie. what @command{pwd} will print
  4578. when in that directory on that machine). If the host that contains
  4579. the file system does not have this capability, you can specify another
  4580. host as long as it can access the file system through NFS.
  4581. If the list of file systems is very long you may wish to put it
  4582. in a separate file. This file is usually named
  4583. @file{/etc/backup/dirs}, but this name may be overridden in
  4584. @file{backup-specs} using @code{DIRLIST} variable.
  4585. @end defvr
  4586. @defvr {Backup variable} DIRLIST
  4587. A path to the file containing the list of the file systems to backup
  4588. or restore. By default it is @file{/etc/backup/dirs}.
  4589. @end defvr
  4590. @defvr {Backup variable} BACKUP_FILES
  4591. A list of individual files to be dumped (for @code{backup}), or restored
  4592. (for @code{restore}). These should be accessible from the machine on
  4593. which the backup script is run.
  4594. If the list of file systems is very long you may wish to store it
  4595. in a separate file. This file is usually named
  4596. @file{/etc/backup/files}, but this name may be overridden in
  4597. @file{backup-specs} using @code{FILELIST} variable.
  4598. @end defvr
  4599. @defvr {Backup variable} FILELIST
  4600. A path to the file containing the list of the individual files to backup
  4601. or restore. By default it is @file{/etc/backup/files}.
  4602. @end defvr
  4603. @defvr {Backup variable} MT
  4604. Full file name of @command{mt} binary.
  4605. @end defvr
  4606. @defvr {Backup variable} RSH
  4607. @anchor{RSH}
  4608. Full file name of @command{rsh} binary or its equivalent. You may wish to
  4609. set it to @code{ssh}, to improve security. In this case you will have
  4610. to use public key authentication.
  4611. @end defvr
  4612. @defvr {Backup variable} RSH_COMMAND
  4613. Full file name of @command{rsh} binary on remote mashines. This will
  4614. be passed via @option{--rsh-command} option to the remote invocation
  4615. of @GNUTAR{}.
  4616. @end defvr
  4617. @defvr {Backup variable} VOLNO_FILE
  4618. Name of temporary file to hold volume numbers. This needs to be accessible
  4619. by all the machines which have file systems to be dumped.
  4620. @end defvr
  4621. @defvr {Backup variable} XLIST
  4622. Name of @dfn{exclude file list}. An @dfn{exclude file list} is a file
  4623. located on the remote machine and containing the list of files to
  4624. be excluded from the backup. Exclude file lists are searched in
  4625. /etc/tar-backup directory. A common use for exclude file lists
  4626. is to exclude files containing security-sensitive information
  4627. (e.g., @file{/etc/shadow} from backups).
  4628. This variable affects only @code{backup}.
  4629. @end defvr
  4630. @defvr {Backup variable} SLEEP_TIME
  4631. Time to sleep between dumps of any two successive file systems
  4632. This variable affects only @code{backup}.
  4633. @end defvr
  4634. @defvr {Backup variable} DUMP_REMIND_SCRIPT
  4635. Script to be run when it's time to insert a new tape in for the next
  4636. volume. Administrators may want to tailor this script for their site.
  4637. If this variable isn't set, @GNUTAR{} will display its built-in prompt
  4638. @FIXME-xref{describe it somewhere!}, and will expect confirmation from
  4639. the console.
  4640. @end defvr
  4641. @defvr {Backup variable} SLEEP_MESSAGE
  4642. Message to display on the terminal while waiting for dump time. Usually
  4643. this will just be some literal text.
  4644. @end defvr
  4645. @defvr {Backup variable} TAR
  4646. Full file name of the @GNUTAR{} executable. If this is not set, backup
  4647. scripts will search @command{tar} in the current shell path.
  4648. @end defvr
  4649. @node Magnetic Tape Control
  4650. @subsection Magnetic Tape Control
  4651. Backup scripts access tape device using special @dfn{hook functions}.
  4652. These functions take a single argument -- the name of the tape
  4653. device. Their names are kept in the following variables:
  4654. @defvr {Backup variable} MT_BEGIN
  4655. The name of @dfn{begin} function. This function is called before
  4656. accessing the drive. By default it retensions the tape:
  4657. @smallexample
  4658. MT_BEGIN=mt_begin
  4659. mt_begin() @{
  4660. mt -f "$1" retension
  4661. @}
  4662. @end smallexample
  4663. @end defvr
  4664. @defvr {Backup variable} MT_REWIND
  4665. The name of @dfn{rewind} function. The default definition is as
  4666. follows:
  4667. @smallexample
  4668. MT_REWIND=mt_rewind
  4669. mt_rewind() @{
  4670. mt -f "$1" rewind
  4671. @}
  4672. @end smallexample
  4673. @end defvr
  4674. @defvr {Backup variable} MT_OFFLINE
  4675. The name of the function switching the tape off line. By default
  4676. it is defined as follows:
  4677. @smallexample
  4678. MT_OFFLINE=mt_offline
  4679. mt_offline() @{
  4680. mt -f "$1" offl
  4681. @}
  4682. @end smallexample
  4683. @end defvr
  4684. @defvr {Backup variable} MT_STATUS
  4685. The name of the function used to obtain the status of the archive device,
  4686. including error count. Default definition:
  4687. @smallexample
  4688. MT_STATUS=mt_status
  4689. mt_status() @{
  4690. mt -f "$1" status
  4691. @}
  4692. @end smallexample
  4693. @end defvr
  4694. @node User Hooks
  4695. @subsection User Hooks
  4696. @dfn{User hooks} are shell functions executed before and after
  4697. each @command{tar} invocation. Thus, there are @dfn{backup
  4698. hooks}, which are executed before and after dumping each file
  4699. system, and @dfn{restore hooks}, executed before and
  4700. after restoring a file system. Each user hook is a shell function
  4701. taking four arguments:
  4702. @deffn {User Hook Function} hook @var{level} @var{host} @var{fs} @var{fsname}
  4703. Its arguments are:
  4704. @table @var
  4705. @item level
  4706. Current backup or restore level.
  4707. @item host
  4708. Name or IP address of the host machine being dumped or restored.
  4709. @item fs
  4710. Full path name to the file system being dumped or restored.
  4711. @item fsname
  4712. File system name with directory separators replaced with colons. This
  4713. is useful, e.g., for creating unique files.
  4714. @end table
  4715. @end deffn
  4716. Following variables keep the names of user hook functions
  4717. @defvr {Backup variable} DUMP_BEGIN
  4718. Dump begin function. It is executed before dumping the file system.
  4719. @end defvr
  4720. @defvr {Backup variable} DUMP_END
  4721. Executed after dumping the file system.
  4722. @end defvr
  4723. @defvr {Backup variable} RESTORE_BEGIN
  4724. Executed before restoring the file system.
  4725. @end defvr
  4726. @defvr {Backup variable} RESTORE_END
  4727. Executed after restoring the file system.
  4728. @end defvr
  4729. @node backup-specs example
  4730. @subsection An Example Text of @file{Backup-specs}
  4731. The following is an example of @file{backup-specs}:
  4732. @smallexample
  4733. # site-specific parameters for file system backup.
  4734. ADMINISTRATOR=friedman
  4735. BACKUP_HOUR=1
  4736. TAPE_FILE=/dev/nrsmt0
  4737. # Use @code{ssh} instead of the less secure @code{rsh}
  4738. RSH=/usr/bin/ssh
  4739. RSH_COMMAND=/usr/bin/ssh
  4740. # Override MT_STATUS function:
  4741. my_status() @{
  4742. mts -t $TAPE_FILE
  4743. @}
  4744. MT_STATUS=my_status
  4745. # Disable MT_OFFLINE function
  4746. MT_OFFLINE=:
  4747. BLOCKING=124
  4748. BACKUP_DIRS="
  4749. albert:/fs/fsf
  4750. apple-gunkies:/gd
  4751. albert:/fs/gd2
  4752. albert:/fs/gp
  4753. geech:/usr/jla
  4754. churchy:/usr/roland
  4755. albert:/
  4756. albert:/usr
  4757. apple-gunkies:/
  4758. apple-gunkies:/usr
  4759. gnu:/hack
  4760. gnu:/u
  4761. apple-gunkies:/com/mailer/gnu
  4762. apple-gunkies:/com/archive/gnu"
  4763. BACKUP_FILES="/com/mailer/aliases /com/mailer/league*[a-z]"
  4764. @end smallexample
  4765. @node Scripted Backups
  4766. @section Using the Backup Scripts
  4767. The syntax for running a backup script is:
  4768. @smallexample
  4769. backup --level=@var{level} --time=@var{time}
  4770. @end smallexample
  4771. The @option{level} option requests the dump level. Thus, to produce
  4772. a full dump, specify @code{--level=0} (this is the default, so
  4773. @option{--level} may be omitted if its value is @code{0}).
  4774. @footnote{For backward compatibility, the @code{backup} will also
  4775. try to deduce the requested dump level from the name of the
  4776. script itself. If the name consists of a string @samp{level-}
  4777. followed by a single decimal digit, that digit is taken as
  4778. the dump level number. Thus, you may create a link from @code{backup}
  4779. to @code{level-1} and then run @code{level-1} whenever you need to
  4780. create a level one dump.}
  4781. The @option{--time} option determines when should the backup be
  4782. run. @var{Time} may take three forms:
  4783. @table @asis
  4784. @item @var{hh}:@var{mm}
  4785. The dump must be run at @var{hh} hours @var{mm} minutes.
  4786. @item @var{hh}
  4787. The dump must be run at @var{hh} hours
  4788. @item now
  4789. The dump must be run immediately.
  4790. @end table
  4791. You should start a script with a tape or disk mounted. Once you
  4792. start a script, it prompts you for new tapes or disks as it
  4793. needs them. Media volumes don't have to correspond to archive
  4794. files --- a multi-volume archive can be started in the middle of a
  4795. tape that already contains the end of another multi-volume archive.
  4796. The @code{restore} script prompts for media by its archive volume,
  4797. so to avoid an error message you should keep track of which tape
  4798. (or disk) contains which volume of the archive (@pxref{Scripted
  4799. Restoration}).
  4800. The backup scripts write two files on the file system. The first is a
  4801. record file in @file{/etc/tar-backup/}, which is used by the scripts
  4802. to store and retrieve information about which files were dumped. This
  4803. file is not meant to be read by humans, and should not be deleted by
  4804. them. @xref{Snapshot Files}, for a more detailed explanation of this
  4805. file.
  4806. The second file is a log file containing the names of the file systems
  4807. and files dumped, what time the backup was made, and any error
  4808. messages that were generated, as well as how much space was left in
  4809. the media volume after the last volume of the archive was written.
  4810. You should check this log file after every backup. The file name is
  4811. @file{log-@var{mm-dd-yyyy}-level-@var{n}}, where @var{mm-dd-yyyy}
  4812. represents current date, and @var{n} represents current dump level number.
  4813. The script also prints the name of each system being dumped to the
  4814. standard output.
  4815. Following is the full list of options accepted by @code{backup}
  4816. script:
  4817. @table @option
  4818. @item -l @var{level}
  4819. @itemx --level=@var{level}
  4820. Do backup level @var{level} (default 0).
  4821. @item -f
  4822. @itemx --force
  4823. Force backup even if today's log file already exists.
  4824. @item -v[@var{level}]
  4825. @itemx --verbose[=@var{level}]
  4826. Set verbosity level. The higher the level is, the more debugging
  4827. information will be output during execution. Devault @var{level}
  4828. is 100, which means the highest debugging level.
  4829. @item -t @var{start-time}
  4830. @itemx --time=@var{start-time}
  4831. Wait till @var{time}, then do backup.
  4832. @item -h
  4833. @itemx --help
  4834. Display short help message and exit.
  4835. @item -V
  4836. @itemx --version
  4837. Display information about the program's name, version, origin and legal
  4838. status, all on standard output, and then exit successfully.
  4839. @end table
  4840. @node Scripted Restoration
  4841. @section Using the Restore Script
  4842. To restore files that were archived using a scripted backup, use the
  4843. @code{restore} script. Its usage is quite straightforward. In the
  4844. simplest form, invoke @code{restore --all}, it will
  4845. then restore all the file systems and files specified in
  4846. @file{backup-specs} (@pxref{General-Purpose Variables,BACKUP_DIRS}).
  4847. You may select the file systems (and/or files) to restore by
  4848. giving @code{restore} list of @dfn{patterns} in its command
  4849. line. For example, running
  4850. @smallexample
  4851. restore 'albert:*'
  4852. @end smallexample
  4853. @noindent
  4854. will restore all file systems on the machine @samp{albert}. A more
  4855. complicated example:
  4856. @smallexample
  4857. restore 'albert:*' '*:/var'
  4858. @end smallexample
  4859. @noindent
  4860. This command will restore all file systems on the machine @samp{albert}
  4861. as well as @file{/var} file system on all machines.
  4862. By default @code{restore} will start restoring files from the lowest
  4863. available dump level (usually zero) and will continue through
  4864. all available dump levels. There may be situations where such a
  4865. thorough restore is not necessary. For example, you may wish to
  4866. restore only files from the recent level one backup. To do so,
  4867. use @option{--level} option, as shown in the example below:
  4868. @smallexample
  4869. restore --level=1
  4870. @end smallexample
  4871. The full list of options accepted by @code{restore} follows:
  4872. @table @option
  4873. @item -a
  4874. @itemx --all
  4875. Restore all file systems and files specified in @file{backup-specs}
  4876. @item -l @var{level}
  4877. @itemx --level=@var{level}
  4878. Start restoring from the given backup level, instead of the default 0.
  4879. @item -v[@var{level}]
  4880. @itemx --verbose[=@var{level}]
  4881. Set verbosity level. The higher the level is, the more debugging
  4882. information will be output during execution. Devault @var{level}
  4883. is 100, which means the highest debugging level.
  4884. @item -h
  4885. @itemx --help
  4886. Display short help message and exit.
  4887. @item -V
  4888. @itemx --version
  4889. Display information about the program's name, version, origin and legal
  4890. status, all on standard output, and then exit successfully.
  4891. @end table
  4892. You should start the restore script with the media containing the
  4893. first volume of the archive mounted. The script will prompt for other
  4894. volumes as they are needed. If the archive is on tape, you don't need
  4895. to rewind the tape to to its beginning---if the tape head is
  4896. positioned past the beginning of the archive, the script will rewind
  4897. the tape as needed. @FIXME-xref{Media, for a discussion of tape
  4898. positioning.}
  4899. @quotation
  4900. @strong{Warning:} The script will delete files from the active file
  4901. system if they were not in the file system when the archive was made.
  4902. @end quotation
  4903. @xref{Incremental Dumps}, for an explanation of how the script makes
  4904. that determination.
  4905. @node Choosing
  4906. @chapter Choosing Files and Names for @command{tar}
  4907. @UNREVISED
  4908. Certain options to @command{tar} enable you to specify a name for your
  4909. archive. Other options let you decide which files to include or exclude
  4910. from the archive, based on when or whether files were modified, whether
  4911. the file names do or don't match specified patterns, or whether files
  4912. are in specified directories.
  4913. This chapter discusses these options in detail.
  4914. @menu
  4915. * file:: Choosing the Archive's Name
  4916. * Selecting Archive Members::
  4917. * files:: Reading Names from a File
  4918. * exclude:: Excluding Some Files
  4919. * Wildcards:: Wildcards Patterns and Matching
  4920. * after:: Operating Only on New Files
  4921. * recurse:: Descending into Directories
  4922. * one:: Crossing File System Boundaries
  4923. @end menu
  4924. @node file
  4925. @section Choosing and Naming Archive Files
  4926. @UNREVISED
  4927. @cindex Naming an archive
  4928. @cindex Archive Name
  4929. @cindex Choosing an archive file
  4930. @cindex Where is the archive?
  4931. By default, @command{tar} uses an archive file name that was compiled when
  4932. it was built on the system; usually this name refers to some physical
  4933. tape drive on the machine. However, the person who installed @command{tar}
  4934. on the system may not have set the default to a meaningful value as far as
  4935. most users are concerned. As a result, you will usually want to tell
  4936. @command{tar} where to find (or create) the archive. The
  4937. @option{--file=@var{archive-name}} (@option{-f @var{archive-name}})
  4938. option allows you to either specify or name a file to use as the archive
  4939. instead of the default archive file location.
  4940. @table @option
  4941. @opindex file, short description
  4942. @item --file=@var{archive-name}
  4943. @itemx -f @var{archive-name}
  4944. Name the archive to create or operate on. Use in conjunction with
  4945. any operation.
  4946. @end table
  4947. For example, in this @command{tar} command,
  4948. @smallexample
  4949. $ @kbd{tar -cvf collection.tar blues folk jazz}
  4950. @end smallexample
  4951. @noindent
  4952. @file{collection.tar} is the name of the archive. It must directly
  4953. follow the @option{-f} option, since whatever directly follows @option{-f}
  4954. @emph{will} end up naming the archive. If you neglect to specify an
  4955. archive name, you may end up overwriting a file in the working directory
  4956. with the archive you create since @command{tar} will use this file's name
  4957. for the archive name.
  4958. An archive can be saved as a file in the file system, sent through a
  4959. pipe or over a network, or written to an I/O device such as a tape,
  4960. floppy disk, or CD write drive.
  4961. @cindex Writing new archives
  4962. @cindex Archive creation
  4963. If you do not name the archive, @command{tar} uses the value of the
  4964. environment variable @env{TAPE} as the file name for the archive. If
  4965. that is not available, @command{tar} uses a default, compiled-in archive
  4966. name, usually that for tape unit zero (ie. @file{/dev/tu00}).
  4967. @cindex Standard input and output
  4968. @cindex tar to standard input and output
  4969. If you use @file{-} as an @var{archive-name}, @command{tar} reads the
  4970. archive from standard input (when listing or extracting files), or
  4971. writes it to standard output (when creating an archive). If you use
  4972. @file{-} as an @var{archive-name} when modifying an archive,
  4973. @command{tar} reads the original archive from its standard input and
  4974. writes the entire new archive to its standard output.
  4975. The following example is a convenient way of copying directory
  4976. hierarchy from @file{sourcedir} to @file{targetdir}.
  4977. @smallexample
  4978. $ @kbd{(cd sourcedir; tar -cf - .) | (cd targetdir; tar -xpf -)}
  4979. @end smallexample
  4980. The @option{-C} option allows to avoid using subshells:
  4981. @smallexample
  4982. $ @kbd{tar -C sourcedir -cf - . | tar -C targetdir -xpf -}
  4983. @end smallexample
  4984. In both examples above, the leftmost @command{tar} invocation archives
  4985. the contents of @file{sourcedir} to the standard output, while the
  4986. rightmost one reads this archive from its standard input and
  4987. extracts it. The @option{-p} option tells it to restore permissions
  4988. of the extracted files.
  4989. @cindex Remote devices
  4990. @cindex tar to a remote device
  4991. @anchor{remote-dev}
  4992. To specify an archive file on a device attached to a remote machine,
  4993. use the following:
  4994. @smallexample
  4995. @kbd{--file=@var{hostname}:/@var{dev}/@var{file-name}}
  4996. @end smallexample
  4997. @noindent
  4998. @command{tar} will complete the remote connection, if possible, and
  4999. prompt you for a username and password. If you use
  5000. @option{--file=@@@var{hostname}:/@var{dev}/@var{file-name}}, @command{tar}
  5001. will complete the remote connection, if possible, using your username
  5002. as the username on the remote machine.
  5003. @cindex Local and remote archives
  5004. @anchor{local and remote archives}
  5005. If the archive file name includes a colon (@samp{:}), then it is assumed
  5006. to be a file on another machine. If the archive file is
  5007. @samp{@var{user}@@@var{host}:@var{file}}, then @var{file} is used on the
  5008. host @var{host}. The remote host is accessed using the @command{rsh}
  5009. program, with a username of @var{user}. If the username is omitted
  5010. (along with the @samp{@@} sign), then your user name will be used.
  5011. (This is the normal @command{rsh} behavior.) It is necessary for the
  5012. remote machine, in addition to permitting your @command{rsh} access, to
  5013. have the @file{rmt} program installed (This command is included in
  5014. the @GNUTAR{} distribution and by default is installed under
  5015. @file{@var{prefix}/libexec/rmt}, were @var{prefix} means your
  5016. installation prefix). If you need to use a file whose name includes a
  5017. colon, then the remote tape drive behavior
  5018. can be inhibited by using the @option{--force-local} option.
  5019. When the archive is being created to @file{/dev/null}, @GNUTAR{}
  5020. tries to minimize input and output operations. The Amanda backup
  5021. system, when used with @GNUTAR{}, has an initial sizing pass which
  5022. uses this feature.
  5023. @node Selecting Archive Members
  5024. @section Selecting Archive Members
  5025. @cindex Specifying files to act on
  5026. @cindex Specifying archive members
  5027. @dfn{File Name arguments} specify which files in the file system
  5028. @command{tar} operates on, when creating or adding to an archive, or which
  5029. archive members @command{tar} operates on, when reading or deleting from
  5030. an archive. @xref{Operations}.
  5031. To specify file names, you can include them as the last arguments on
  5032. the command line, as follows:
  5033. @smallexample
  5034. @kbd{tar} @var{operation} [@var{option1} @var{option2} @dots{}] [@var{file name-1} @var{file name-2} @dots{}]
  5035. @end smallexample
  5036. If a file name begins with dash (@samp{-}), precede it with
  5037. @option{--add-file} option to prevent it from being treated as an
  5038. option.
  5039. If you specify a directory name as a file name argument, all the files
  5040. in that directory are operated on by @command{tar}.
  5041. If you do not specify files, @command{tar} behavior differs depending
  5042. on the operation mode as described below:
  5043. When @command{tar} is invoked with @option{--create} (@option{-c}),
  5044. @command{tar} will stop immediately, reporting the following:
  5045. @smallexample
  5046. @group
  5047. $ @kbd{tar cf a.tar}
  5048. tar: Cowardly refusing to create an empty archive
  5049. Try `tar --help' or `tar --usage' for more information.
  5050. @end group
  5051. @end smallexample
  5052. If you specify either @option{--list} (@option{-t}) or
  5053. @option{--extract} (@option{--get}, @option{-x}), @command{tar}
  5054. operates on all the archive members in the archive.
  5055. If run with @option{--diff} option, tar will compare the archive with
  5056. the contents of the current working directory.
  5057. If you specify any other operation, @command{tar} does nothing.
  5058. By default, @command{tar} takes file names from the command line. However,
  5059. there are other ways to specify file or member names, or to modify the
  5060. manner in which @command{tar} selects the files or members upon which to
  5061. operate. In general, these methods work both for specifying the names
  5062. of files and archive members.
  5063. @node files
  5064. @section Reading Names from a File
  5065. @cindex Reading file names from a file
  5066. @cindex Lists of file names
  5067. @cindex File Name arguments, alternatives
  5068. Instead of giving the names of files or archive members on the command
  5069. line, you can put the names into a file, and then use the
  5070. @option{--files-from=@var{file-of-names}} (@option{-T
  5071. @var{file-of-names}}) option to @command{tar}. Give the name of the
  5072. file which contains the list of files to include as the argument to
  5073. @option{--files-from}. In the list, the file names should be separated by
  5074. newlines. You will frequently use this option when you have generated
  5075. the list of files to archive with the @command{find} utility.
  5076. @table @option
  5077. @opindex files-from
  5078. @item --files-from=@var{file-name}
  5079. @itemx -T @var{file-name}
  5080. Get names to extract or create from file @var{file-name}.
  5081. @end table
  5082. If you give a single dash as a file name for @option{--files-from}, (i.e.,
  5083. you specify either @code{--files-from=-} or @code{-T -}), then the file
  5084. names are read from standard input.
  5085. Unless you are running @command{tar} with @option{--create}, you can not use
  5086. both @code{--files-from=-} and @code{--file=-} (@code{-f -}) in the same
  5087. command.
  5088. Any number of @option{-T} options can be given in the command line.
  5089. The following example shows how to use @command{find} to generate a list of
  5090. files smaller than 400K in length and put that list into a file
  5091. called @file{small-files}. You can then use the @option{-T} option to
  5092. @command{tar} to specify the files from that file, @file{small-files}, to
  5093. create the archive @file{little.tgz}. (The @option{-z} option to
  5094. @command{tar} compresses the archive with @command{gzip}; @pxref{gzip} for
  5095. more information.)
  5096. @smallexample
  5097. $ @kbd{find . -size -400 -print > small-files}
  5098. $ @kbd{tar -c -v -z -T small-files -f little.tgz}
  5099. @end smallexample
  5100. @noindent
  5101. In the file list given by @option{-T} option, any file name beginning
  5102. with @samp{-} character is considered a @command{tar} option and is
  5103. processed accordingly.@footnote{Versions of @GNUTAR{} up to 1.15.1
  5104. recognized only @option{-C} option in file lists, and only if the
  5105. option and its argument occupied two consecutive lines.} For example,
  5106. the common use of this feature is to change to another directory by
  5107. specifying @option{-C} option:
  5108. @smallexample
  5109. @group
  5110. $ @kbd{cat list}
  5111. -C/etc
  5112. passwd
  5113. hosts
  5114. -C/lib
  5115. libc.a
  5116. $ @kbd{tar -c -f foo.tar --files-from list}
  5117. @end group
  5118. @end smallexample
  5119. @noindent
  5120. In this example, @command{tar} will first switch to @file{/etc}
  5121. directory and add files @file{passwd} and @file{hosts} to the
  5122. archive. Then it will change to @file{/lib} directory and will archive
  5123. the file @file{libc.a}. Thus, the resulting archive @file{foo.tar} will
  5124. contain:
  5125. @smallexample
  5126. @group
  5127. $ @kbd{tar tf foo.tar}
  5128. passwd
  5129. hosts
  5130. libc.a
  5131. @end group
  5132. @end smallexample
  5133. @noindent
  5134. @opindex directory, using in @option{--files-from} argument
  5135. Notice that the option parsing algorithm used with @option{-T} is
  5136. stricter than the one used by shell. Namely, when specifying option
  5137. arguments, you should observe the following rules:
  5138. @itemize @bullet
  5139. @item
  5140. When using short (single-letter) option form, its argument must
  5141. immediately follow the option letter, without any intervening
  5142. whitespace. For example: @code{-Cdir}.
  5143. @item
  5144. When using long option form, the option argument must be separated
  5145. from the option by a single equal sign. No whitespace is allowed on
  5146. any side of the equal sign. For example: @code{--directory=dir}.
  5147. @item
  5148. For both short and long option forms, the option argument can be given
  5149. on the next line after the option name, e.g.:
  5150. @smallexample
  5151. @group
  5152. --directory
  5153. dir
  5154. @end group
  5155. @end smallexample
  5156. @noindent
  5157. and
  5158. @smallexample
  5159. @group
  5160. -C
  5161. dir
  5162. @end group
  5163. @end smallexample
  5164. @end itemize
  5165. @opindex add-file
  5166. If you happen to have a file whose name starts with @samp{-},
  5167. precede it with @option{--add-file} option to prevent it from
  5168. being recognized as an option. For example: @code{--add-file=--my-file}.
  5169. @menu
  5170. * nul::
  5171. @end menu
  5172. @node nul
  5173. @subsection @code{NUL} Terminated File Names
  5174. @cindex File names, terminated by @code{NUL}
  5175. @cindex @code{NUL} terminated file names
  5176. The @option{--null} option causes
  5177. @option{--files-from=@var{file-of-names}} (@option{-T @var{file-of-names}})
  5178. to read file names terminated by a @code{NUL} instead of a newline, so
  5179. files whose names contain newlines can be archived using
  5180. @option{--files-from}.
  5181. @table @option
  5182. @opindex null
  5183. @item --null
  5184. Only consider @code{NUL} terminated file names, instead of files that
  5185. terminate in a newline.
  5186. @end table
  5187. The @option{--null} option is just like the one in @acronym{GNU}
  5188. @command{xargs} and @command{cpio}, and is useful with the
  5189. @option{-print0} predicate of @acronym{GNU} @command{find}. In
  5190. @command{tar}, @option{--null} also disables special handling for
  5191. file names that begin with dash.
  5192. This example shows how to use @command{find} to generate a list of files
  5193. larger than 800K in length and put that list into a file called
  5194. @file{long-files}. The @option{-print0} option to @command{find} is just
  5195. like @option{-print}, except that it separates files with a @code{NUL}
  5196. rather than with a newline. You can then run @command{tar} with both the
  5197. @option{--null} and @option{-T} options to specify that @command{tar} get the
  5198. files from that file, @file{long-files}, to create the archive
  5199. @file{big.tgz}. The @option{--null} option to @command{tar} will cause
  5200. @command{tar} to recognize the @code{NUL} separator between files.
  5201. @smallexample
  5202. $ @kbd{find . -size +800 -print0 > long-files}
  5203. $ @kbd{tar -c -v --null --files-from=long-files --file=big.tar}
  5204. @end smallexample
  5205. @FIXME{say anything else here to conclude the section?}
  5206. @node exclude
  5207. @section Excluding Some Files
  5208. @UNREVISED
  5209. @cindex File names, excluding files by
  5210. @cindex Excluding files by name and pattern
  5211. @cindex Excluding files by file system
  5212. To avoid operating on files whose names match a particular pattern,
  5213. use the @option{--exclude} or @option{--exclude-from} options.
  5214. @table @option
  5215. @opindex exclude
  5216. @item --exclude=@var{pattern}
  5217. Causes @command{tar} to ignore files that match the @var{pattern}.
  5218. @end table
  5219. @findex exclude
  5220. The @option{--exclude=@var{pattern}} option prevents any file or
  5221. member whose name matches the shell wildcard (@var{pattern}) from
  5222. being operated on.
  5223. For example, to create an archive with all the contents of the directory
  5224. @file{src} except for files whose names end in @file{.o}, use the
  5225. command @samp{tar -cf src.tar --exclude='*.o' src}.
  5226. You may give multiple @option{--exclude} options.
  5227. @table @option
  5228. @opindex exclude-from
  5229. @item --exclude-from=@var{file}
  5230. @itemx -X @var{file}
  5231. Causes @command{tar} to ignore files that match the patterns listed in
  5232. @var{file}.
  5233. @end table
  5234. @findex exclude-from
  5235. Use the @option{--exclude-from} option to read a
  5236. list of patterns, one per line, from @var{file}; @command{tar} will
  5237. ignore files matching those patterns. Thus if @command{tar} is
  5238. called as @w{@samp{tar -c -X foo .}} and the file @file{foo} contains a
  5239. single line @file{*.o}, no files whose names end in @file{.o} will be
  5240. added to the archive.
  5241. @table @option
  5242. @opindex exclude-caches
  5243. @item --exclude-caches
  5244. Causes @command{tar} to ignore directories containing a cache directory tag.
  5245. @end table
  5246. @findex exclude-caches
  5247. When creating an archive, the @option{--exclude-caches} option causes
  5248. @command{tar} to exclude all directories that contain a @dfn{cache
  5249. directory tag}. A cache directory tag is a short file with the
  5250. well-known name @file{CACHEDIR.TAG} and having a standard header
  5251. specified in @url{http://www.brynosaurus.com/cachedir/spec.html}.
  5252. Various applications write cache directory tags into directories they
  5253. use to hold regenerable, non-precious data, so that such data can be
  5254. more easily excluded from backups.
  5255. @menu
  5256. * problems with exclude::
  5257. @end menu
  5258. @node problems with exclude
  5259. @unnumberedsubsec Problems with Using the @code{exclude} Options
  5260. @opindex exclude, potential problems with
  5261. Some users find @samp{exclude} options confusing. Here are some common
  5262. pitfalls:
  5263. @itemize @bullet
  5264. @item
  5265. The main operating mode of @command{tar} does not act on a path name
  5266. explicitly listed on the command line if one of its file name
  5267. components is excluded. In the example above, if
  5268. you create an archive and exclude files that end with @samp{*.o}, but
  5269. explicitly name the file @samp{dir.o/foo} after all the options have been
  5270. listed, @samp{dir.o/foo} will be excluded from the archive.
  5271. @item
  5272. You can sometimes confuse the meanings of @option{--exclude} and
  5273. @option{--exclude-from}. Be careful: use @option{--exclude} when files
  5274. to be excluded are given as a pattern on the command line. Use
  5275. @option{--exclude-from} to introduce the name of a file which contains
  5276. a list of patterns, one per line; each of these patterns can exclude
  5277. zero, one, or many files.
  5278. @item
  5279. When you use @option{--exclude=@var{pattern}}, be sure to quote the
  5280. @var{pattern} parameter, so @GNUTAR{} sees wildcard characters
  5281. like @samp{*}. If you do not do this, the shell might expand the
  5282. @samp{*} itself using files at hand, so @command{tar} might receive a
  5283. list of files instead of one pattern, or none at all, making the
  5284. command somewhat illegal. This might not correspond to what you want.
  5285. For example, write:
  5286. @smallexample
  5287. $ @kbd{tar -c -f @var{archive.tar} --exclude '*.o' @var{directory}}
  5288. @end smallexample
  5289. @noindent
  5290. rather than:
  5291. @smallexample
  5292. # @emph{Wrong!}
  5293. $ @kbd{tar -c -f @var{archive.tar} --exclude *.o @var{directory}}
  5294. @end smallexample
  5295. @item
  5296. You must use use shell syntax, or globbing, rather than @code{regexp}
  5297. syntax, when using exclude options in @command{tar}. If you try to use
  5298. @code{regexp} syntax to describe files to be excluded, your command
  5299. might fail.
  5300. @item
  5301. @FIXME{The change in semantics must have occurred before 1.11,
  5302. so I doubt if it is worth mentioning at all. Anyway, should at
  5303. least specify in which version the semantics changed.}
  5304. In earlier versions of @command{tar}, what is now the
  5305. @option{--exclude-from} option was called @option{--exclude} instead.
  5306. Now, @option{--exclude} applies to patterns listed on the command
  5307. line and @option{--exclude-from} applies to patterns listed in a
  5308. file.
  5309. @end itemize
  5310. @node Wildcards
  5311. @section Wildcards Patterns and Matching
  5312. @dfn{Globbing} is the operation by which @dfn{wildcard} characters,
  5313. @samp{*} or @samp{?} for example, are replaced and expanded into all
  5314. existing files matching the given pattern. @GNUTAR{} can use wildcard
  5315. patterns for matching (or globbing) archive members when extracting
  5316. from or listing an archive. Wildcard patterns are also used for
  5317. verifying volume labels of @command{tar} archives. This section has the
  5318. purpose of explaining wildcard syntax for @command{tar}.
  5319. @FIXME{the next few paragraphs need work.}
  5320. A @var{pattern} should be written according to shell syntax, using wildcard
  5321. characters to effect globbing. Most characters in the pattern stand
  5322. for themselves in the matched string, and case is significant: @samp{a}
  5323. will match only @samp{a}, and not @samp{A}. The character @samp{?} in the
  5324. pattern matches any single character in the matched string. The character
  5325. @samp{*} in the pattern matches zero, one, or more single characters in
  5326. the matched string. The character @samp{\} says to take the following
  5327. character of the pattern @emph{literally}; it is useful when one needs to
  5328. match the @samp{?}, @samp{*}, @samp{[} or @samp{\} characters, themselves.
  5329. The character @samp{[}, up to the matching @samp{]}, introduces a character
  5330. class. A @dfn{character class} is a list of acceptable characters
  5331. for the next single character of the matched string. For example,
  5332. @samp{[abcde]} would match any of the first five letters of the alphabet.
  5333. Note that within a character class, all of the ``special characters''
  5334. listed above other than @samp{\} lose their special meaning; for example,
  5335. @samp{[-\\[*?]]} would match any of the characters, @samp{-}, @samp{\},
  5336. @samp{[}, @samp{*}, @samp{?}, or @samp{]}. (Due to parsing constraints,
  5337. the characters @samp{-} and @samp{]} must either come @emph{first} or
  5338. @emph{last} in a character class.)
  5339. @cindex Excluding characters from a character class
  5340. @cindex Character class, excluding characters from
  5341. If the first character of the class after the opening @samp{[}
  5342. is @samp{!} or @samp{^}, then the meaning of the class is reversed.
  5343. Rather than listing character to match, it lists those characters which
  5344. are @emph{forbidden} as the next single character of the matched string.
  5345. Other characters of the class stand for themselves. The special
  5346. construction @samp{[@var{a}-@var{e}]}, using an hyphen between two
  5347. letters, is meant to represent all characters between @var{a} and
  5348. @var{e}, inclusive.
  5349. @FIXME{need to add a sentence or so here to make this clear for those
  5350. who don't have dan around.}
  5351. Periods (@samp{.}) or forward slashes (@samp{/}) are not considered
  5352. special for wildcard matches. However, if a pattern completely matches
  5353. a directory prefix of a matched string, then it matches the full matched
  5354. string: thus, excluding a directory also excludes all the files beneath it.
  5355. @menu
  5356. * controlling pattern-matching::
  5357. @end menu
  5358. @node controlling pattern-matching
  5359. @unnumberedsubsec Controlling Pattern-Matching
  5360. For the purposes of this section, we call @dfn{exclusion members} all
  5361. member names obtained while processing @option{--exclude} and
  5362. @option{--exclude-from} options, and @dfn{inclusion members} those
  5363. member names that were given in the command line or read from the file
  5364. specified with @option{--files-from} option.
  5365. These two pairs of member lists are used in the following operations:
  5366. @option{--diff}, @option{--extract}, @option{--list},
  5367. @option{--update}.
  5368. There are no inclusion members in create mode (@option{--create} and
  5369. @option{--append}), since in this mode the names obtained from the
  5370. command line refer to @emph{files}, not archive members.
  5371. By default, inclusion members are compared with archive members
  5372. literally @footnote{Notice that earlier @GNUTAR{} versions used
  5373. globbing for inclusion members, which contradicted to UNIX98
  5374. specification and was not documented. @xref{Changes}, for more
  5375. information on this and other changes} and exclusion members are
  5376. treated as globbing patterns. For example:
  5377. @smallexample
  5378. @group
  5379. $ @kbd{tar tf foo.tar}
  5380. a.c
  5381. b.c
  5382. a.txt
  5383. [remarks]
  5384. # @i{Member names are used verbatim:}
  5385. $ @kbd{tar -xf foo.tar -v '[remarks]'}
  5386. [remarks]
  5387. # @i{Exclude member names are globbed:}
  5388. $ @kbd{tar -xf foo.tar -v --exclude '*.c'}
  5389. a.txt
  5390. [remarks]
  5391. @end group
  5392. @end smallexample
  5393. This behavior can be altered by using the following options:
  5394. @table @option
  5395. @opindex wildcards
  5396. @item --wildcards
  5397. Treat all member names as wildcards.
  5398. @opindex no-wildcards
  5399. @item --no-wildcards
  5400. Treat all member names as literal strings.
  5401. @end table
  5402. Thus, to extract files whose names end in @samp{.c}, you can use:
  5403. @smallexample
  5404. $ @kbd{tar -xf foo.tar -v --wildcards '*.c'}
  5405. a.c
  5406. b.c
  5407. @end smallexample
  5408. @noindent
  5409. Notice quoting of the pattern to prevent the shell from interpreting
  5410. it.
  5411. The effect of @option{--wildcards} option is cancelled by
  5412. @option{--no-wildcards}. This can be used to pass part of
  5413. the command line arguments verbatim and other part as globbing
  5414. patterns. For example, the following invocation:
  5415. @smallexample
  5416. $ @kbd{tar -xf foo.tar --wildcards '*.txt' --no-wildcards '[remarks]'}
  5417. @end smallexample
  5418. @noindent
  5419. instructs @command{tar} to extract from @file{foo.tar} all files whose
  5420. names end in @samp{.txt} and the file named @file{[remarks]}.
  5421. Normally, a pattern matches a name if an initial subsequence of the
  5422. name's components matches the pattern, where @samp{*}, @samp{?}, and
  5423. @samp{[...]} are the usual shell wildcards, @samp{\} escapes wildcards,
  5424. and wildcards can match @samp{/}.
  5425. Other than optionally stripping leading @samp{/} from names
  5426. (@pxref{absolute}), patterns and names are used as-is. For
  5427. example, trailing @samp{/} is not trimmed from a user-specified name
  5428. before deciding whether to exclude it.
  5429. However, this matching procedure can be altered by the options listed
  5430. below. These options accumulate. For example:
  5431. @smallexample
  5432. --ignore-case --exclude='makefile' --no-ignore-case ---exclude='readme'
  5433. @end smallexample
  5434. ignores case when excluding @samp{makefile}, but not when excluding
  5435. @samp{readme}.
  5436. @table @option
  5437. @opindex anchored
  5438. @opindex no-anchored
  5439. @item --anchored
  5440. @itemx --no-anchored
  5441. If anchored, a pattern must match an initial subsequence
  5442. of the name's components. Otherwise, the pattern can match any
  5443. subsequence. Default is @option{--no-anchored} for exclusion members
  5444. and @option{--anchored} inclusion members.
  5445. @opindex ignore-case
  5446. @opindex no-ignore-case
  5447. @item --ignore-case
  5448. @itemx --no-ignore-case
  5449. When ignoring case, upper-case patterns match lower-case names and vice versa.
  5450. When not ignoring case (the default), matching is case-sensitive.
  5451. @opindex wildcards-match-slash
  5452. @opindex no-wildcards-match-slash
  5453. @item --wildcards-match-slash
  5454. @itemx --no-wildcards-match-slash
  5455. When wildcards match slash (the default for exclusion members), a
  5456. wildcard like @samp{*} in the pattern can match a @samp{/} in the
  5457. name. Otherwise, @samp{/} is matched only by @samp{/}.
  5458. @end table
  5459. The @option{--recursion} and @option{--no-recursion} options
  5460. (@pxref{recurse}) also affect how member patterns are interpreted. If
  5461. recursion is in effect, a pattern matches a name if it matches any of
  5462. the name's parent directories.
  5463. The following table summarizes pattern-matching default values:
  5464. @multitable @columnfractions .3 .7
  5465. @headitem Members @tab Default settings
  5466. @item Inclusion @tab @option{--no-wildcards --anchored --no-wildcards-match-slash}
  5467. @item Exclusion @tab @option{--wildcards --no-anchored --wildcards-match-slash}
  5468. @end multitable
  5469. @node after
  5470. @section Operating Only on New Files
  5471. @UNREVISED
  5472. @cindex Excluding file by age
  5473. @cindex Data Modification time, excluding files by
  5474. @cindex Modification time, excluding files by
  5475. @cindex Age, excluding files by
  5476. The @option{--after-date=@var{date}} (@option{--newer=@var{date}},
  5477. @option{-N @var{date}}) option causes @command{tar} to only work on
  5478. files whose data modification or status change times are newer than
  5479. the @var{date} given. If @var{date} starts with @samp{/} or @samp{.},
  5480. it is taken to be a file name; the data modification time of that file
  5481. is used as the date. If you use this option when creating or appending
  5482. to an archive, the archive will only include new files. If you use
  5483. @option{--after-date} when extracting an archive, @command{tar} will
  5484. only extract files newer than the @var{date} you specify.
  5485. If you only want @command{tar} to make the date comparison based on
  5486. modification of the file's data (rather than status
  5487. changes), then use the @option{--newer-mtime=@var{date}} option.
  5488. You may use these options with any operation. Note that these options
  5489. differ from the @option{--update} (@option{-u}) operation in that they
  5490. allow you to specify a particular date against which @command{tar} can
  5491. compare when deciding whether or not to archive the files.
  5492. @table @option
  5493. @opindex after-date
  5494. @opindex newer
  5495. @item --after-date=@var{date}
  5496. @itemx --newer=@var{date}
  5497. @itemx -N @var{date}
  5498. Only store files newer than @var{date}.
  5499. Acts on files only if their data modification or status change times are
  5500. later than @var{date}. Use in conjunction with any operation.
  5501. If @var{date} starts with @samp{/} or @samp{.}, it is taken to be a file
  5502. name; the data modification time of that file is used as the date.
  5503. @opindex newer-mtime
  5504. @item --newer-mtime=@var{date}
  5505. Acts like @option{--after-date}, but only looks at data modification times.
  5506. @end table
  5507. These options limit @command{tar} to operate only on files which have
  5508. been modified after the date specified. A file's status is considered to have
  5509. changed if its contents have been modified, or if its owner,
  5510. permissions, and so forth, have been changed. (For more information on
  5511. how to specify a date, see @ref{Date input formats}; remember that the
  5512. entire date argument must be quoted if it contains any spaces.)
  5513. Gurus would say that @option{--after-date} tests both the data
  5514. modification time (@code{mtime}, the time the contents of the file
  5515. were last modified) and the status change time (@code{ctime}, the time
  5516. the file's status was last changed: owner, permissions, etc.@:)
  5517. fields, while @option{--newer-mtime} tests only the @code{mtime}
  5518. field.
  5519. To be precise, @option{--after-date} checks @emph{both} @code{mtime} and
  5520. @code{ctime} and processes the file if either one is more recent than
  5521. @var{date}, while @option{--newer-mtime} only checks @code{mtime} and
  5522. disregards @code{ctime}. Neither does it use @code{atime} (the last time the
  5523. contents of the file were looked at).
  5524. Date specifiers can have embedded spaces. Because of this, you may need
  5525. to quote date arguments to keep the shell from parsing them as separate
  5526. arguments. For example, the following command will add to the archive
  5527. all the files modified less than two days ago:
  5528. @smallexample
  5529. $ @kbd{tar -cf foo.tar --newer-mtime '2 days ago'}
  5530. @end smallexample
  5531. @quotation
  5532. @strong{Please Note:} @option{--after-date} and @option{--newer-mtime}
  5533. should not be used for incremental backups. @xref{Incremental Dumps},
  5534. for proper way of creating incremental backups.
  5535. @end quotation
  5536. @node recurse
  5537. @section Descending into Directories
  5538. @UNREVISED
  5539. @cindex Avoiding recursion in directories
  5540. @cindex Descending directories, avoiding
  5541. @cindex Directories, avoiding recursion
  5542. @cindex Recursion in directories, avoiding
  5543. @FIXME{arrggh! this is still somewhat confusing to me. :-< }
  5544. Usually, @command{tar} will recursively explore all directories (either
  5545. those given on the command line or through the @option{--files-from}
  5546. option) for the various files they contain. However, you may not always
  5547. want @command{tar} to act this way.
  5548. @opindex no-recursion
  5549. The @option{--no-recursion} option inhibits @command{tar}'s recursive descent
  5550. into specified directories. If you specify @option{--no-recursion}, you can
  5551. use the @command{find} utility for hunting through levels of directories to
  5552. construct a list of file names which you could then pass to @command{tar}.
  5553. @command{find} allows you to be more selective when choosing which files to
  5554. archive; see @ref{files}, for more information on using @command{find} with
  5555. @command{tar}, or look.
  5556. @table @option
  5557. @item --no-recursion
  5558. Prevents @command{tar} from recursively descending directories.
  5559. @opindex recursion
  5560. @item --recursion
  5561. Requires @command{tar} to recursively descend directories.
  5562. This is the default.
  5563. @end table
  5564. When you use @option{--no-recursion}, @GNUTAR{} grabs
  5565. directory entries themselves, but does not descend on them
  5566. recursively. Many people use @command{find} for locating files they
  5567. want to back up, and since @command{tar} @emph{usually} recursively
  5568. descends on directories, they have to use the @samp{@w{-not -type d}}
  5569. test in their @command{find} invocation (@pxref{Type, Type, Type test,
  5570. find, Finding Files}), as they usually do not want all the files in a
  5571. directory. They then use the @option{--files-from} option to archive
  5572. the files located via @command{find}.
  5573. The problem when restoring files archived in this manner is that the
  5574. directories themselves are not in the archive; so the
  5575. @option{--same-permissions} (@option{--preserve-permissions},
  5576. @option{-p}) option does not affect them---while users might really
  5577. like it to. Specifying @option{--no-recursion} is a way to tell
  5578. @command{tar} to grab only the directory entries given to it, adding
  5579. no new files on its own. To summarize, if you use @command{find} to
  5580. create a list of files to be stored in an archive, use it as follows:
  5581. @smallexample
  5582. @group
  5583. $ @kbd{find @var{dir} @var{tests} | \
  5584. tar -cf @var{archive} -T - --no-recursion}
  5585. @end group
  5586. @end smallexample
  5587. The @option{--no-recursion} option also applies when extracting: it
  5588. causes @command{tar} to extract only the matched directory entries, not
  5589. the files under those directories.
  5590. The @option{--no-recursion} option also affects how globbing patterns
  5591. are interpreted (@pxref{controlling pattern-matching}).
  5592. The @option{--no-recursion} and @option{--recursion} options apply to
  5593. later options and operands, and can be overridden by later occurrences
  5594. of @option{--no-recursion} and @option{--recursion}. For example:
  5595. @smallexample
  5596. $ @kbd{tar -cf jams.tar --no-recursion grape --recursion grape/concord}
  5597. @end smallexample
  5598. @noindent
  5599. creates an archive with one entry for @file{grape}, and the recursive
  5600. contents of @file{grape/concord}, but no entries under @file{grape}
  5601. other than @file{grape/concord}.
  5602. @node one
  5603. @section Crossing File System Boundaries
  5604. @cindex File system boundaries, not crossing
  5605. @UNREVISED
  5606. @command{tar} will normally automatically cross file system boundaries in
  5607. order to archive files which are part of a directory tree. You can
  5608. change this behavior by running @command{tar} and specifying
  5609. @option{--one-file-system}. This option only affects files that are
  5610. archived because they are in a directory that is being archived;
  5611. @command{tar} will still archive files explicitly named on the command line
  5612. or through @option{--files-from}, regardless of where they reside.
  5613. @table @option
  5614. @opindex one-file-system
  5615. @item --one-file-system
  5616. Prevents @command{tar} from crossing file system boundaries when
  5617. archiving. Use in conjunction with any write operation.
  5618. @end table
  5619. The @option{--one-file-system} option causes @command{tar} to modify its
  5620. normal behavior in archiving the contents of directories. If a file in
  5621. a directory is not on the same file system as the directory itself, then
  5622. @command{tar} will not archive that file. If the file is a directory
  5623. itself, @command{tar} will not archive anything beneath it; in other words,
  5624. @command{tar} will not cross mount points.
  5625. This option is useful for making full or incremental archival backups of
  5626. a file system. If this option is used in conjunction with
  5627. @option{--verbose} (@option{-v}), files that are excluded are
  5628. mentioned by name on the standard error.
  5629. @menu
  5630. * directory:: Changing Directory
  5631. * absolute:: Absolute File Names
  5632. @end menu
  5633. @node directory
  5634. @subsection Changing the Working Directory
  5635. @UNREVISED
  5636. @FIXME{need to read over this node now for continuity; i've switched
  5637. things around some.}
  5638. @cindex Changing directory mid-stream
  5639. @cindex Directory, changing mid-stream
  5640. @cindex Working directory, specifying
  5641. To change the working directory in the middle of a list of file names,
  5642. either on the command line or in a file specified using
  5643. @option{--files-from} (@option{-T}), use @option{--directory} (@option{-C}).
  5644. This will change the working directory to the specified directory
  5645. after that point in the list.
  5646. @table @option
  5647. @opindex directory
  5648. @item --directory=@var{directory}
  5649. @itemx -C @var{directory}
  5650. Changes the working directory in the middle of a command line.
  5651. @end table
  5652. For example,
  5653. @smallexample
  5654. $ @kbd{tar -c -f jams.tar grape prune -C food cherry}
  5655. @end smallexample
  5656. @noindent
  5657. will place the files @file{grape} and @file{prune} from the current
  5658. directory into the archive @file{jams.tar}, followed by the file
  5659. @file{cherry} from the directory @file{food}. This option is especially
  5660. useful when you have several widely separated files that you want to
  5661. store in the same archive.
  5662. Note that the file @file{cherry} is recorded in the archive under the
  5663. precise name @file{cherry}, @emph{not} @file{food/cherry}. Thus, the
  5664. archive will contain three files that all appear to have come from the
  5665. same directory; if the archive is extracted with plain @samp{tar
  5666. --extract}, all three files will be written in the current directory.
  5667. Contrast this with the command,
  5668. @smallexample
  5669. $ @kbd{tar -c -f jams.tar grape prune -C food red/cherry}
  5670. @end smallexample
  5671. @noindent
  5672. which records the third file in the archive under the name
  5673. @file{red/cherry} so that, if the archive is extracted using
  5674. @samp{tar --extract}, the third file will be written in a subdirectory
  5675. named @file{orange-colored}.
  5676. You can use the @option{--directory} option to make the archive
  5677. independent of the original name of the directory holding the files.
  5678. The following command places the files @file{/etc/passwd},
  5679. @file{/etc/hosts}, and @file{/lib/libc.a} into the archive
  5680. @file{foo.tar}:
  5681. @smallexample
  5682. $ @kbd{tar -c -f foo.tar -C /etc passwd hosts -C /lib libc.a}
  5683. @end smallexample
  5684. @noindent
  5685. However, the names of the archive members will be exactly what they were
  5686. on the command line: @file{passwd}, @file{hosts}, and @file{libc.a}.
  5687. They will not appear to be related by file name to the original
  5688. directories where those files were located.
  5689. Note that @option{--directory} options are interpreted consecutively. If
  5690. @option{--directory} specifies a relative file name, it is interpreted
  5691. relative to the then current directory, which might not be the same as
  5692. the original current working directory of @command{tar}, due to a previous
  5693. @option{--directory} option.
  5694. When using @option{--files-from} (@pxref{files}), you can put various
  5695. @command{tar} options (including @option{-C}) in the file list. Notice,
  5696. however, that in this case the option and its argument may not be
  5697. separated by whitespace. If you use short option, its argument must
  5698. either follow the option letter immediately, without any intervening
  5699. whitespace, or occupy the next line. Otherwise, if you use long
  5700. option, separate its argument by an equal sign.
  5701. For instance, the file list for the above example will be:
  5702. @smallexample
  5703. @group
  5704. -C
  5705. /etc
  5706. passwd
  5707. hosts
  5708. -C
  5709. /lib
  5710. libc.a
  5711. @end group
  5712. @end smallexample
  5713. @noindent
  5714. To use it, you would invoke @command{tar} as follows:
  5715. @smallexample
  5716. $ @kbd{tar -c -f foo.tar --files-from list}
  5717. @end smallexample
  5718. Notice also that you can only use the short option variant in the file
  5719. list, i.e., always use @option{-C}, not @option{--directory}.
  5720. The interpretation of @option{--directory} is disabled by
  5721. @option{--null} option.
  5722. @node absolute
  5723. @subsection Absolute File Names
  5724. @UNREVISED
  5725. @table @option
  5726. @opindex absolute-names
  5727. @item --absolute-names
  5728. @itemx -P
  5729. Do not strip leading slashes from file names, and permit file names
  5730. containing a @file{..} file name component.
  5731. @end table
  5732. By default, @GNUTAR{} drops a leading @samp{/} on
  5733. input or output, and complains about file names containing a @file{..}
  5734. component. This option turns off this behavior.
  5735. When @command{tar} extracts archive members from an archive, it strips any
  5736. leading slashes (@samp{/}) from the member name. This causes absolute
  5737. member names in the archive to be treated as relative file names. This
  5738. allows you to have such members extracted wherever you want, instead of
  5739. being restricted to extracting the member in the exact directory named
  5740. in the archive. For example, if the archive member has the name
  5741. @file{/etc/passwd}, @command{tar} will extract it as if the name were
  5742. really @file{etc/passwd}.
  5743. File names containing @file{..} can cause problems when extracting, so
  5744. @command{tar} normally warns you about such files when creating an
  5745. archive, and rejects attempts to extracts such files.
  5746. Other @command{tar} programs do not do this. As a result, if you
  5747. create an archive whose member names start with a slash, they will be
  5748. difficult for other people with a non-@GNUTAR{}
  5749. program to use. Therefore, @GNUTAR{} also strips
  5750. leading slashes from member names when putting members into the
  5751. archive. For example, if you ask @command{tar} to add the file
  5752. @file{/bin/ls} to an archive, it will do so, but the member name will
  5753. be @file{bin/ls}.@footnote{A side effect of this is that when
  5754. @option{--create} is used with @option{--verbose} the resulting output
  5755. is not, generally speaking, the same as the one you'd get running
  5756. @kbd{tar --list} command. This may be important if you use some
  5757. scripts for comparing both outputs. @xref{listing member and file names},
  5758. for the information on how to handle this case.}
  5759. If you use the @option{--absolute-names} (@option{-P}) option,
  5760. @command{tar} will do none of these transformations.
  5761. To archive or extract files relative to the root directory, specify
  5762. the @option{--absolute-names} (@option{-P}) option.
  5763. Normally, @command{tar} acts on files relative to the working
  5764. directory---ignoring superior directory names when archiving, and
  5765. ignoring leading slashes when extracting.
  5766. When you specify @option{--absolute-names} (@option{-P}),
  5767. @command{tar} stores file names including all superior directory
  5768. names, and preserves leading slashes. If you only invoked
  5769. @command{tar} from the root directory you would never need the
  5770. @option{--absolute-names} option, but using this option
  5771. may be more convenient than switching to root.
  5772. @FIXME{Should be an example in the tutorial/wizardry section using this
  5773. to transfer files between systems.}
  5774. @FIXME{Is write access an issue?}
  5775. @table @option
  5776. @item --absolute-names
  5777. Preserves full file names (including superior directory names) when
  5778. archiving files. Preserves leading slash when extracting files.
  5779. @end table
  5780. @FIXME{this is still horrible; need to talk with dan on monday.}
  5781. @command{tar} prints out a message about removing the @samp{/} from
  5782. file names. This message appears once per @GNUTAR{}
  5783. invocation. It represents something which ought to be told; ignoring
  5784. what it means can cause very serious surprises, later.
  5785. Some people, nevertheless, do not want to see this message. Wanting to
  5786. play really dangerously, one may of course redirect @command{tar} standard
  5787. error to the sink. For example, under @command{sh}:
  5788. @smallexample
  5789. $ @kbd{tar -c -f archive.tar /home 2> /dev/null}
  5790. @end smallexample
  5791. @noindent
  5792. Another solution, both nicer and simpler, would be to change to
  5793. the @file{/} directory first, and then avoid absolute notation.
  5794. For example:
  5795. @smallexample
  5796. $ @kbd{(cd / && tar -c -f archive.tar home)}
  5797. # @i{or}:
  5798. $ @kbd{tar -c -f archive.tar -C / home}
  5799. @end smallexample
  5800. @include getdate.texi
  5801. @node Formats
  5802. @chapter Controlling the Archive Format
  5803. @cindex Tar archive formats
  5804. Due to historical reasons, there are several formats of tar archives.
  5805. All of them are based on the same principles, but have some subtle
  5806. differences that often make them incompatible with each other.
  5807. GNU tar is able to create and handle archives in a variety of formats.
  5808. The most frequently used formats are (in alphabetical order):
  5809. @table @asis
  5810. @item gnu
  5811. Format used by @GNUTAR{} versions up to 1.13.25. This format derived
  5812. from an early @acronym{POSIX} standard, adding some improvements such as
  5813. sparse file handling and incremental archives. Unfortunately these
  5814. features were implemented in a way incompatible with other archive
  5815. formats.
  5816. Archives in @samp{gnu} format are able to hold pathnames of unlimited
  5817. length.
  5818. @item oldgnu
  5819. Format used by @GNUTAR{} of versions prior to 1.12.
  5820. @item v7
  5821. Archive format, compatible with the V7 implementation of tar. This
  5822. format imposes a number of limitations. The most important of them
  5823. are:
  5824. @enumerate
  5825. @item The maximum length of a file name is limited to 99 characters.
  5826. @item The maximum length of a symbolic link is limited to 99 characters.
  5827. @item It is impossible to store special files (block and character
  5828. devices, fifos etc.)
  5829. @item Maximum value of user or group ID is limited to 2097151 (7777777
  5830. octal)
  5831. @item V7 archives do not contain symbolic ownership information (user
  5832. and group name of the file owner).
  5833. @end enumerate
  5834. This format has traditionally been used by Automake when producing
  5835. Makefiles. This practice will change in the future, in the meantime,
  5836. however this means that projects containing filenames more than 99
  5837. characters long will not be able to use @GNUTAR{} @value{VERSION} and
  5838. Automake prior to 1.9.
  5839. @item ustar
  5840. Archive format defined by @acronym{POSIX.1-1988} specification. It stores
  5841. symbolic ownership information. It is also able to store
  5842. special files. However, it imposes several restrictions as well:
  5843. @enumerate
  5844. @item The maximum length of a file name is limited to 256 characters,
  5845. provided that the filename can be split at directory separator in
  5846. two parts, first of them being at most 155 bytes long. So, in most
  5847. cases the maximum file name length will be shorter than 256
  5848. characters.
  5849. @item The maximum length of a symbolic link name is limited to
  5850. 100 characters.
  5851. @item Maximum size of a file the archive is able to accomodate
  5852. is 8GB
  5853. @item Maximum value of UID/GID is 2097151.
  5854. @item Maximum number of bits in device major and minor numbers is 21.
  5855. @end enumerate
  5856. @item star
  5857. Format used by J@"org Schilling @command{star}
  5858. implementation. @GNUTAR{} is able to read @samp{star} archives but
  5859. currently does not produce them.
  5860. @item posix
  5861. Archive format defined by @acronym{POSIX.1-2001} specification. This is the
  5862. most flexible and feature-rich format. It does not impose any
  5863. restrictions on file sizes or filename lengths. This format is quite
  5864. recent, so not all tar implementations are able to handle it properly.
  5865. However, this format is designed in such a way that any tar
  5866. implementation able to read @samp{ustar} archives will be able to read
  5867. most @samp{posix} archives as well, with the only exception that any
  5868. additional information (such as long file names etc.) will in such
  5869. case be extracted as plain text files along with the files it refers to.
  5870. This archive format will be the default format for future versions
  5871. of @GNUTAR{}.
  5872. @end table
  5873. The following table summarizes the limitations of each of these
  5874. formats:
  5875. @multitable @columnfractions .10 .20 .20 .20 .20
  5876. @headitem Format @tab UID @tab File Size @tab Path Name @tab Devn
  5877. @item gnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
  5878. @item oldgnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
  5879. @item v7 @tab 2097151 @tab 8GB @tab 99 @tab n/a
  5880. @item ustar @tab 2097151 @tab 8GB @tab 256 @tab 21
  5881. @item posix @tab Unlimited @tab Unlimited @tab Unlimited @tab Unlimited
  5882. @end multitable
  5883. The default format for @GNUTAR{} is defined at compilation
  5884. time. You may check it by running @command{tar --help}, and examining
  5885. the last lines of its output. Usually, @GNUTAR{} is configured
  5886. to create archives in @samp{gnu} format, however, future version will
  5887. switch to @samp{posix}.
  5888. @menu
  5889. * Portability:: Making @command{tar} Archives More Portable
  5890. * Compression:: Using Less Space through Compression
  5891. * Attributes:: Handling File Attributes
  5892. * Standard:: The Standard Format
  5893. * Extensions:: @acronym{GNU} Extensions to the Archive Format
  5894. * cpio:: Comparison of @command{tar} and @command{cpio}
  5895. @end menu
  5896. @node Portability
  5897. @section Making @command{tar} Archives More Portable
  5898. Creating a @command{tar} archive on a particular system that is meant to be
  5899. useful later on many other machines and with other versions of @command{tar}
  5900. is more challenging than you might think. @command{tar} archive formats
  5901. have been evolving since the first versions of Unix. Many such formats
  5902. are around, and are not always compatible with each other. This section
  5903. discusses a few problems, and gives some advice about making @command{tar}
  5904. archives more portable.
  5905. One golden rule is simplicity. For example, limit your @command{tar}
  5906. archives to contain only regular files and directories, avoiding
  5907. other kind of special files. Do not attempt to save sparse files or
  5908. contiguous files as such. Let's discuss a few more problems, in turn.
  5909. @FIXME{Discuss GNU extensions (incremental backups, multi-volume
  5910. archives and archive labels) in GNU and PAX formats.}
  5911. @menu
  5912. * Portable Names:: Portable Names
  5913. * dereference:: Symbolic Links
  5914. * old:: Old V7 Archives
  5915. * ustar:: Ustar Archives
  5916. * gnu:: GNU and old GNU format archives.
  5917. * posix:: @acronym{POSIX} archives
  5918. * Checksumming:: Checksumming Problems
  5919. * Large or Negative Values:: Large files, negative time stamps, etc.
  5920. @end menu
  5921. @node Portable Names
  5922. @subsection Portable Names
  5923. Use portable file and member names. A name is portable if it contains
  5924. only ASCII letters and digits, @samp{/}, @samp{.}, @samp{_}, and
  5925. @samp{-}; it cannot be empty, start with @samp{-} or @samp{//}, or
  5926. contain @samp{/-}. Avoid deep directory nesting. For portability to
  5927. old Unix hosts, limit your file name components to 14 characters or
  5928. less.
  5929. If you intend to have your @command{tar} archives to be read under
  5930. MSDOS, you should not rely on case distinction for file names, and you
  5931. might use the @acronym{GNU} @command{doschk} program for helping you
  5932. further diagnosing illegal MSDOS names, which are even more limited
  5933. than System V's.
  5934. @node dereference
  5935. @subsection Symbolic Links
  5936. @cindex File names, using symbolic links
  5937. @cindex Symbolic link as file name
  5938. @opindex dereference
  5939. Normally, when @command{tar} archives a symbolic link, it writes a
  5940. block to the archive naming the target of the link. In that way, the
  5941. @command{tar} archive is a faithful record of the file system contents.
  5942. @option{--dereference} (@option{-h}) is used with @option{--create} (@option{-c}), and causes
  5943. @command{tar} to archive the files symbolic links point to, instead of
  5944. the links themselves. When this option is used, when @command{tar}
  5945. encounters a symbolic link, it will archive the linked-to file,
  5946. instead of simply recording the presence of a symbolic link.
  5947. The name under which the file is stored in the file system is not
  5948. recorded in the archive. To record both the symbolic link name and
  5949. the file name in the system, archive the file under both names. If
  5950. all links were recorded automatically by @command{tar}, an extracted file
  5951. might be linked to a file name that no longer exists in the file
  5952. system.
  5953. If a linked-to file is encountered again by @command{tar} while creating
  5954. the same archive, an entire second copy of it will be stored. (This
  5955. @emph{might} be considered a bug.)
  5956. So, for portable archives, do not archive symbolic links as such,
  5957. and use @option{--dereference} (@option{-h}): many systems do not support
  5958. symbolic links, and moreover, your distribution might be unusable if
  5959. it contains unresolved symbolic links.
  5960. @node old
  5961. @subsection Old V7 Archives
  5962. @cindex Format, old style
  5963. @cindex Old style format
  5964. @cindex Old style archives
  5965. @cindex v7 archive format
  5966. Certain old versions of @command{tar} cannot handle additional
  5967. information recorded by newer @command{tar} programs. To create an
  5968. archive in V7 format (not ANSI), which can be read by these old
  5969. versions, specify the @option{--format=v7} option in
  5970. conjunction with the @option{--create} (@option{-c}) (@command{tar} also
  5971. accepts @option{--portability} or @samp{op-old-archive} for this
  5972. option). When you specify it,
  5973. @command{tar} leaves out information about directories, pipes, fifos,
  5974. contiguous files, and device files, and specifies file ownership by
  5975. group and user IDs instead of group and user names.
  5976. When updating an archive, do not use @option{--format=v7}
  5977. unless the archive was created using this option.
  5978. In most cases, a @emph{new} format archive can be read by an @emph{old}
  5979. @command{tar} program without serious trouble, so this option should
  5980. seldom be needed. On the other hand, most modern @command{tar}s are
  5981. able to read old format archives, so it might be safer for you to
  5982. always use @option{--format=v7} for your distributions.
  5983. @node ustar
  5984. @subsection Ustar Archive Format
  5985. @cindex ustar archive format
  5986. Archive format defined by @acronym{POSIX}.1-1988 specification is called
  5987. @code{ustar}. Although it is more flexible than the V7 format, it
  5988. still has many restrictions (@xref{Formats,ustar}, for the detailed
  5989. description of @code{ustar} format). Along with V7 format,
  5990. @code{ustar} format is a good choice for archives intended to be read
  5991. with other implementations of @command{tar}.
  5992. To create archive in @code{ustar} format, use @option{--format=ustar}
  5993. option in conjunction with the @option{--create} (@option{-c}).
  5994. @node gnu
  5995. @subsection @acronym{GNU} and old @GNUTAR{} format
  5996. @cindex GNU archive format
  5997. @cindex Old GNU archive format
  5998. @GNUTAR{} was based on an early draft of the
  5999. @acronym{POSIX} 1003.1 @code{ustar} standard. @acronym{GNU} extensions to
  6000. @command{tar}, such as the support for file names longer than 100
  6001. characters, use portions of the @command{tar} header record which were
  6002. specified in that @acronym{POSIX} draft as unused. Subsequent changes in
  6003. @acronym{POSIX} have allocated the same parts of the header record for
  6004. other purposes. As a result, @GNUTAR{} format is
  6005. incompatible with the current @acronym{POSIX} specification, and with
  6006. @command{tar} programs that follow it.
  6007. In the majority of cases, @command{tar} will be configured to create
  6008. this format by default. This will change in the future releases, since
  6009. we plan to make @samp{posix} format the default.
  6010. To force creation a @GNUTAR{} archive, use option
  6011. @option{--format=gnu}.
  6012. @node posix
  6013. @subsection @GNUTAR{} and @acronym{POSIX} @command{tar}
  6014. @cindex POSIX archive format
  6015. @cindex PAX archive format
  6016. The version @value{VERSION} of @GNUTAR{} is able
  6017. to read and create archives conforming to @acronym{POSIX.1-2001} standard.
  6018. A @acronym{POSIX} conformant archive will be created if @command{tar}
  6019. was given @option{--format=posix} option.
  6020. @node Checksumming
  6021. @subsection Checksumming Problems
  6022. SunOS and HP-UX @command{tar} fail to accept archives created using
  6023. @GNUTAR{} and containing non-ASCII file names, that
  6024. is, file names having characters with the eight bit set, because they
  6025. use signed checksums, while @GNUTAR{} uses unsigned
  6026. checksums while creating archives, as per @acronym{POSIX} standards. On
  6027. reading, @GNUTAR{} computes both checksums and
  6028. accept any. It is somewhat worrying that a lot of people may go
  6029. around doing backup of their files using faulty (or at least
  6030. non-standard) software, not learning about it until it's time to
  6031. restore their missing files with an incompatible file extractor, or
  6032. vice versa.
  6033. @GNUTAR{} compute checksums both ways, and accept
  6034. any on read, so @acronym{GNU} tar can read Sun tapes even with their
  6035. wrong checksums. @GNUTAR{} produces the standard
  6036. checksum, however, raising incompatibilities with Sun. That is to
  6037. say, @GNUTAR{} has not been modified to
  6038. @emph{produce} incorrect archives to be read by buggy @command{tar}'s.
  6039. I've been told that more recent Sun @command{tar} now read standard
  6040. archives, so maybe Sun did a similar patch, after all?
  6041. The story seems to be that when Sun first imported @command{tar}
  6042. sources on their system, they recompiled it without realizing that
  6043. the checksums were computed differently, because of a change in
  6044. the default signing of @code{char}'s in their compiler. So they
  6045. started computing checksums wrongly. When they later realized their
  6046. mistake, they merely decided to stay compatible with it, and with
  6047. themselves afterwards. Presumably, but I do not really know, HP-UX
  6048. has chosen that their @command{tar} archives to be compatible with Sun's.
  6049. The current standards do not favor Sun @command{tar} format. In any
  6050. case, it now falls on the shoulders of SunOS and HP-UX users to get
  6051. a @command{tar} able to read the good archives they receive.
  6052. @node Large or Negative Values
  6053. @subsection Large or Negative Values
  6054. @cindex large values
  6055. @cindex future time stamps
  6056. @cindex negative time stamps
  6057. @UNREVISED{}
  6058. The above sections suggest to use @samp{oldest possible} archive
  6059. format if in doubt. However, sometimes it is not possible. If you
  6060. attempt to archive a file whose metadata cannot be represented using
  6061. required format, @GNUTAR{} will print error message and ignore such a
  6062. file. You will than have to switch to a format that is able to
  6063. handle such values. The format summary table (@pxref{Formats}) will
  6064. help you to do so.
  6065. In particular, when trying to archive files larger than 8GB or with
  6066. timestamps not in the range 1970-01-01 00:00:00 through 2242-03-16
  6067. 12:56:31 @sc{utc}, you will have to chose between @acronym{GNU} and
  6068. @acronym{POSIX} archive formats. When considering which format to
  6069. choose, bear in mind that the @acronym{GNU} format uses
  6070. two's-complement base-256 notation to store values that do not fit
  6071. into standard @acronym{ustar} range. Such archives can generally be
  6072. read only by a @GNUTAR{} implementation. Moreover, they sometimes
  6073. cannot be correctly restored on another hosts even by @GNUTAR{}. For
  6074. example, using two's complement representation for negative time
  6075. stamps that assumes a signed 32-bit @code{time_t} generates archives
  6076. that are not portable to hosts with differing @code{time_t}
  6077. representations.
  6078. On the other hand, @acronym{POSIX} archives, generally speaking, can
  6079. be extracted by any tar implementation that understands older
  6080. @acronym{ustar} format. The only exception are files larger than 8GB.
  6081. @FIXME{Describe how @acronym{POSIX} archives are extracted by non
  6082. POSIX-aware tars.}
  6083. @node Compression
  6084. @section Using Less Space through Compression
  6085. @menu
  6086. * gzip:: Creating and Reading Compressed Archives
  6087. * sparse:: Archiving Sparse Files
  6088. @end menu
  6089. @node gzip
  6090. @subsection Creating and Reading Compressed Archives
  6091. @cindex Compressed archives
  6092. @cindex Storing archives in compressed format
  6093. @GNUTAR{} is able to create and read compressed archives. It supports
  6094. @command{gzip} and @command{bzip2} compression programs. For backward
  6095. compatibilty, it also supports @command{compress} command, although
  6096. we strongly recommend against using it, since there is a patent
  6097. covering the algorithm it uses and you could be sued for patent
  6098. infringement merely by running @command{compress}! Besides, it is less
  6099. effective than @command{gzip} and @command{bzip2}.
  6100. Creating a compressed archive is simple: you just specify a
  6101. @dfn{compression option} along with the usual archive creation
  6102. commands. The compression option is @option{-z} (@option{--gzip}) to
  6103. create a @command{gzip} compressed archive, @option{-j}
  6104. (@option{--bzip2}) to create a @command{bzip2} compressed archive, and
  6105. @option{-Z} (@option{--compress}) to use @command{compress} program.
  6106. For example:
  6107. @smallexample
  6108. $ @kbd{tar cfz archive.tar.gz .}
  6109. @end smallexample
  6110. Reading compressed archive is even simpler: you don't need to specify
  6111. any additional options as @GNUTAR{} recognizes its format
  6112. automatically. Thus, the following commands will list and extract the
  6113. archive created in previous example:
  6114. @smallexample
  6115. # List the compressed archive
  6116. $ @kbd{tar tf archive.tar.gz}
  6117. # Extract the compressed archive
  6118. $ @kbd{tar xf archive.tar.gz}
  6119. @end smallexample
  6120. The only case when you have to specify a decompression option while
  6121. reading the archive is when reading from a pipe or from a tape drive
  6122. that does not support random access. However, in this case @GNUTAR{}
  6123. will indicate which option you should use. For example:
  6124. @smallexample
  6125. $ @kbd{cat archive.tar.gz | tar tf -}
  6126. tar: Archive is compressed. Use -z option
  6127. tar: Error is not recoverable: exiting now
  6128. @end smallexample
  6129. If you see such diagnostics, just add the suggested option to the
  6130. invocation of @GNUTAR{}:
  6131. @smallexample
  6132. $ @kbd{cat archive.tar.gz | tar tfz -}
  6133. @end smallexample
  6134. Notice also, that there are several restrictions on operations on
  6135. compressed archives. First of all, compressed archives cannot be
  6136. modified, i.e., you cannot update (@option{--update} (@option{-u})) them or delete
  6137. (@option{--delete}) members from them. Likewise, you cannot append
  6138. another @command{tar} archive to a compressed archive using
  6139. @option{--append} (@option{-r})). Secondly, multi-volume archives cannot be
  6140. compressed.
  6141. The following table summarizes compression options used by @GNUTAR{}.
  6142. @table @option
  6143. @opindex gzip
  6144. @opindex ungzip
  6145. @item -z
  6146. @itemx --gzip
  6147. @itemx --ungzip
  6148. Filter the archive through @command{gzip}.
  6149. You can use @option{--gzip} and @option{--gunzip} on physical devices
  6150. (tape drives, etc.) and remote files as well as on normal files; data
  6151. to or from such devices or remote files is reblocked by another copy
  6152. of the @command{tar} program to enforce the specified (or default) record
  6153. size. The default compression parameters are used; if you need to
  6154. override them, set @env{GZIP} environment variable, e.g.:
  6155. @smallexample
  6156. $ @kbd{GZIP=--best tar cfz archive.tar.gz subdir}
  6157. @end smallexample
  6158. @noindent
  6159. Another way would be to avoid the @option{--gzip} (@option{--gunzip}, @option{--ungzip}, @option{-z}) option and run
  6160. @command{gzip} explicitly:
  6161. @smallexample
  6162. $ @kbd{tar cf - subdir | gzip --best -c - > archive.tar.gz}
  6163. @end smallexample
  6164. @cindex corrupted archives
  6165. About corrupted compressed archives: @command{gzip}'ed files have no
  6166. redundancy, for maximum compression. The adaptive nature of the
  6167. compression scheme means that the compression tables are implicitly
  6168. spread all over the archive. If you lose a few blocks, the dynamic
  6169. construction of the compression tables becomes unsynchronized, and there
  6170. is little chance that you could recover later in the archive.
  6171. There are pending suggestions for having a per-volume or per-file
  6172. compression in @GNUTAR{}. This would allow for viewing the
  6173. contents without decompression, and for resynchronizing decompression at
  6174. every volume or file, in case of corrupted archives. Doing so, we might
  6175. lose some compressibility. But this would have make recovering easier.
  6176. So, there are pros and cons. We'll see!
  6177. @opindex bzip2
  6178. @item -j
  6179. @itemx --bzip2
  6180. Filter the archive through @code{bzip2}. Otherwise like @option{--gzip}.
  6181. @opindex compress
  6182. @opindex uncompress
  6183. @item -Z
  6184. @itemx --compress
  6185. @itemx --uncompress
  6186. Filter the archive through @command{compress}. Otherwise like @option{--gzip}.
  6187. The @acronym{GNU} Project recommends you not use
  6188. @command{compress}, because there is a patent covering the algorithm it
  6189. uses. You could be sued for patent infringement merely by running
  6190. @command{compress}.
  6191. @opindex use-compress-program
  6192. @item --use-compress-program=@var{prog}
  6193. Use external compression program @var{prog}. Use this option if you
  6194. have a compression program that @GNUTAR{} does not support. There
  6195. are two requirements to which @var{prog} should comply:
  6196. First, when called without options, it should read data from standard
  6197. input, compress it and output it on standard output.
  6198. Secondly, if called with @option{-d} argument, it should do exactly
  6199. the opposite, i.e., read the compressed data from the standard input
  6200. and produce uncompressed data on the standard output.
  6201. @end table
  6202. @cindex gpg, using with tar
  6203. @cindex gnupg, using with tar
  6204. @cindex Using encrypted archives
  6205. The @option{--use-compress-program} option, in particular, lets you
  6206. implement your own filters, not necessarily dealing with
  6207. compression/decomression. For example, suppose you wish to implement
  6208. PGP encryption on top of compression, using @command{gpg} (@pxref{Top,
  6209. gpg, gpg ---- encryption and signing tool, gpg}). The following
  6210. script does that:
  6211. @smallexample
  6212. @group
  6213. #! /bin/sh
  6214. case $1 in
  6215. -d) gpg --decrypt - | gzip -d -c;;
  6216. '') gzip -c | gpg -s ;;
  6217. *) echo "Unknown option $1">&2; exit 1;;
  6218. esac
  6219. @end group
  6220. @end smallexample
  6221. Suppose you name it @file{gpgz} and save it somewhere in your
  6222. @env{PATH}. Then the following command will create a commpressed
  6223. archive signed with your private key:
  6224. @smallexample
  6225. $ @kbd{tar -cf foo.tar.gpgz --use-compress=gpgz .}
  6226. @end smallexample
  6227. @noindent
  6228. Likewise, the following command will list its contents:
  6229. @smallexample
  6230. $ @kbd{tar -tf foo.tar.gpgz --use-compress=gpgz .}
  6231. @end smallexample
  6232. @ignore
  6233. The above is based on the following discussion:
  6234. I have one question, or maybe it's a suggestion if there isn't a way
  6235. to do it now. I would like to use @option{--gzip}, but I'd also like
  6236. the output to be fed through a program like @acronym{GNU}
  6237. @command{ecc} (actually, right now that's @samp{exactly} what I'd like
  6238. to use :-)), basically adding ECC protection on top of compression.
  6239. It seems as if this should be quite easy to do, but I can't work out
  6240. exactly how to go about it. Of course, I can pipe the standard output
  6241. of @command{tar} through @command{ecc}, but then I lose (though I
  6242. haven't started using it yet, I confess) the ability to have
  6243. @command{tar} use @command{rmt} for it's I/O (I think).
  6244. I think the most straightforward thing would be to let me specify a
  6245. general set of filters outboard of compression (preferably ordered,
  6246. so the order can be automatically reversed on input operations, and
  6247. with the options they require specifiable), but beggars shouldn't be
  6248. choosers and anything you decide on would be fine with me.
  6249. By the way, I like @command{ecc} but if (as the comments say) it can't
  6250. deal with loss of block sync, I'm tempted to throw some time at adding
  6251. that capability. Supposing I were to actually do such a thing and
  6252. get it (apparently) working, do you accept contributed changes to
  6253. utilities like that? (Leigh Clayton @file{loc@@soliton.com}, May 1995).
  6254. Isn't that exactly the role of the
  6255. @option{--use-compress-prog=@var{program}} option?
  6256. I never tried it myself, but I suspect you may want to write a
  6257. @var{prog} script or program able to filter stdin to stdout to
  6258. way you want. It should recognize the @option{-d} option, for when
  6259. extraction is needed rather than creation.
  6260. It has been reported that if one writes compressed data (through the
  6261. @option{--gzip} or @option{--compress} options) to a DLT and tries to use
  6262. the DLT compression mode, the data will actually get bigger and one will
  6263. end up with less space on the tape.
  6264. @end ignore
  6265. @node sparse
  6266. @subsection Archiving Sparse Files
  6267. @cindex Sparse Files
  6268. @UNREVISED
  6269. @table @option
  6270. @opindex sparse
  6271. @item -S
  6272. @itemx --sparse
  6273. Handle sparse files efficiently.
  6274. @end table
  6275. This option causes all files to be put in the archive to be tested for
  6276. sparseness, and handled specially if they are. The @option{--sparse}
  6277. (@option{-S}) option is useful when many @code{dbm} files, for example, are being
  6278. backed up. Using this option dramatically decreases the amount of
  6279. space needed to store such a file.
  6280. In later versions, this option may be removed, and the testing and
  6281. treatment of sparse files may be done automatically with any special
  6282. @acronym{GNU} options. For now, it is an option needing to be specified on
  6283. the command line with the creation or updating of an archive.
  6284. Files in the file system occasionally have ``holes.'' A hole in a file
  6285. is a section of the file's contents which was never written. The
  6286. contents of a hole read as all zeros. On many operating systems,
  6287. actual disk storage is not allocated for holes, but they are counted
  6288. in the length of the file. If you archive such a file, @command{tar}
  6289. could create an archive longer than the original. To have @command{tar}
  6290. attempt to recognize the holes in a file, use @option{--sparse} (@option{-S}). When
  6291. you use this option, then, for any file using less disk space than
  6292. would be expected from its length, @command{tar} searches the file for
  6293. consecutive stretches of zeros. It then records in the archive for
  6294. the file where the consecutive stretches of zeros are, and only
  6295. archives the ``real contents'' of the file. On extraction (using
  6296. @option{--sparse} is not needed on extraction) any such
  6297. files have holes created wherever the continuous stretches of zeros
  6298. were found. Thus, if you use @option{--sparse}, @command{tar} archives
  6299. won't take more space than the original.
  6300. A file is sparse if it contains blocks of zeros whose existence is
  6301. recorded, but that have no space allocated on disk. When you specify
  6302. the @option{--sparse} option in conjunction with the @option{--create}
  6303. (@option{-c}) operation, @command{tar} tests all files for sparseness
  6304. while archiving. If @command{tar} finds a file to be sparse, it uses a
  6305. sparse representation of the file in the archive. @xref{create}, for
  6306. more information about creating archives.
  6307. @option{--sparse} is useful when archiving files, such as dbm files,
  6308. likely to contain many nulls. This option dramatically
  6309. decreases the amount of space needed to store such an archive.
  6310. @quotation
  6311. @strong{Please Note:} Always use @option{--sparse} when performing file
  6312. system backups, to avoid archiving the expanded forms of files stored
  6313. sparsely in the system.
  6314. Even if your system has no sparse files currently, some may be
  6315. created in the future. If you use @option{--sparse} while making file
  6316. system backups as a matter of course, you can be assured the archive
  6317. will never take more space on the media than the files take on disk
  6318. (otherwise, archiving a disk filled with sparse files might take
  6319. hundreds of tapes). @xref{Incremental Dumps}.
  6320. @end quotation
  6321. @command{tar} ignores the @option{--sparse} option when reading an archive.
  6322. @table @option
  6323. @item --sparse
  6324. @itemx -S
  6325. Files stored sparsely in the file system are represented sparsely in
  6326. the archive. Use in conjunction with write operations.
  6327. @end table
  6328. However, users should be well aware that at archive creation time,
  6329. @GNUTAR{} still has to read whole disk file to
  6330. locate the @dfn{holes}, and so, even if sparse files use little space
  6331. on disk and in the archive, they may sometimes require inordinate
  6332. amount of time for reading and examining all-zero blocks of a file.
  6333. Although it works, it's painfully slow for a large (sparse) file, even
  6334. though the resulting tar archive may be small. (One user reports that
  6335. dumping a @file{core} file of over 400 megabytes, but with only about
  6336. 3 megabytes of actual data, took about 9 minutes on a Sun Sparcstation
  6337. ELC, with full CPU utilization.)
  6338. This reading is required in all cases and is not related to the fact
  6339. the @option{--sparse} option is used or not, so by merely @emph{not}
  6340. using the option, you are not saving time@footnote{Well! We should say
  6341. the whole truth, here. When @option{--sparse} is selected while creating
  6342. an archive, the current @command{tar} algorithm requires sparse files to be
  6343. read twice, not once. We hope to develop a new archive format for saving
  6344. sparse files in which one pass will be sufficient.}.
  6345. Programs like @command{dump} do not have to read the entire file; by
  6346. examining the file system directly, they can determine in advance
  6347. exactly where the holes are and thus avoid reading through them. The
  6348. only data it need read are the actual allocated data blocks.
  6349. @GNUTAR{} uses a more portable and straightforward
  6350. archiving approach, it would be fairly difficult that it does
  6351. otherwise. Elizabeth Zwicky writes to @file{comp.unix.internals}, on
  6352. 1990-12-10:
  6353. @quotation
  6354. What I did say is that you cannot tell the difference between a hole and an
  6355. equivalent number of nulls without reading raw blocks. @code{st_blocks} at
  6356. best tells you how many holes there are; it doesn't tell you @emph{where}.
  6357. Just as programs may, conceivably, care what @code{st_blocks} is (care
  6358. to name one that does?), they may also care where the holes are (I have
  6359. no examples of this one either, but it's equally imaginable).
  6360. I conclude from this that good archivers are not portable. One can
  6361. arguably conclude that if you want a portable program, you can in good
  6362. conscience restore files with as many holes as possible, since you can't
  6363. get it right.
  6364. @end quotation
  6365. @node Attributes
  6366. @section Handling File Attributes
  6367. @UNREVISED
  6368. When @command{tar} reads files, it updates their access times. To
  6369. avoid this, use the @option{--atime-preserve[=METHOD]} option, which can either
  6370. reset the access time retroactively or avoid changing it in the first
  6371. place.
  6372. Handling of file attributes
  6373. @table @option
  6374. @opindex atime-preserve
  6375. @item --atime-preserve
  6376. @itemx --atime-preserve=replace
  6377. @itemx --atime-preserve=system
  6378. Preserve the access times of files that are read. This works only for
  6379. files that you own, unless you have superuser privileges.
  6380. @option{--atime-preserve=replace} works on most systems, but it also
  6381. restores the data modification time and updates the status change
  6382. time. Hence it doesn't interact with incremental dumps nicely
  6383. (@pxref{Backups}), and it can set access or data modification times
  6384. incorrectly if other programs access the file while @command{tar} is
  6385. running.
  6386. @option{--atime-preserve=system} avoids changing the access time in
  6387. the first place, if the operating system supports this.
  6388. Unfortunately, this may or may not work on any given operating system
  6389. or file system. If @command{tar} knows for sure it won't work, it
  6390. complains right away.
  6391. Currently @option{--atime-preserve} with no operand defaults to
  6392. @option{--atime-preserve=replace}, but this is intended to change to
  6393. @option{--atime-preserve=system} when the latter is better-supported.
  6394. @opindex touch
  6395. @item -m
  6396. @itemx --touch
  6397. Do not extract data modification time.
  6398. When this option is used, @command{tar} leaves the data modification times
  6399. of the files it extracts as the times when the files were extracted,
  6400. instead of setting it to the times recorded in the archive.
  6401. This option is meaningless with @option{--list} (@option{-t}).
  6402. @opindex same-owner
  6403. @item --same-owner
  6404. Create extracted files with the same ownership they have in the
  6405. archive.
  6406. This is the default behavior for the superuser,
  6407. so this option is meaningful only for non-root users, when @command{tar}
  6408. is executed on those systems able to give files away. This is
  6409. considered as a security flaw by many people, at least because it
  6410. makes quite difficult to correctly account users for the disk space
  6411. they occupy. Also, the @code{suid} or @code{sgid} attributes of
  6412. files are easily and silently lost when files are given away.
  6413. When writing an archive, @command{tar} writes the user id and user name
  6414. separately. If it can't find a user name (because the user id is not
  6415. in @file{/etc/passwd}), then it does not write one. When restoring,
  6416. it tries to look the name (if one was written) up in
  6417. @file{/etc/passwd}. If it fails, then it uses the user id stored in
  6418. the archive instead.
  6419. @opindex no-same-owner
  6420. @item --no-same-owner
  6421. @itemx -o
  6422. Do not attempt to restore ownership when extracting. This is the
  6423. default behavior for ordinary users, so this option has an effect
  6424. only for the superuser.
  6425. @opindex numeric-owner
  6426. @item --numeric-owner
  6427. The @option{--numeric-owner} option allows (ANSI) archives to be written
  6428. without user/group name information or such information to be ignored
  6429. when extracting. It effectively disables the generation and/or use
  6430. of user/group name information. This option forces extraction using
  6431. the numeric ids from the archive, ignoring the names.
  6432. This is useful in certain circumstances, when restoring a backup from
  6433. an emergency floppy with different passwd/group files for example.
  6434. It is otherwise impossible to extract files with the right ownerships
  6435. if the password file in use during the extraction does not match the
  6436. one belonging to the file system(s) being extracted. This occurs,
  6437. for example, if you are restoring your files after a major crash and
  6438. had booted from an emergency floppy with no password file or put your
  6439. disk into another machine to do the restore.
  6440. The numeric ids are @emph{always} saved into @command{tar} archives.
  6441. The identifying names are added at create time when provided by the
  6442. system, unless @option{--old-archive} (@option{-o}) is used. Numeric ids could be
  6443. used when moving archives between a collection of machines using
  6444. a centralized management for attribution of numeric ids to users
  6445. and groups. This is often made through using the NIS capabilities.
  6446. When making a @command{tar} file for distribution to other sites, it
  6447. is sometimes cleaner to use a single owner for all files in the
  6448. distribution, and nicer to specify the write permission bits of the
  6449. files as stored in the archive independently of their actual value on
  6450. the file system. The way to prepare a clean distribution is usually
  6451. to have some Makefile rule creating a directory, copying all needed
  6452. files in that directory, then setting ownership and permissions as
  6453. wanted (there are a lot of possible schemes), and only then making a
  6454. @command{tar} archive out of this directory, before cleaning
  6455. everything out. Of course, we could add a lot of options to
  6456. @GNUTAR{} for fine tuning permissions and ownership.
  6457. This is not the good way, I think. @GNUTAR{} is
  6458. already crowded with options and moreover, the approach just explained
  6459. gives you a great deal of control already.
  6460. @opindex same-permissions, short description
  6461. @opindex preserve-permissions, short description
  6462. @item -p
  6463. @itemx --same-permissions
  6464. @itemx --preserve-permissions
  6465. Extract all protection information.
  6466. This option causes @command{tar} to set the modes (access permissions) of
  6467. extracted files exactly as recorded in the archive. If this option
  6468. is not used, the current @code{umask} setting limits the permissions
  6469. on extracted files. This option is by default enabled when
  6470. @command{tar} is executed by a superuser.
  6471. This option is meaningless with @option{--list} (@option{-t}).
  6472. @opindex preserve
  6473. @item --preserve
  6474. Same as both @option{--same-permissions} and @option{--same-order}.
  6475. The @option{--preserve} option has no equivalent short option name.
  6476. It is equivalent to @option{--same-permissions} plus @option{--same-order}.
  6477. @FIXME{I do not see the purpose of such an option. (Neither I. FP.)
  6478. Neither do I. --Sergey}
  6479. @end table
  6480. @node Standard
  6481. @section Basic Tar Format
  6482. @UNREVISED
  6483. While an archive may contain many files, the archive itself is a
  6484. single ordinary file. Like any other file, an archive file can be
  6485. written to a storage device such as a tape or disk, sent through a
  6486. pipe or over a network, saved on the active file system, or even
  6487. stored in another archive. An archive file is not easy to read or
  6488. manipulate without using the @command{tar} utility or Tar mode in
  6489. @acronym{GNU} Emacs.
  6490. Physically, an archive consists of a series of file entries terminated
  6491. by an end-of-archive entry, which consists of two 512 blocks of zero
  6492. bytes. A file
  6493. entry usually describes one of the files in the archive (an
  6494. @dfn{archive member}), and consists of a file header and the contents
  6495. of the file. File headers contain file names and statistics, checksum
  6496. information which @command{tar} uses to detect file corruption, and
  6497. information about file types.
  6498. Archives are permitted to have more than one member with the same
  6499. member name. One way this situation can occur is if more than one
  6500. version of a file has been stored in the archive. For information
  6501. about adding new versions of a file to an archive, see @ref{update}.
  6502. @FIXME-xref{To learn more about having more than one archive member with the
  6503. same name, see -backup node, when it's written.}
  6504. In addition to entries describing archive members, an archive may
  6505. contain entries which @command{tar} itself uses to store information.
  6506. @xref{label}, for an example of such an archive entry.
  6507. A @command{tar} archive file contains a series of blocks. Each block
  6508. contains @code{BLOCKSIZE} bytes. Although this format may be thought
  6509. of as being on magnetic tape, other media are often used.
  6510. Each file archived is represented by a header block which describes
  6511. the file, followed by zero or more blocks which give the contents
  6512. of the file. At the end of the archive file there are two 512-byte blocks
  6513. filled with binary zeros as an end-of-file marker. A reasonable system
  6514. should write such end-of-file marker at the end of an archive, but
  6515. must not assume that such a block exists when reading an archive. In
  6516. particular @GNUTAR{} always issues a warning if it does not encounter it.
  6517. The blocks may be @dfn{blocked} for physical I/O operations.
  6518. Each record of @var{n} blocks (where @var{n} is set by the
  6519. @option{--blocking-factor=@var{512-size}} (@option{-b @var{512-size}}) option to @command{tar}) is written with a single
  6520. @w{@samp{write ()}} operation. On magnetic tapes, the result of
  6521. such a write is a single record. When writing an archive,
  6522. the last record of blocks should be written at the full size, with
  6523. blocks after the zero block containing all zeros. When reading
  6524. an archive, a reasonable system should properly handle an archive
  6525. whose last record is shorter than the rest, or which contains garbage
  6526. records after a zero block.
  6527. The header block is defined in C as follows. In the @GNUTAR{}
  6528. distribution, this is part of file @file{src/tar.h}:
  6529. @smallexample
  6530. @include header.texi
  6531. @end smallexample
  6532. All characters in header blocks are represented by using 8-bit
  6533. characters in the local variant of ASCII. Each field within the
  6534. structure is contiguous; that is, there is no padding used within
  6535. the structure. Each character on the archive medium is stored
  6536. contiguously.
  6537. Bytes representing the contents of files (after the header block
  6538. of each file) are not translated in any way and are not constrained
  6539. to represent characters in any character set. The @command{tar} format
  6540. does not distinguish text files from binary files, and no translation
  6541. of file contents is performed.
  6542. The @code{name}, @code{linkname}, @code{magic}, @code{uname}, and
  6543. @code{gname} are null-terminated character strings. All other fields
  6544. are zero-filled octal numbers in ASCII. Each numeric field of width
  6545. @var{w} contains @var{w} minus 1 digits, and a null.
  6546. The @code{name} field is the file name of the file, with directory names
  6547. (if any) preceding the file name, separated by slashes.
  6548. @FIXME{how big a name before field overflows?}
  6549. The @code{mode} field provides nine bits specifying file permissions
  6550. and three bits to specify the Set UID, Set GID, and Save Text
  6551. (@dfn{sticky}) modes. Values for these bits are defined above.
  6552. When special permissions are required to create a file with a given
  6553. mode, and the user restoring files from the archive does not hold such
  6554. permissions, the mode bit(s) specifying those special permissions
  6555. are ignored. Modes which are not supported by the operating system
  6556. restoring files from the archive will be ignored. Unsupported modes
  6557. should be faked up when creating or updating an archive; e.g., the
  6558. group permission could be copied from the @emph{other} permission.
  6559. The @code{uid} and @code{gid} fields are the numeric user and group
  6560. ID of the file owners, respectively. If the operating system does
  6561. not support numeric user or group IDs, these fields should be ignored.
  6562. The @code{size} field is the size of the file in bytes; linked files
  6563. are archived with this field specified as zero. @FIXME-xref{Modifiers, in
  6564. particular the @option{--incremental} (@option{-G}) option.}
  6565. The @code{mtime} field is the data modification time of the file at
  6566. the time it was archived. It is the ASCII representation of the octal
  6567. value of the last time the file's contents were modified, represented
  6568. as an integer number of
  6569. seconds since January 1, 1970, 00:00 Coordinated Universal Time.
  6570. The @code{chksum} field is the ASCII representation of the octal value
  6571. of the simple sum of all bytes in the header block. Each 8-bit
  6572. byte in the header is added to an unsigned integer, initialized to
  6573. zero, the precision of which shall be no less than seventeen bits.
  6574. When calculating the checksum, the @code{chksum} field is treated as
  6575. if it were all blanks.
  6576. The @code{typeflag} field specifies the type of file archived. If a
  6577. particular implementation does not recognize or permit the specified
  6578. type, the file will be extracted as if it were a regular file. As this
  6579. action occurs, @command{tar} issues a warning to the standard error.
  6580. The @code{atime} and @code{ctime} fields are used in making incremental
  6581. backups; they store, respectively, the particular file's access and
  6582. status change times.
  6583. The @code{offset} is used by the @option{--multi-volume} (@option{-M}) option, when
  6584. making a multi-volume archive. The offset is number of bytes into
  6585. the file that we need to restart at to continue the file on the next
  6586. tape, i.e., where we store the location that a continued file is
  6587. continued at.
  6588. The following fields were added to deal with sparse files. A file
  6589. is @dfn{sparse} if it takes in unallocated blocks which end up being
  6590. represented as zeros, i.e., no useful data. A test to see if a file
  6591. is sparse is to look at the number blocks allocated for it versus the
  6592. number of characters in the file; if there are fewer blocks allocated
  6593. for the file than would normally be allocated for a file of that
  6594. size, then the file is sparse. This is the method @command{tar} uses to
  6595. detect a sparse file, and once such a file is detected, it is treated
  6596. differently from non-sparse files.
  6597. Sparse files are often @code{dbm} files, or other database-type files
  6598. which have data at some points and emptiness in the greater part of
  6599. the file. Such files can appear to be very large when an @samp{ls
  6600. -l} is done on them, when in truth, there may be a very small amount
  6601. of important data contained in the file. It is thus undesirable
  6602. to have @command{tar} think that it must back up this entire file, as
  6603. great quantities of room are wasted on empty blocks, which can lead
  6604. to running out of room on a tape far earlier than is necessary.
  6605. Thus, sparse files are dealt with so that these empty blocks are
  6606. not written to the tape. Instead, what is written to the tape is a
  6607. description, of sorts, of the sparse file: where the holes are, how
  6608. big the holes are, and how much data is found at the end of the hole.
  6609. This way, the file takes up potentially far less room on the tape,
  6610. and when the file is extracted later on, it will look exactly the way
  6611. it looked beforehand. The following is a description of the fields
  6612. used to handle a sparse file:
  6613. The @code{sp} is an array of @code{struct sparse}. Each @code{struct
  6614. sparse} contains two 12-character strings which represent an offset
  6615. into the file and a number of bytes to be written at that offset.
  6616. The offset is absolute, and not relative to the offset in preceding
  6617. array element.
  6618. The header can hold four of these @code{struct sparse} at the moment;
  6619. if more are needed, they are not stored in the header.
  6620. The @code{isextended} flag is set when an @code{extended_header}
  6621. is needed to deal with a file. Note that this means that this flag
  6622. can only be set when dealing with a sparse file, and it is only set
  6623. in the event that the description of the file will not fit in the
  6624. allotted room for sparse structures in the header. In other words,
  6625. an extended_header is needed.
  6626. The @code{extended_header} structure is used for sparse files which
  6627. need more sparse structures than can fit in the header. The header can
  6628. fit 4 such structures; if more are needed, the flag @code{isextended}
  6629. gets set and the next block is an @code{extended_header}.
  6630. Each @code{extended_header} structure contains an array of 21
  6631. sparse structures, along with a similar @code{isextended} flag
  6632. that the header had. There can be an indeterminate number of such
  6633. @code{extended_header}s to describe a sparse file.
  6634. @table @asis
  6635. @item @code{REGTYPE}
  6636. @itemx @code{AREGTYPE}
  6637. These flags represent a regular file. In order to be compatible
  6638. with older versions of @command{tar}, a @code{typeflag} value of
  6639. @code{AREGTYPE} should be silently recognized as a regular file.
  6640. New archives should be created using @code{REGTYPE}. Also, for
  6641. backward compatibility, @command{tar} treats a regular file whose name
  6642. ends with a slash as a directory.
  6643. @item @code{LNKTYPE}
  6644. This flag represents a file linked to another file, of any type,
  6645. previously archived. Such files are identified in Unix by each
  6646. file having the same device and inode number. The linked-to name is
  6647. specified in the @code{linkname} field with a trailing null.
  6648. @item @code{SYMTYPE}
  6649. This represents a symbolic link to another file. The linked-to name
  6650. is specified in the @code{linkname} field with a trailing null.
  6651. @item @code{CHRTYPE}
  6652. @itemx @code{BLKTYPE}
  6653. These represent character special files and block special files
  6654. respectively. In this case the @code{devmajor} and @code{devminor}
  6655. fields will contain the major and minor device numbers respectively.
  6656. Operating systems may map the device specifications to their own
  6657. local specification, or may ignore the entry.
  6658. @item @code{DIRTYPE}
  6659. This flag specifies a directory or sub-directory. The directory
  6660. name in the @code{name} field should end with a slash. On systems where
  6661. disk allocation is performed on a directory basis, the @code{size} field
  6662. will contain the maximum number of bytes (which may be rounded to
  6663. the nearest disk block allocation unit) which the directory may
  6664. hold. A @code{size} field of zero indicates no such limiting. Systems
  6665. which do not support limiting in this manner should ignore the
  6666. @code{size} field.
  6667. @item @code{FIFOTYPE}
  6668. This specifies a FIFO special file. Note that the archiving of a
  6669. FIFO file archives the existence of this file and not its contents.
  6670. @item @code{CONTTYPE}
  6671. This specifies a contiguous file, which is the same as a normal
  6672. file except that, in operating systems which support it, all its
  6673. space is allocated contiguously on the disk. Operating systems
  6674. which do not allow contiguous allocation should silently treat this
  6675. type as a normal file.
  6676. @item @code{A} @dots{} @code{Z}
  6677. These are reserved for custom implementations. Some of these are
  6678. used in the @acronym{GNU} modified format, as described below.
  6679. @end table
  6680. Other values are reserved for specification in future revisions of
  6681. the P1003 standard, and should not be used by any @command{tar} program.
  6682. The @code{magic} field indicates that this archive was output in
  6683. the P1003 archive format. If this field contains @code{TMAGIC},
  6684. the @code{uname} and @code{gname} fields will contain the ASCII
  6685. representation of the owner and group of the file respectively.
  6686. If found, the user and group IDs are used rather than the values in
  6687. the @code{uid} and @code{gid} fields.
  6688. For references, see ISO/IEC 9945-1:1990 or IEEE Std 1003.1-1990, pages
  6689. 169-173 (section 10.1) for @cite{Archive/Interchange File Format}; and
  6690. IEEE Std 1003.2-1992, pages 380-388 (section 4.48) and pages 936-940
  6691. (section E.4.48) for @cite{pax - Portable archive interchange}.
  6692. @node Extensions
  6693. @section @acronym{GNU} Extensions to the Archive Format
  6694. @UNREVISED
  6695. The @acronym{GNU} format uses additional file types to describe new types of
  6696. files in an archive. These are listed below.
  6697. @table @code
  6698. @item GNUTYPE_DUMPDIR
  6699. @itemx 'D'
  6700. This represents a directory and a list of files created by the
  6701. @option{--incremental} (@option{-G}) option. The @code{size} field gives the total
  6702. size of the associated list of files. Each file name is preceded by
  6703. either a @samp{Y} (the file should be in this archive) or an @samp{N}.
  6704. (The file is a directory, or is not stored in the archive.) Each file
  6705. name is terminated by a null. There is an additional null after the
  6706. last file name.
  6707. @item GNUTYPE_MULTIVOL
  6708. @itemx 'M'
  6709. This represents a file continued from another volume of a multi-volume
  6710. archive created with the @option{--multi-volume} (@option{-M}) option. The original
  6711. type of the file is not given here. The @code{size} field gives the
  6712. maximum size of this piece of the file (assuming the volume does
  6713. not end before the file is written out). The @code{offset} field
  6714. gives the offset from the beginning of the file where this part of
  6715. the file begins. Thus @code{size} plus @code{offset} should equal
  6716. the original size of the file.
  6717. @item GNUTYPE_SPARSE
  6718. @itemx 'S'
  6719. This flag indicates that we are dealing with a sparse file. Note
  6720. that archiving a sparse file requires special operations to find
  6721. holes in the file, which mark the positions of these holes, along
  6722. with the number of bytes of data to be found after the hole.
  6723. @item GNUTYPE_VOLHDR
  6724. @itemx 'V'
  6725. This file type is used to mark the volume header that was given with
  6726. the @option{--label=@var{archive-label}} (@option{-V @var{archive-label}}) option when the archive was created. The @code{name}
  6727. field contains the @code{name} given after the @option{--label=@var{archive-label}} (@option{-V @var{archive-label}}) option.
  6728. The @code{size} field is zero. Only the first file in each volume
  6729. of an archive should have this type.
  6730. @end table
  6731. You may have trouble reading a @acronym{GNU} format archive on a
  6732. non-@acronym{GNU} system if the options @option{--incremental} (@option{-G}),
  6733. @option{--multi-volume} (@option{-M}), @option{--sparse} (@option{-S}), or @option{--label=@var{archive-label}} (@option{-V @var{archive-label}}) were
  6734. used when writing the archive. In general, if @command{tar} does not
  6735. use the @acronym{GNU}-added fields of the header, other versions of
  6736. @command{tar} should be able to read the archive. Otherwise, the
  6737. @command{tar} program will give an error, the most likely one being a
  6738. checksum error.
  6739. @node cpio
  6740. @section Comparison of @command{tar} and @command{cpio}
  6741. @UNREVISED
  6742. @FIXME{Reorganize the following material}
  6743. The @command{cpio} archive formats, like @command{tar}, do have maximum
  6744. pathname lengths. The binary and old ASCII formats have a max path
  6745. length of 256, and the new ASCII and CRC ASCII formats have a max
  6746. path length of 1024. @acronym{GNU} @command{cpio} can read and write archives
  6747. with arbitrary pathname lengths, but other @command{cpio} implementations
  6748. may crash unexplainedly trying to read them.
  6749. @command{tar} handles symbolic links in the form in which it comes in BSD;
  6750. @command{cpio} doesn't handle symbolic links in the form in which it comes
  6751. in System V prior to SVR4, and some vendors may have added symlinks
  6752. to their system without enhancing @command{cpio} to know about them.
  6753. Others may have enhanced it in a way other than the way I did it
  6754. at Sun, and which was adopted by AT&T (and which is, I think, also
  6755. present in the @command{cpio} that Berkeley picked up from AT&T and put
  6756. into a later BSD release---I think I gave them my changes).
  6757. (SVR4 does some funny stuff with @command{tar}; basically, its @command{cpio}
  6758. can handle @command{tar} format input, and write it on output, and it
  6759. probably handles symbolic links. They may not have bothered doing
  6760. anything to enhance @command{tar} as a result.)
  6761. @command{cpio} handles special files; traditional @command{tar} doesn't.
  6762. @command{tar} comes with V7, System III, System V, and BSD source;
  6763. @command{cpio} comes only with System III, System V, and later BSD
  6764. (4.3-tahoe and later).
  6765. @command{tar}'s way of handling multiple hard links to a file can handle
  6766. file systems that support 32-bit inumbers (e.g., the BSD file system);
  6767. @command{cpio}s way requires you to play some games (in its "binary"
  6768. format, i-numbers are only 16 bits, and in its "portable ASCII" format,
  6769. they're 18 bits---it would have to play games with the "file system ID"
  6770. field of the header to make sure that the file system ID/i-number pairs
  6771. of different files were always different), and I don't know which
  6772. @command{cpio}s, if any, play those games. Those that don't might get
  6773. confused and think two files are the same file when they're not, and
  6774. make hard links between them.
  6775. @command{tar}s way of handling multiple hard links to a file places only
  6776. one copy of the link on the tape, but the name attached to that copy
  6777. is the @emph{only} one you can use to retrieve the file; @command{cpio}s
  6778. way puts one copy for every link, but you can retrieve it using any
  6779. of the names.
  6780. @quotation
  6781. What type of check sum (if any) is used, and how is this calculated.
  6782. @end quotation
  6783. See the attached manual pages for @command{tar} and @command{cpio} format.
  6784. @command{tar} uses a checksum which is the sum of all the bytes in the
  6785. @command{tar} header for a file; @command{cpio} uses no checksum.
  6786. @quotation
  6787. If anyone knows why @command{cpio} was made when @command{tar} was present
  6788. at the unix scene,
  6789. @end quotation
  6790. It wasn't. @command{cpio} first showed up in PWB/UNIX 1.0; no
  6791. generally-available version of UNIX had @command{tar} at the time. I don't
  6792. know whether any version that was generally available @emph{within AT&T}
  6793. had @command{tar}, or, if so, whether the people within AT&T who did
  6794. @command{cpio} knew about it.
  6795. On restore, if there is a corruption on a tape @command{tar} will stop at
  6796. that point, while @command{cpio} will skip over it and try to restore the
  6797. rest of the files.
  6798. The main difference is just in the command syntax and header format.
  6799. @command{tar} is a little more tape-oriented in that everything is blocked
  6800. to start on a record boundary.
  6801. @quotation
  6802. Is there any differences between the ability to recover crashed
  6803. archives between the two of them. (Is there any chance of recovering
  6804. crashed archives at all.)
  6805. @end quotation
  6806. Theoretically it should be easier under @command{tar} since the blocking
  6807. lets you find a header with some variation of @samp{dd skip=@var{nn}}.
  6808. However, modern @command{cpio}'s and variations have an option to just
  6809. search for the next file header after an error with a reasonable chance
  6810. of resyncing. However, lots of tape driver software won't allow you to
  6811. continue past a media error which should be the only reason for getting
  6812. out of sync unless a file changed sizes while you were writing the
  6813. archive.
  6814. @quotation
  6815. If anyone knows why @command{cpio} was made when @command{tar} was present
  6816. at the unix scene, please tell me about this too.
  6817. @end quotation
  6818. Probably because it is more media efficient (by not blocking everything
  6819. and using only the space needed for the headers where @command{tar}
  6820. always uses 512 bytes per file header) and it knows how to archive
  6821. special files.
  6822. You might want to look at the freely available alternatives. The
  6823. major ones are @command{afio}, @GNUTAR{}, and
  6824. @command{pax}, each of which have their own extensions with some
  6825. backwards compatibility.
  6826. Sparse files were @command{tar}red as sparse files (which you can
  6827. easily test, because the resulting archive gets smaller, and
  6828. @acronym{GNU} @command{cpio} can no longer read it).
  6829. @node Media
  6830. @chapter Tapes and Other Archive Media
  6831. @UNREVISED
  6832. A few special cases about tape handling warrant more detailed
  6833. description. These special cases are discussed below.
  6834. Many complexities surround the use of @command{tar} on tape drives. Since
  6835. the creation and manipulation of archives located on magnetic tape was
  6836. the original purpose of @command{tar}, it contains many features making
  6837. such manipulation easier.
  6838. Archives are usually written on dismountable media---tape cartridges,
  6839. mag tapes, or floppy disks.
  6840. The amount of data a tape or disk holds depends not only on its size,
  6841. but also on how it is formatted. A 2400 foot long reel of mag tape
  6842. holds 40 megabytes of data when formatted at 1600 bits per inch. The
  6843. physically smaller EXABYTE tape cartridge holds 2.3 gigabytes.
  6844. Magnetic media are re-usable---once the archive on a tape is no longer
  6845. needed, the archive can be erased and the tape or disk used over.
  6846. Media quality does deteriorate with use, however. Most tapes or disks
  6847. should be discarded when they begin to produce data errors. EXABYTE
  6848. tape cartridges should be discarded when they generate an @dfn{error
  6849. count} (number of non-usable bits) of more than 10k.
  6850. Magnetic media are written and erased using magnetic fields, and
  6851. should be protected from such fields to avoid damage to stored data.
  6852. Sticking a floppy disk to a filing cabinet using a magnet is probably
  6853. not a good idea.
  6854. @menu
  6855. * Device:: Device selection and switching
  6856. * Remote Tape Server::
  6857. * Common Problems and Solutions::
  6858. * Blocking:: Blocking
  6859. * Many:: Many archives on one tape
  6860. * Using Multiple Tapes:: Using Multiple Tapes
  6861. * label:: Including a Label in the Archive
  6862. * verify::
  6863. * Write Protection::
  6864. @end menu
  6865. @node Device
  6866. @section Device Selection and Switching
  6867. @UNREVISED
  6868. @table @option
  6869. @item -f [@var{hostname}:]@var{file}
  6870. @itemx --file=[@var{hostname}:]@var{file}
  6871. Use archive file or device @var{file} on @var{hostname}.
  6872. @end table
  6873. This option is used to specify the file name of the archive @command{tar}
  6874. works on.
  6875. If the file name is @samp{-}, @command{tar} reads the archive from standard
  6876. input (when listing or extracting), or writes it to standard output
  6877. (when creating). If the @samp{-} file name is given when updating an
  6878. archive, @command{tar} will read the original archive from its standard
  6879. input, and will write the entire new archive to its standard output.
  6880. If the file name contains a @samp{:}, it is interpreted as
  6881. @samp{hostname:file name}. If the @var{hostname} contains an @dfn{at}
  6882. sign (@samp{@@}), it is treated as @samp{user@@hostname:file name}. In
  6883. either case, @command{tar} will invoke the command @command{rsh} (or
  6884. @command{remsh}) to start up an @command{/usr/libexec/rmt} on the remote
  6885. machine. If you give an alternate login name, it will be given to the
  6886. @command{rsh}.
  6887. Naturally, the remote machine must have an executable
  6888. @command{/usr/libexec/rmt}. This program is free software from the
  6889. University of California, and a copy of the source code can be found
  6890. with the sources for @command{tar}; it's compiled and installed by default.
  6891. The exact path to this utility is determined when configuring the package.
  6892. It is @file{@var{prefix}/libexec/rmt}, where @var{prefix} stands for
  6893. your installation prefix. This location may also be overridden at
  6894. runtime by using @option{rmt-command=@var{command}} option (@xref{Option Summary,
  6895. ---rmt-command}, for detailed description of this option. @xref{Remote
  6896. Tape Server}, for the description of @command{rmt} command).
  6897. If this option is not given, but the environment variable @env{TAPE}
  6898. is set, its value is used; otherwise, old versions of @command{tar}
  6899. used a default archive name (which was picked when @command{tar} was
  6900. compiled). The default is normally set up to be the @dfn{first} tape
  6901. drive or other transportable I/O medium on the system.
  6902. Starting with version 1.11.5, @GNUTAR{} uses
  6903. standard input and standard output as the default device, and I will
  6904. not try anymore supporting automatic device detection at installation
  6905. time. This was failing really in too many cases, it was hopeless.
  6906. This is now completely left to the installer to override standard
  6907. input and standard output for default device, if this seems
  6908. preferable. Further, I think @emph{most} actual usages of
  6909. @command{tar} are done with pipes or disks, not really tapes,
  6910. cartridges or diskettes.
  6911. Some users think that using standard input and output is running
  6912. after trouble. This could lead to a nasty surprise on your screen if
  6913. you forget to specify an output file name---especially if you are going
  6914. through a network or terminal server capable of buffering large amounts
  6915. of output. We had so many bug reports in that area of configuring
  6916. default tapes automatically, and so many contradicting requests, that
  6917. we finally consider the problem to be portably intractable. We could
  6918. of course use something like @samp{/dev/tape} as a default, but this
  6919. is @emph{also} running after various kind of trouble, going from hung
  6920. processes to accidental destruction of real tapes. After having seen
  6921. all this mess, using standard input and output as a default really
  6922. sounds like the only clean choice left, and a very useful one too.
  6923. @GNUTAR{} reads and writes archive in records, I
  6924. suspect this is the main reason why block devices are preferred over
  6925. character devices. Most probably, block devices are more efficient
  6926. too. The installer could also check for @samp{DEFTAPE} in
  6927. @file{<sys/mtio.h>}.
  6928. @table @option
  6929. @opindex force-local, short description
  6930. @item --force-local
  6931. Archive file is local even if it contains a colon.
  6932. @opindex rsh-command
  6933. @item --rsh-command=@var{command}
  6934. Use remote @var{command} instead of @command{rsh}. This option exists
  6935. so that people who use something other than the standard @command{rsh}
  6936. (e.g., a Kerberized @command{rsh}) can access a remote device.
  6937. When this command is not used, the shell command found when
  6938. the @command{tar} program was installed is used instead. This is
  6939. the first found of @file{/usr/ucb/rsh}, @file{/usr/bin/remsh},
  6940. @file{/usr/bin/rsh}, @file{/usr/bsd/rsh} or @file{/usr/bin/nsh}.
  6941. The installer may have overridden this by defining the environment
  6942. variable @env{RSH} @emph{at installation time}.
  6943. @item -[0-7][lmh]
  6944. Specify drive and density.
  6945. @opindex multi-volume, short description
  6946. @item -M
  6947. @itemx --multi-volume
  6948. Create/list/extract multi-volume archive.
  6949. This option causes @command{tar} to write a @dfn{multi-volume} archive---one
  6950. that may be larger than will fit on the medium used to hold it.
  6951. @xref{Multi-Volume Archives}.
  6952. @opindex tape-length, short description
  6953. @item -L @var{num}
  6954. @itemx --tape-length=@var{num}
  6955. Change tape after writing @var{num} x 1024 bytes.
  6956. This option might be useful when your tape drivers do not properly
  6957. detect end of physical tapes. By being slightly conservative on the
  6958. maximum tape length, you might avoid the problem entirely.
  6959. @opindex info-script, short description
  6960. @opindex new-volume-script, short description
  6961. @item -F @var{file}
  6962. @itemx --info-script=@var{file}
  6963. @itemx --new-volume-script=@var{file}
  6964. Execute @file{file} at end of each tape. This implies
  6965. @option{--multi-volume} (@option{-M}). @xref{info-script}, for a detailed
  6966. description of this option.
  6967. @end table
  6968. @node Remote Tape Server
  6969. @section The Remote Tape Server
  6970. @cindex remote tape drive
  6971. @pindex rmt
  6972. In order to access the tape drive on a remote machine, @command{tar}
  6973. uses the remote tape server written at the University of California at
  6974. Berkeley. The remote tape server must be installed as
  6975. @file{@var{prefix}/libexec/rmt} on any machine whose tape drive you
  6976. want to use. @command{tar} calls @command{rmt} by running an
  6977. @command{rsh} or @command{remsh} to the remote machine, optionally
  6978. using a different login name if one is supplied.
  6979. A copy of the source for the remote tape server is provided. It is
  6980. Copyright @copyright{} 1983 by the Regents of the University of
  6981. California, but can be freely distributed. It is compiled and
  6982. installed by default.
  6983. @cindex absolute file names
  6984. Unless you use the @option{--absolute-names} (@option{-P}) option,
  6985. @GNUTAR{} will not allow you to create an archive that contains
  6986. absolute file names (a file name beginning with @samp{/}.) If you try,
  6987. @command{tar} will automatically remove the leading @samp{/} from the
  6988. file names it stores in the archive. It will also type a warning
  6989. message telling you what it is doing.
  6990. When reading an archive that was created with a different
  6991. @command{tar} program, @GNUTAR{} automatically
  6992. extracts entries in the archive which have absolute file names as if
  6993. the file names were not absolute. This is an important feature. A
  6994. visitor here once gave a @command{tar} tape to an operator to restore;
  6995. the operator used Sun @command{tar} instead of @GNUTAR{},
  6996. and the result was that it replaced large portions of
  6997. our @file{/bin} and friends with versions from the tape; needless to
  6998. say, we were unhappy about having to recover the file system from
  6999. backup tapes.
  7000. For example, if the archive contained a file @file{/usr/bin/computoy},
  7001. @GNUTAR{} would extract the file to @file{usr/bin/computoy},
  7002. relative to the current directory. If you want to extract the files in
  7003. an archive to the same absolute names that they had when the archive
  7004. was created, you should do a @samp{cd /} before extracting the files
  7005. from the archive, or you should either use the @option{--absolute-names}
  7006. option, or use the command @samp{tar -C / @dots{}}.
  7007. @cindex Ultrix 3.1 and write failure
  7008. Some versions of Unix (Ultrix 3.1 is known to have this problem),
  7009. can claim that a short write near the end of a tape succeeded,
  7010. when it actually failed. This will result in the -M option not
  7011. working correctly. The best workaround at the moment is to use a
  7012. significantly larger blocking factor than the default 20.
  7013. In order to update an archive, @command{tar} must be able to backspace the
  7014. archive in order to reread or rewrite a record that was just read (or
  7015. written). This is currently possible only on two kinds of files: normal
  7016. disk files (or any other file that can be backspaced with @samp{lseek}),
  7017. and industry-standard 9-track magnetic tape (or any other kind of tape
  7018. that can be backspaced with the @code{MTIOCTOP} @code{ioctl}.
  7019. This means that the @option{--append}, @option{--concatenate}, and
  7020. @option{--delete} commands will not work on any other kind of file.
  7021. Some media simply cannot be backspaced, which means these commands and
  7022. options will never be able to work on them. These non-backspacing
  7023. media include pipes and cartridge tape drives.
  7024. Some other media can be backspaced, and @command{tar} will work on them
  7025. once @command{tar} is modified to do so.
  7026. Archives created with the @option{--multi-volume}, @option{--label}, and
  7027. @option{--incremental} (@option{-G}) options may not be readable by other version
  7028. of @command{tar}. In particular, restoring a file that was split over
  7029. a volume boundary will require some careful work with @command{dd}, if
  7030. it can be done at all. Other versions of @command{tar} may also create
  7031. an empty file whose name is that of the volume header. Some versions
  7032. of @command{tar} may create normal files instead of directories archived
  7033. with the @option{--incremental} (@option{-G}) option.
  7034. @node Common Problems and Solutions
  7035. @section Some Common Problems and their Solutions
  7036. @ifclear PUBLISH
  7037. @format
  7038. errors from system:
  7039. permission denied
  7040. no such file or directory
  7041. not owner
  7042. errors from @command{tar}:
  7043. directory checksum error
  7044. header format error
  7045. errors from media/system:
  7046. i/o error
  7047. device busy
  7048. @end format
  7049. @end ifclear
  7050. @node Blocking
  7051. @section Blocking
  7052. @UNREVISED
  7053. @dfn{Block} and @dfn{record} terminology is rather confused, and it
  7054. is also confusing to the expert reader. On the other hand, readers
  7055. who are new to the field have a fresh mind, and they may safely skip
  7056. the next two paragraphs, as the remainder of this manual uses those
  7057. two terms in a quite consistent way.
  7058. John Gilmore, the writer of the public domain @command{tar} from which
  7059. @GNUTAR{} was originally derived, wrote (June 1995):
  7060. @quotation
  7061. The nomenclature of tape drives comes from IBM, where I believe
  7062. they were invented for the IBM 650 or so. On IBM mainframes, what
  7063. is recorded on tape are tape blocks. The logical organization of
  7064. data is into records. There are various ways of putting records into
  7065. blocks, including @code{F} (fixed sized records), @code{V} (variable
  7066. sized records), @code{FB} (fixed blocked: fixed size records, @var{n}
  7067. to a block), @code{VB} (variable size records, @var{n} to a block),
  7068. @code{VSB} (variable spanned blocked: variable sized records that can
  7069. occupy more than one block), etc. The @code{JCL} @samp{DD RECFORM=}
  7070. parameter specified this to the operating system.
  7071. The Unix man page on @command{tar} was totally confused about this.
  7072. When I wrote @code{PD TAR}, I used the historically correct terminology
  7073. (@command{tar} writes data records, which are grouped into blocks).
  7074. It appears that the bogus terminology made it into @acronym{POSIX} (no surprise
  7075. here), and now Fran@,{c}ois has migrated that terminology back
  7076. into the source code too.
  7077. @end quotation
  7078. The term @dfn{physical block} means the basic transfer chunk from or
  7079. to a device, after which reading or writing may stop without anything
  7080. being lost. In this manual, the term @dfn{block} usually refers to
  7081. a disk physical block, @emph{assuming} that each disk block is 512
  7082. bytes in length. It is true that some disk devices have different
  7083. physical blocks, but @command{tar} ignore these differences in its own
  7084. format, which is meant to be portable, so a @command{tar} block is always
  7085. 512 bytes in length, and @dfn{block} always mean a @command{tar} block.
  7086. The term @dfn{logical block} often represents the basic chunk of
  7087. allocation of many disk blocks as a single entity, which the operating
  7088. system treats somewhat atomically; this concept is only barely used
  7089. in @GNUTAR{}.
  7090. The term @dfn{physical record} is another way to speak of a physical
  7091. block, those two terms are somewhat interchangeable. In this manual,
  7092. the term @dfn{record} usually refers to a tape physical block,
  7093. @emph{assuming} that the @command{tar} archive is kept on magnetic tape.
  7094. It is true that archives may be put on disk or used with pipes,
  7095. but nevertheless, @command{tar} tries to read and write the archive one
  7096. @dfn{record} at a time, whatever the medium in use. One record is made
  7097. up of an integral number of blocks, and this operation of putting many
  7098. disk blocks into a single tape block is called @dfn{reblocking}, or
  7099. more simply, @dfn{blocking}. The term @dfn{logical record} refers to
  7100. the logical organization of many characters into something meaningful
  7101. to the application. The term @dfn{unit record} describes a small set
  7102. of characters which are transmitted whole to or by the application,
  7103. and often refers to a line of text. Those two last terms are unrelated
  7104. to what we call a @dfn{record} in @GNUTAR{}.
  7105. When writing to tapes, @command{tar} writes the contents of the archive
  7106. in chunks known as @dfn{records}. To change the default blocking
  7107. factor, use the @option{--blocking-factor=@var{512-size}} (@option{-b
  7108. @var{512-size}}) option. Each record will then be composed of
  7109. @var{512-size} blocks. (Each @command{tar} block is 512 bytes.
  7110. @xref{Standard}.) Each file written to the archive uses at least one
  7111. full record. As a result, using a larger record size can result in
  7112. more wasted space for small files. On the other hand, a larger record
  7113. size can often be read and written much more efficiently.
  7114. Further complicating the problem is that some tape drives ignore the
  7115. blocking entirely. For these, a larger record size can still improve
  7116. performance (because the software layers above the tape drive still
  7117. honor the blocking), but not as dramatically as on tape drives that
  7118. honor blocking.
  7119. When reading an archive, @command{tar} can usually figure out the
  7120. record size on itself. When this is the case, and a non-standard
  7121. record size was used when the archive was created, @command{tar} will
  7122. print a message about a non-standard blocking factor, and then operate
  7123. normally. On some tape devices, however, @command{tar} cannot figure
  7124. out the record size itself. On most of those, you can specify a
  7125. blocking factor (with @option{--blocking-factor}) larger than the
  7126. actual blocking factor, and then use the @option{--read-full-records}
  7127. (@option{-B}) option. (If you specify a blocking factor with
  7128. @option{--blocking-factor} and don't use the
  7129. @option{--read-full-records} option, then @command{tar} will not
  7130. attempt to figure out the recording size itself.) On some devices,
  7131. you must always specify the record size exactly with
  7132. @option{--blocking-factor} when reading, because @command{tar} cannot
  7133. figure it out. In any case, use @option{--list} (@option{-t}) before
  7134. doing any extractions to see whether @command{tar} is reading the archive
  7135. correctly.
  7136. @command{tar} blocks are all fixed size (512 bytes), and its scheme for
  7137. putting them into records is to put a whole number of them (one or
  7138. more) into each record. @command{tar} records are all the same size;
  7139. at the end of the file there's a block containing all zeros, which
  7140. is how you tell that the remainder of the last record(s) are garbage.
  7141. In a standard @command{tar} file (no options), the block size is 512
  7142. and the record size is 10240, for a blocking factor of 20. What the
  7143. @option{--blocking-factor} option does is sets the blocking factor,
  7144. changing the record size while leaving the block size at 512 bytes.
  7145. 20 was fine for ancient 800 or 1600 bpi reel-to-reel tape drives;
  7146. most tape drives these days prefer much bigger records in order to
  7147. stream and not waste tape. When writing tapes for myself, some tend
  7148. to use a factor of the order of 2048, say, giving a record size of
  7149. around one megabyte.
  7150. If you use a blocking factor larger than 20, older @command{tar}
  7151. programs might not be able to read the archive, so we recommend this
  7152. as a limit to use in practice. @GNUTAR{}, however,
  7153. will support arbitrarily large record sizes, limited only by the
  7154. amount of virtual memory or the physical characteristics of the tape
  7155. device.
  7156. @menu
  7157. * Format Variations:: Format Variations
  7158. * Blocking Factor:: The Blocking Factor of an Archive
  7159. @end menu
  7160. @node Format Variations
  7161. @subsection Format Variations
  7162. @cindex Format Parameters
  7163. @cindex Format Options
  7164. @cindex Options, archive format specifying
  7165. @cindex Options, format specifying
  7166. @UNREVISED
  7167. Format parameters specify how an archive is written on the archive
  7168. media. The best choice of format parameters will vary depending on
  7169. the type and number of files being archived, and on the media used to
  7170. store the archive.
  7171. To specify format parameters when accessing or creating an archive,
  7172. you can use the options described in the following sections.
  7173. If you do not specify any format parameters, @command{tar} uses
  7174. default parameters. You cannot modify a compressed archive.
  7175. If you create an archive with the @option{--blocking-factor} option
  7176. specified (@pxref{Blocking Factor}), you must specify that
  7177. blocking-factor when operating on the archive. @xref{Formats}, for other
  7178. examples of format parameter considerations.
  7179. @node Blocking Factor
  7180. @subsection The Blocking Factor of an Archive
  7181. @cindex Blocking Factor
  7182. @cindex Record Size
  7183. @cindex Number of blocks per record
  7184. @cindex Number of bytes per record
  7185. @cindex Bytes per record
  7186. @cindex Blocks per record
  7187. @UNREVISED
  7188. @opindex blocking-factor
  7189. The data in an archive is grouped into blocks, which are 512 bytes.
  7190. Blocks are read and written in whole number multiples called
  7191. @dfn{records}. The number of blocks in a record (ie. the size of a
  7192. record in units of 512 bytes) is called the @dfn{blocking factor}.
  7193. The @option{--blocking-factor=@var{512-size}} (@option{-b
  7194. @var{512-size}}) option specifies the blocking factor of an archive.
  7195. The default blocking factor is typically 20 (i.e., 10240 bytes), but
  7196. can be specified at installation. To find out the blocking factor of
  7197. an existing archive, use @samp{tar --list --file=@var{archive-name}}.
  7198. This may not work on some devices.
  7199. Records are separated by gaps, which waste space on the archive media.
  7200. If you are archiving on magnetic tape, using a larger blocking factor
  7201. (and therefore larger records) provides faster throughput and allows you
  7202. to fit more data on a tape (because there are fewer gaps). If you are
  7203. archiving on cartridge, a very large blocking factor (say 126 or more)
  7204. greatly increases performance. A smaller blocking factor, on the other
  7205. hand, may be useful when archiving small files, to avoid archiving lots
  7206. of nulls as @command{tar} fills out the archive to the end of the record.
  7207. In general, the ideal record size depends on the size of the
  7208. inter-record gaps on the tape you are using, and the average size of the
  7209. files you are archiving. @xref{create}, for information on
  7210. writing archives.
  7211. @FIXME{Need example of using a cartridge with blocking factor=126 or more.}
  7212. Archives with blocking factors larger than 20 cannot be read
  7213. by very old versions of @command{tar}, or by some newer versions
  7214. of @command{tar} running on old machines with small address spaces.
  7215. With @GNUTAR{}, the blocking factor of an archive is limited
  7216. only by the maximum record size of the device containing the archive,
  7217. or by the amount of available virtual memory.
  7218. Also, on some systems, not using adequate blocking factors, as sometimes
  7219. imposed by the device drivers, may yield unexpected diagnostics. For
  7220. example, this has been reported:
  7221. @smallexample
  7222. Cannot write to /dev/dlt: Invalid argument
  7223. @end smallexample
  7224. @noindent
  7225. In such cases, it sometimes happen that the @command{tar} bundled by
  7226. the system is aware of block size idiosyncrasies, while @GNUTAR{}
  7227. requires an explicit specification for the block size,
  7228. which it cannot guess. This yields some people to consider
  7229. @GNUTAR{} is misbehaving, because by comparison,
  7230. @cite{the bundle @command{tar} works OK}. Adding @w{@kbd{-b 256}},
  7231. for example, might resolve the problem.
  7232. If you use a non-default blocking factor when you create an archive, you
  7233. must specify the same blocking factor when you modify that archive. Some
  7234. archive devices will also require you to specify the blocking factor when
  7235. reading that archive, however this is not typically the case. Usually, you
  7236. can use @option{--list} (@option{-t}) without specifying a blocking factor---@command{tar}
  7237. reports a non-default record size and then lists the archive members as
  7238. it would normally. To extract files from an archive with a non-standard
  7239. blocking factor (particularly if you're not sure what the blocking factor
  7240. is), you can usually use the @option{--read-full-records} (@option{-B}) option while
  7241. specifying a blocking factor larger then the blocking factor of the archive
  7242. (ie. @samp{tar --extract --read-full-records --blocking-factor=300}.
  7243. @xref{list}, for more information on the @option{--list} (@option{-t})
  7244. operation. @xref{Reading}, for a more detailed explanation of that option.
  7245. @table @option
  7246. @item --blocking-factor=@var{number}
  7247. @itemx -b @var{number}
  7248. Specifies the blocking factor of an archive. Can be used with any
  7249. operation, but is usually not necessary with @option{--list} (@option{-t}).
  7250. @end table
  7251. Device blocking
  7252. @table @option
  7253. @item -b @var{blocks}
  7254. @itemx --blocking-factor=@var{blocks}
  7255. Set record size to @math{@var{blocks} * 512} bytes.
  7256. This option is used to specify a @dfn{blocking factor} for the archive.
  7257. When reading or writing the archive, @command{tar}, will do reads and writes
  7258. of the archive in records of @math{@var{block}*512} bytes. This is true
  7259. even when the archive is compressed. Some devices requires that all
  7260. write operations be a multiple of a certain size, and so, @command{tar}
  7261. pads the archive out to the next record boundary.
  7262. The default blocking factor is set when @command{tar} is compiled, and is
  7263. typically 20. Blocking factors larger than 20 cannot be read by very
  7264. old versions of @command{tar}, or by some newer versions of @command{tar}
  7265. running on old machines with small address spaces.
  7266. With a magnetic tape, larger records give faster throughput and fit
  7267. more data on a tape (because there are fewer inter-record gaps).
  7268. If the archive is in a disk file or a pipe, you may want to specify
  7269. a smaller blocking factor, since a large one will result in a large
  7270. number of null bytes at the end of the archive.
  7271. When writing cartridge or other streaming tapes, a much larger
  7272. blocking factor (say 126 or more) will greatly increase performance.
  7273. However, you must specify the same blocking factor when reading or
  7274. updating the archive.
  7275. Apparently, Exabyte drives have a physical block size of 8K bytes.
  7276. If we choose our blocksize as a multiple of 8k bytes, then the problem
  7277. seems to disappear. Id est, we are using block size of 112 right
  7278. now, and we haven't had the problem since we switched@dots{}
  7279. With @GNUTAR{} the blocking factor is limited only
  7280. by the maximum record size of the device containing the archive, or by
  7281. the amount of available virtual memory.
  7282. However, deblocking or reblocking is virtually avoided in a special
  7283. case which often occurs in practice, but which requires all the
  7284. following conditions to be simultaneously true:
  7285. @itemize @bullet
  7286. @item
  7287. the archive is subject to a compression option,
  7288. @item
  7289. the archive is not handled through standard input or output, nor
  7290. redirected nor piped,
  7291. @item
  7292. the archive is directly handled to a local disk, instead of any special
  7293. device,
  7294. @item
  7295. @option{--blocking-factor} is not explicitly specified on the @command{tar}
  7296. invocation.
  7297. @end itemize
  7298. If the output goes directly to a local disk, and not through
  7299. stdout, then the last write is not extended to a full record size.
  7300. Otherwise, reblocking occurs. Here are a few other remarks on this
  7301. topic:
  7302. @itemize @bullet
  7303. @item
  7304. @command{gzip} will complain about trailing garbage if asked to
  7305. uncompress a compressed archive on tape, there is an option to turn
  7306. the message off, but it breaks the regularity of simply having to use
  7307. @samp{@var{prog} -d} for decompression. It would be nice if gzip was
  7308. silently ignoring any number of trailing zeros. I'll ask Jean-loup
  7309. Gailly, by sending a copy of this message to him.
  7310. @item
  7311. @command{compress} does not show this problem, but as Jean-loup pointed
  7312. out to Michael, @samp{compress -d} silently adds garbage after
  7313. the result of decompression, which tar ignores because it already
  7314. recognized its end-of-file indicator. So this bug may be safely
  7315. ignored.
  7316. @item
  7317. @samp{gzip -d -q} will be silent about the trailing zeros indeed,
  7318. but will still return an exit status of 2 which tar reports in turn.
  7319. @command{tar} might ignore the exit status returned, but I hate doing
  7320. that, as it weakens the protection @command{tar} offers users against
  7321. other possible problems at decompression time. If @command{gzip} was
  7322. silently skipping trailing zeros @emph{and} also avoiding setting the
  7323. exit status in this innocuous case, that would solve this situation.
  7324. @item
  7325. @command{tar} should become more solid at not stopping to read a pipe at
  7326. the first null block encountered. This inelegantly breaks the pipe.
  7327. @command{tar} should rather drain the pipe out before exiting itself.
  7328. @end itemize
  7329. @opindex ignore-zeros, short description
  7330. @item -i
  7331. @itemx --ignore-zeros
  7332. Ignore blocks of zeros in archive (means EOF).
  7333. The @option{--ignore-zeros} (@option{-i}) option causes @command{tar} to ignore blocks
  7334. of zeros in the archive. Normally a block of zeros indicates the
  7335. end of the archive, but when reading a damaged archive, or one which
  7336. was created by concatenating several archives together, this option
  7337. allows @command{tar} to read the entire archive. This option is not on
  7338. by default because many versions of @command{tar} write garbage after
  7339. the zeroed blocks.
  7340. Note that this option causes @command{tar} to read to the end of the
  7341. archive file, which may sometimes avoid problems when multiple files
  7342. are stored on a single physical tape.
  7343. @opindex read-full-records, short description
  7344. @item -B
  7345. @itemx --read-full-records
  7346. Reblock as we read (for reading 4.2BSD pipes).
  7347. If @option{--read-full-records} is used, @command{tar}
  7348. will not panic if an attempt to read a record from the archive does
  7349. not return a full record. Instead, @command{tar} will keep reading
  7350. until it has obtained a full
  7351. record.
  7352. This option is turned on by default when @command{tar} is reading
  7353. an archive from standard input, or from a remote machine. This is
  7354. because on BSD Unix systems, a read of a pipe will return however
  7355. much happens to be in the pipe, even if it is less than @command{tar}
  7356. requested. If this option was not used, @command{tar} would fail as
  7357. soon as it read an incomplete record from the pipe.
  7358. This option is also useful with the commands for updating an archive.
  7359. @end table
  7360. Tape blocking
  7361. @FIXME{Appropriate options should be moved here from elsewhere.}
  7362. @cindex blocking factor
  7363. @cindex tape blocking
  7364. When handling various tapes or cartridges, you have to take care of
  7365. selecting a proper blocking, that is, the number of disk blocks you
  7366. put together as a single tape block on the tape, without intervening
  7367. tape gaps. A @dfn{tape gap} is a small landing area on the tape
  7368. with no information on it, used for decelerating the tape to a
  7369. full stop, and for later regaining the reading or writing speed.
  7370. When the tape driver starts reading a record, the record has to
  7371. be read whole without stopping, as a tape gap is needed to stop the
  7372. tape motion without loosing information.
  7373. @cindex Exabyte blocking
  7374. @cindex DAT blocking
  7375. Using higher blocking (putting more disk blocks per tape block) will use
  7376. the tape more efficiently as there will be less tape gaps. But reading
  7377. such tapes may be more difficult for the system, as more memory will be
  7378. required to receive at once the whole record. Further, if there is a
  7379. reading error on a huge record, this is less likely that the system will
  7380. succeed in recovering the information. So, blocking should not be too
  7381. low, nor it should be too high. @command{tar} uses by default a blocking of
  7382. 20 for historical reasons, and it does not really matter when reading or
  7383. writing to disk. Current tape technology would easily accommodate higher
  7384. blockings. Sun recommends a blocking of 126 for Exabytes and 96 for DATs.
  7385. We were told that for some DLT drives, the blocking should be a multiple
  7386. of 4Kb, preferably 64Kb (@w{@kbd{-b 128}}) or 256 for decent performance.
  7387. Other manufacturers may use different recommendations for the same tapes.
  7388. This might also depends of the buffering techniques used inside modern
  7389. tape controllers. Some imposes a minimum blocking, or a maximum blocking.
  7390. Others request blocking to be some exponent of two.
  7391. So, there is no fixed rule for blocking. But blocking at read time
  7392. should ideally be the same as blocking used at write time. At one place
  7393. I know, with a wide variety of equipment, they found it best to use a
  7394. blocking of 32 to guarantee that their tapes are fully interchangeable.
  7395. I was also told that, for recycled tapes, prior erasure (by the same
  7396. drive unit that will be used to create the archives) sometimes lowers
  7397. the error rates observed at rewriting time.
  7398. I might also use @option{--number-blocks} instead of
  7399. @option{--block-number}, so @option{--block} will then expand to
  7400. @option{--blocking-factor} unambiguously.
  7401. @node Many
  7402. @section Many Archives on One Tape
  7403. @FIXME{Appropriate options should be moved here from elsewhere.}
  7404. @findex ntape @r{device}
  7405. Most tape devices have two entries in the @file{/dev} directory, or
  7406. entries that come in pairs, which differ only in the minor number for
  7407. this device. Let's take for example @file{/dev/tape}, which often
  7408. points to the only or usual tape device of a given system. There might
  7409. be a corresponding @file{/dev/nrtape} or @file{/dev/ntape}. The simpler
  7410. name is the @emph{rewinding} version of the device, while the name
  7411. having @samp{nr} in it is the @emph{no rewinding} version of the same
  7412. device.
  7413. A rewinding tape device will bring back the tape to its beginning point
  7414. automatically when this device is opened or closed. Since @command{tar}
  7415. opens the archive file before using it and closes it afterwards, this
  7416. means that a simple:
  7417. @smallexample
  7418. $ @kbd{tar cf /dev/tape @var{directory}}
  7419. @end smallexample
  7420. @noindent
  7421. will reposition the tape to its beginning both prior and after saving
  7422. @var{directory} contents to it, thus erasing prior tape contents and
  7423. making it so that any subsequent write operation will destroy what has
  7424. just been saved.
  7425. @cindex tape positioning
  7426. So, a rewinding device is normally meant to hold one and only one file.
  7427. If you want to put more than one @command{tar} archive on a given tape, you
  7428. will need to avoid using the rewinding version of the tape device. You
  7429. will also have to pay special attention to tape positioning. Errors in
  7430. positioning may overwrite the valuable data already on your tape. Many
  7431. people, burnt by past experiences, will only use rewinding devices and
  7432. limit themselves to one file per tape, precisely to avoid the risk of
  7433. such errors. Be fully aware that writing at the wrong position on a
  7434. tape loses all information past this point and most probably until the
  7435. end of the tape, and this destroyed information @emph{cannot} be
  7436. recovered.
  7437. To save @var{directory-1} as a first archive at the beginning of a
  7438. tape, and leave that tape ready for a second archive, you should use:
  7439. @smallexample
  7440. $ @kbd{mt -f /dev/nrtape rewind}
  7441. $ @kbd{tar cf /dev/nrtape @var{directory-1}}
  7442. @end smallexample
  7443. @cindex tape marks
  7444. @dfn{Tape marks} are special magnetic patterns written on the tape
  7445. media, which are later recognizable by the reading hardware. These
  7446. marks are used after each file, when there are many on a single tape.
  7447. An empty file (that is to say, two tape marks in a row) signal the
  7448. logical end of the tape, after which no file exist. Usually,
  7449. non-rewinding tape device drivers will react to the close request issued
  7450. by @command{tar} by first writing two tape marks after your archive, and by
  7451. backspacing over one of these. So, if you remove the tape at that time
  7452. from the tape drive, it is properly terminated. But if you write
  7453. another file at the current position, the second tape mark will be
  7454. erased by the new information, leaving only one tape mark between files.
  7455. So, you may now save @var{directory-2} as a second archive after the
  7456. first on the same tape by issuing the command:
  7457. @smallexample
  7458. $ @kbd{tar cf /dev/nrtape @var{directory-2}}
  7459. @end smallexample
  7460. @noindent
  7461. and so on for all the archives you want to put on the same tape.
  7462. Another usual case is that you do not write all the archives the same
  7463. day, and you need to remove and store the tape between two archive
  7464. sessions. In general, you must remember how many files are already
  7465. saved on your tape. Suppose your tape already has 16 files on it, and
  7466. that you are ready to write the 17th. You have to take care of skipping
  7467. the first 16 tape marks before saving @var{directory-17}, say, by using
  7468. these commands:
  7469. @smallexample
  7470. $ @kbd{mt -f /dev/nrtape rewind}
  7471. $ @kbd{mt -f /dev/nrtape fsf 16}
  7472. $ @kbd{tar cf /dev/nrtape @var{directory-17}}
  7473. @end smallexample
  7474. In all the previous examples, we put aside blocking considerations, but
  7475. you should do the proper things for that as well. @xref{Blocking}.
  7476. @menu
  7477. * Tape Positioning:: Tape Positions and Tape Marks
  7478. * mt:: The @command{mt} Utility
  7479. @end menu
  7480. @node Tape Positioning
  7481. @subsection Tape Positions and Tape Marks
  7482. @UNREVISED
  7483. Just as archives can store more than one file from the file system,
  7484. tapes can store more than one archive file. To keep track of where
  7485. archive files (or any other type of file stored on tape) begin and
  7486. end, tape archive devices write magnetic @dfn{tape marks} on the
  7487. archive media. Tape drives write one tape mark between files,
  7488. two at the end of all the file entries.
  7489. If you think of data as a series of records "rrrr"'s, and tape marks as
  7490. "*"'s, a tape might look like the following:
  7491. @smallexample
  7492. rrrr*rrrrrr*rrrrr*rr*rrrrr**-------------------------
  7493. @end smallexample
  7494. Tape devices read and write tapes using a read/write @dfn{tape
  7495. head}---a physical part of the device which can only access one
  7496. point on the tape at a time. When you use @command{tar} to read or
  7497. write archive data from a tape device, the device will begin reading
  7498. or writing from wherever on the tape the tape head happens to be,
  7499. regardless of which archive or what part of the archive the tape
  7500. head is on. Before writing an archive, you should make sure that no
  7501. data on the tape will be overwritten (unless it is no longer needed).
  7502. Before reading an archive, you should make sure the tape head is at
  7503. the beginning of the archive you want to read. You can do it manually
  7504. via @code{mt} utility (@pxref{mt}). The @code{restore} script does
  7505. that automatically (@pxref{Scripted Restoration}).
  7506. If you want to add new archive file entries to a tape, you should
  7507. advance the tape to the end of the existing file entries, backspace
  7508. over the last tape mark, and write the new archive file. If you were
  7509. to add two archives to the example above, the tape might look like the
  7510. following:
  7511. @smallexample
  7512. rrrr*rrrrrr*rrrrr*rr*rrrrr*rrr*rrrr**----------------
  7513. @end smallexample
  7514. @node mt
  7515. @subsection The @command{mt} Utility
  7516. @UNREVISED
  7517. @FIXME{Is it true that this only works on non-block devices?
  7518. should explain the difference, (fixed or variable).}
  7519. @xref{Blocking Factor}.
  7520. You can use the @command{mt} utility to advance or rewind a tape past a
  7521. specified number of archive files on the tape. This will allow you
  7522. to move to the beginning of an archive before extracting or reading
  7523. it, or to the end of all the archives before writing a new one.
  7524. @FIXME{Why isn't there an "advance 'til you find two tape marks
  7525. together"?}
  7526. The syntax of the @command{mt} command is:
  7527. @smallexample
  7528. @kbd{mt [-f @var{tapename}] @var{operation} [@var{number}]}
  7529. @end smallexample
  7530. where @var{tapename} is the name of the tape device, @var{number} is
  7531. the number of times an operation is performed (with a default of one),
  7532. and @var{operation} is one of the following:
  7533. @FIXME{is there any use for record operations?}
  7534. @table @option
  7535. @item eof
  7536. @itemx weof
  7537. Writes @var{number} tape marks at the current position on the tape.
  7538. @item fsf
  7539. Moves tape position forward @var{number} files.
  7540. @item bsf
  7541. Moves tape position back @var{number} files.
  7542. @item rewind
  7543. Rewinds the tape. (Ignores @var{number}).
  7544. @item offline
  7545. @itemx rewoff1
  7546. Rewinds the tape and takes the tape device off-line. (Ignores @var{number}).
  7547. @item status
  7548. Prints status information about the tape unit.
  7549. @end table
  7550. @FIXME{Is there a better way to frob the spacing on the list?}
  7551. If you don't specify a @var{tapename}, @command{mt} uses the environment
  7552. variable @env{TAPE}; if @env{TAPE} is not set, @command{mt} uses the device
  7553. @file{/dev/rmt12}.
  7554. @command{mt} returns a 0 exit status when the operation(s) were
  7555. successful, 1 if the command was unrecognized, and 2 if an operation
  7556. failed.
  7557. @node Using Multiple Tapes
  7558. @section Using Multiple Tapes
  7559. @UNREVISED
  7560. Often you might want to write a large archive, one larger than will fit
  7561. on the actual tape you are using. In such a case, you can run multiple
  7562. @command{tar} commands, but this can be inconvenient, particularly if you
  7563. are using options like @option{--exclude=@var{pattern}} or dumping entire file systems.
  7564. Therefore, @command{tar} supports multiple tapes automatically.
  7565. Use @option{--multi-volume} (@option{-M}) on the command line, and
  7566. then @command{tar} will, when it reaches the end of the tape, prompt
  7567. for another tape, and continue the archive. Each tape will have an
  7568. independent archive, and can be read without needing the other. (As
  7569. an exception to this, the file that @command{tar} was archiving when
  7570. it ran out of tape will usually be split between the two archives; in
  7571. this case you need to extract from the first archive, using
  7572. @option{--multi-volume}, and then put in the second tape when
  7573. prompted, so @command{tar} can restore both halves of the file.)
  7574. @GNUTAR{} multi-volume archives do not use a truly portable format.
  7575. You need @GNUTAR{} at both ends to process them properly.
  7576. When prompting for a new tape, @command{tar} accepts any of the following
  7577. responses:
  7578. @table @kbd
  7579. @item ?
  7580. Request @command{tar} to explain possible responses
  7581. @item q
  7582. Request @command{tar} to exit immediately.
  7583. @item n @var{file-name}
  7584. Request @command{tar} to write the next volume on the file @var{file-name}.
  7585. @item !
  7586. Request @command{tar} to run a subshell. This option can be disabled
  7587. by giving @option{--restrict} command line option to @command{tar}.
  7588. @item y
  7589. Request @command{tar} to begin writing the next volume.
  7590. @end table
  7591. (You should only type @samp{y} after you have changed the tape;
  7592. otherwise @command{tar} will write over the volume it just finished.)
  7593. @cindex End-of-archive info script
  7594. @cindex Info script
  7595. @anchor{info-script}
  7596. @opindex info-script
  7597. @opindex new-volume-script
  7598. If you want more elaborate behavior than this, give @command{tar} the
  7599. @option{--info-script=@var{script-name}}
  7600. (@option{--new-volume-script=@var{script-name}}, @option{-F
  7601. @var{script-name}}) option. The file @var{script-name} is expected to
  7602. be a program (or shell script) to be run instead of the normal
  7603. prompting procedure. It is executed without any command line
  7604. arguments. Additional data is passed to it via the following
  7605. environment variables:
  7606. @table @env
  7607. @vrindex TAR_VERSION, info script environment variable
  7608. @item TAR_VERSION
  7609. @GNUTAR{} version number.
  7610. @vrindex TAR_ARCHIVE, info script environment variable
  7611. @item TAR_ARCHIVE
  7612. The name of the archive @command{tar} is processing.
  7613. @vrindex TAR_VOLUME, info script environment variable
  7614. @item TAR_VOLUME
  7615. Ordinal number of the volume @command{tar} is about to start.
  7616. @vrindex TAR_SUBCOMMAND, info script environment variable
  7617. @item TAR_SUBCOMMAND
  7618. Short option describing the operation @command{tar} is executed.
  7619. @xref{Operations}, for a complete list of subcommand options.
  7620. @vrindex TAR_FORMAT, info script environment variable
  7621. @item TAR_FORMAT
  7622. Format of the archive being processed. @xref{Formats}, for a complete
  7623. list of archive format names.
  7624. @end table
  7625. The info script can instruct @command{tar} to use new archive name,
  7626. by writing in to file descriptor 3 (see below for an
  7627. example).
  7628. If the info script fails, @command{tar} exits; otherwise, it begins
  7629. writing the next volume.
  7630. The method @command{tar} uses to detect end of tape is not perfect, and
  7631. fails on some operating systems or on some devices. You can use the
  7632. @option{--tape-length=@var{size}} (@option{-L @var{size}}) option if
  7633. @command{tar} can't detect the end of the tape itself. This option
  7634. selects @option{--multi-volume} (@option{-M}) automatically. The
  7635. @var{size} argument should then be the usable size of the tape in
  7636. units of 1024 bytes. But for many devices, and floppy disks in
  7637. particular, this option is never required for real, as far as we know.
  7638. @cindex Volume number file
  7639. @cindex volno file
  7640. @anchor{volno-file}
  7641. @opindex volno-file
  7642. The volume number used by @command{tar} in its tape-change prompt
  7643. can be changed; if you give the
  7644. @option{--volno-file=@var{file-of-number}} option, then
  7645. @var{file-of-number} should be an unexisting file to be created, or
  7646. else, a file already containing a decimal number. That number will be
  7647. used as the volume number of the first volume written. When
  7648. @command{tar} is finished, it will rewrite the file with the
  7649. now-current volume number. (This does not change the volume number
  7650. written on a tape label, as per @ref{label}, it @emph{only} affects
  7651. the number used in the prompt.)
  7652. If you want @command{tar} to cycle through a series of files or tape
  7653. drives, there are three approaches to choose from. First of all, you
  7654. can give @command{tar} multiple @option{--file} options. In this case
  7655. the specified files will be used, in sequence, as the successive
  7656. volumes of the archive. Only when the first one in the sequence needs
  7657. to be used again will @command{tar} prompt for a tape change (or run
  7658. the info script). Secondly, you can use the @samp{n} response to the
  7659. tape-change prompt, and, finally, you can use an info script, that
  7660. writes new archive name to file descriptor. The following example
  7661. illustrates this approach:
  7662. @smallexample
  7663. @group
  7664. #! /bin/sh
  7665. echo Preparing volume $TAR_VOLUME of $TAR_ARCHIVE.
  7666. name=`expr $TAR_ARCHIVE : '\(.*\)-.*'`
  7667. case $TAR_SUBCOMMAND in
  7668. -c) ;;
  7669. -d|-x|-t) test -r $@{name:-$TAR_ARCHIVE@}-$TAR_VOLUME || exit 1
  7670. ;;
  7671. *) exit 1
  7672. esac
  7673. echo $@{name:-$TAR_ARCHIVE@}-$TAR_VOLUME >&3
  7674. @end group
  7675. @end smallexample
  7676. Each volume of a multi-volume archive is an independent @command{tar}
  7677. archive, complete in itself. For example, you can list or extract any
  7678. volume alone; just don't specify @option{--multi-volume}
  7679. (@option{-M}). However, if one file in the archive is split across
  7680. volumes, the only way to extract it successfully is with a
  7681. multi-volume extract command @option{--extract --multi-volume}
  7682. (@option{-xM}) starting on or before the volume where the file begins.
  7683. For example, let's presume someone has two tape drives on a system
  7684. named @file{/dev/tape0} and @file{/dev/tape1}. For having @GNUTAR{}
  7685. to switch to the second drive when it needs to write the
  7686. second tape, and then back to the first tape, etc., just do either of:
  7687. @smallexample
  7688. $ @kbd{tar --create --multi-volume --file=/dev/tape0 --file=/dev/tape1 @var{files}}
  7689. $ @kbd{tar cMff /dev/tape0 /dev/tape1 @var{files}}
  7690. @end smallexample
  7691. @menu
  7692. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  7693. * Tape Files:: Tape Files
  7694. * Tarcat:: Concatenate Volumes into a Single Archive
  7695. @end menu
  7696. @node Multi-Volume Archives
  7697. @subsection Archives Longer than One Tape or Disk
  7698. @cindex Multi-volume archives
  7699. @UNREVISED
  7700. @opindex multi-volume
  7701. To create an archive that is larger than will fit on a single unit of
  7702. the media, use the @option{--multi-volume} (@option{-M}) option in conjunction with
  7703. the @option{--create} option (@pxref{create}). A @dfn{multi-volume}
  7704. archive can be manipulated like any other archive (provided the
  7705. @option{--multi-volume} option is specified), but is stored on more
  7706. than one tape or disk.
  7707. When you specify @option{--multi-volume}, @command{tar} does not report an
  7708. error when it comes to the end of an archive volume (when reading), or
  7709. the end of the media (when writing). Instead, it prompts you to load
  7710. a new storage volume. If the archive is on a magnetic tape, you
  7711. should change tapes when you see the prompt; if the archive is on a
  7712. floppy disk, you should change disks; etc.
  7713. You can read each individual volume of a multi-volume archive as if it
  7714. were an archive by itself. For example, to list the contents of one
  7715. volume, use @option{--list}, without @option{--multi-volume} specified.
  7716. To extract an archive member from one volume (assuming it is described
  7717. that volume), use @option{--extract}, again without
  7718. @option{--multi-volume}.
  7719. If an archive member is split across volumes (ie. its entry begins on
  7720. one volume of the media and ends on another), you need to specify
  7721. @option{--multi-volume} to extract it successfully. In this case, you
  7722. should load the volume where the archive member starts, and use
  7723. @samp{tar --extract --multi-volume}---@command{tar} will prompt for later
  7724. volumes as it needs them. @xref{extracting archives}, for more
  7725. information about extracting archives.
  7726. @option{--info-script=@var{script-name}}
  7727. (@option{--new-volume-script=@var{script-name}}, @option{-F
  7728. @var{script-name}}) (@pxref{info-script}) is like
  7729. @option{--multi-volume} (@option{-M}), except that @command{tar} does
  7730. not prompt you directly to change media volumes when a volume is
  7731. full---instead, @command{tar} runs commands you have stored in
  7732. @var{script-name}. For example, this option can be used to eject
  7733. cassettes, or to broadcast messages such as @samp{Someone please come
  7734. change my tape} when performing unattended backups. When
  7735. @var{script-name} is done, @command{tar} will assume that the media
  7736. has been changed.
  7737. Multi-volume archives can be modified like any other archive. To add
  7738. files to a multi-volume archive, you need to only mount the last
  7739. volume of the archive media (and new volumes, if needed). For all
  7740. other operations, you need to use the entire archive.
  7741. If a multi-volume archive was labeled using
  7742. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  7743. (@pxref{label}) when it was created, @command{tar} will not
  7744. automatically label volumes which are added later. To label
  7745. subsequent volumes, specify @option{--label=@var{archive-label}} again
  7746. in conjunction with the @option{--append}, @option{--update} or
  7747. @option{--concatenate} operation.
  7748. @cindex Labeling multi-volume archives
  7749. @FIXME{example}
  7750. @FIXME{There should be a sample program here, including an exit
  7751. before end. Is the exit status even checked in tar? :-(}
  7752. @table @option
  7753. @item --multi-volume
  7754. @itemx -M
  7755. Creates a multi-volume archive, when used in conjunction with
  7756. @option{--create} (@option{-c}). To perform any other operation on a multi-volume
  7757. archive, specify @option{--multi-volume} in conjunction with that
  7758. operation.
  7759. @item --info-script=@var{program-file}
  7760. @itemx --new-volume-script=@var{program-file}
  7761. @itemx -F @var{program-file}
  7762. Creates a multi-volume archive via a script. Used in conjunction with
  7763. @option{--create} (@option{-c}). @xref{info-script}, dor a detailed discussion.
  7764. @end table
  7765. Beware that there is @emph{no} real standard about the proper way, for
  7766. a @command{tar} archive, to span volume boundaries. If you have a
  7767. multi-volume created by some vendor's @command{tar}, there is almost
  7768. no chance you could read all the volumes with @GNUTAR{}.
  7769. The converse is also true: you may not expect
  7770. multi-volume archives created by @GNUTAR{} to be
  7771. fully recovered by vendor's @command{tar}. Since there is little
  7772. chance that, in mixed system configurations, some vendor's
  7773. @command{tar} will work on another vendor's machine, and there is a
  7774. great chance that @GNUTAR{} will work on most of
  7775. them, your best bet is to install @GNUTAR{} on all
  7776. machines between which you know exchange of files is possible.
  7777. @node Tape Files
  7778. @subsection Tape Files
  7779. @UNREVISED
  7780. To give the archive a name which will be recorded in it, use the
  7781. @option{--label=@var{volume-label}} (@option{-V @var{volume-label}})
  7782. option. This will write a special block identifying
  7783. @var{volume-label} as the name of the archive to the front of the
  7784. archive which will be displayed when the archive is listed with
  7785. @option{--list}. If you are creating a multi-volume archive with
  7786. @option{--multi-volume} (@pxref{Using Multiple Tapes}), then the
  7787. volume label will have @samp{Volume @var{nnn}} appended to the name
  7788. you give, where @var{nnn} is the number of the volume of the archive.
  7789. (If you use the @option{--label=@var{volume-label}}) option when
  7790. reading an archive, it checks to make sure the label on the tape
  7791. matches the one you give. @xref{label}.
  7792. When @command{tar} writes an archive to tape, it creates a single
  7793. tape file. If multiple archives are written to the same tape, one
  7794. after the other, they each get written as separate tape files. When
  7795. extracting, it is necessary to position the tape at the right place
  7796. before running @command{tar}. To do this, use the @command{mt} command.
  7797. For more information on the @command{mt} command and on the organization
  7798. of tapes into a sequence of tape files, see @ref{mt}.
  7799. People seem to often do:
  7800. @smallexample
  7801. @kbd{--label="@var{some-prefix} `date +@var{some-format}`"}
  7802. @end smallexample
  7803. or such, for pushing a common date in all volumes or an archive set.
  7804. @node Tarcat
  7805. @subsection Concatenate Volumes into a Single Archive
  7806. @pindex tarcat
  7807. Sometimes it is necessary to convert existing @GNUTAR{} multi-volume
  7808. archive to a single @command{tar} archive. Simply concatenating all
  7809. volumes into one will not work, since each volume carries an additional
  7810. information at the beginning. @GNUTAR{} is shipped with the shell
  7811. script @command{tarcat} designed for this purpose.
  7812. The script takes a list of files comprising a multi-volume archive
  7813. and creates the resulting archive at the standard output. For example:
  7814. @smallexample
  7815. @kbd{tarcat vol.1 vol.2 vol.3 | tar tf -}
  7816. @end smallexample
  7817. The script implements a simple heuristics to determine the format of
  7818. the first volume file and to decide how to process the rest of the
  7819. files. However, it makes no attempt to verify whether the files are
  7820. given in order or even if they are valid @command{tar} archives.
  7821. It uses @command{dd} and does not filter its standard error, so you
  7822. will usually see lots of spurious messages.
  7823. @FIXME{The script is not installed. Should we install it?}
  7824. @node label
  7825. @section Including a Label in the Archive
  7826. @cindex Labeling an archive
  7827. @cindex Labels on the archive media
  7828. @UNREVISED
  7829. @opindex label
  7830. To avoid problems caused by misplaced paper labels on the archive
  7831. media, you can include a @dfn{label} entry---an archive member which
  7832. contains the name of the archive---in the archive itself. Use the
  7833. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  7834. option in conjunction with the @option{--create} operation to include
  7835. a label entry in the archive as it is being created.
  7836. @table @option
  7837. @item --label=@var{archive-label}
  7838. @itemx -V @var{archive-label}
  7839. Includes an @dfn{archive-label} at the beginning of the archive when
  7840. the archive is being created, when used in conjunction with the
  7841. @option{--create} operation. Checks to make sure the archive label
  7842. matches the one specified (when used in conjunction with any other
  7843. operation.
  7844. @end table
  7845. If you create an archive using both
  7846. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  7847. and @option{--multi-volume} (@option{-M}), each volume of the archive
  7848. will have an archive label of the form @samp{@var{archive-label}
  7849. Volume @var{n}}, where @var{n} is 1 for the first volume, 2 for the
  7850. next, and so on. @xref{Using Multiple Tapes}, for information on
  7851. creating multiple volume archives.
  7852. @cindex Volume label, listing
  7853. @cindex Listing volume label
  7854. The volume label will be displayed by @option{--list} along with
  7855. the file contents. If verbose display is requested, it will also be
  7856. explicitely marked as in the example below:
  7857. @smallexample
  7858. @group
  7859. $ @kbd{tar --verbose --list --file=iamanarchive}
  7860. V--------- 0 0 0 1992-03-07 12:01 iamalabel--Volume Header--
  7861. -rw-r--r-- ringo user 40 1990-05-21 13:30 iamafilename
  7862. @end group
  7863. @end smallexample
  7864. @opindex test-label
  7865. @anchor{--test-label option}
  7866. However, @option{--list} option will cause listing entire
  7867. contents of the archive, which may be undesirable (for example, if the
  7868. archive is stored on a tape). You can request checking only the volume
  7869. by specifying @option{--test-label} option. This option reads only the
  7870. first block of an archive, so it can be used with slow storage
  7871. devices. For example:
  7872. @smallexample
  7873. @group
  7874. $ @kbd{tar --test-label --file=iamanarchive}
  7875. iamalabel
  7876. @end group
  7877. @end smallexample
  7878. If @option{--test-label} is used with a single command line
  7879. argument, @command{tar} compares the volume label with the
  7880. argument. It exits with code 0 if the two strings match, and with code
  7881. 2 otherwise. In this case no output is displayed. For example:
  7882. @smallexample
  7883. @group
  7884. $ @kbd{tar --test-label --file=iamanarchive 'iamalable'}
  7885. @result{} 0
  7886. $ @kbd{tar --test-label --file=iamanarchive 'iamalable' alabel}
  7887. @result{} 1
  7888. @end group
  7889. @end smallexample
  7890. If you request any operation, other than @option{--create}, along
  7891. with using @option{--label} option, @command{tar} will first check if
  7892. the archive label matches the one specified and will refuse to proceed
  7893. if it does not. Use this as a safety precaution to avoid accidentally
  7894. overwriting existing archives. For example, if you wish to add files
  7895. to @file{archive}, presumably labelled with string @samp{My volume},
  7896. you will get:
  7897. @smallexample
  7898. @group
  7899. $ @kbd{tar -rf archive --label 'My volume' .}
  7900. tar: Archive not labeled to match `My volume'
  7901. @end group
  7902. @end smallexample
  7903. @noindent
  7904. in case its label does not match. This will work even if
  7905. @file{archive} is not labelled at all.
  7906. Similarly, @command{tar} will refuse to list or extract the
  7907. archive if its label doesn't match the @var{archive-label}
  7908. specified. In those cases, @var{archive-label} argument is interpreted
  7909. as a globbing-style pattern which must match the actual magnetic
  7910. volume label. @xref{exclude}, for a precise description of how match
  7911. is attempted@footnote{Previous versions of @command{tar} used full
  7912. regular expression matching, or before that, only exact string
  7913. matching, instead of wildcard matchers. We decided for the sake of
  7914. simplicity to use a uniform matching device through
  7915. @command{tar}.}. If the switch @option{--multi-volume} (@option{-M}) is being used,
  7916. the volume label matcher will also suffix @var{archive-label} by
  7917. @w{@samp{ Volume [1-9]*}} if the initial match fails, before giving
  7918. up. Since the volume numbering is automatically added in labels at
  7919. creation time, it sounded logical to equally help the user taking care
  7920. of it when the archive is being read.
  7921. The @option{--label} was once called @option{--volume}, but is not
  7922. available under that name anymore.
  7923. You can also use @option{--label} to get a common information on
  7924. all tapes of a series. For having this information different in each
  7925. series created through a single script used on a regular basis, just
  7926. manage to get some date string as part of the label. For example:
  7927. @smallexample
  7928. @group
  7929. $ @kbd{tar cfMV /dev/tape "Daily backup for `date +%Y-%m-%d`"}
  7930. $ @kbd{tar --create --file=/dev/tape --multi-volume \
  7931. --volume="Daily backup for `date +%Y-%m-%d`"}
  7932. @end group
  7933. @end smallexample
  7934. Also note that each label has its own date and time, which corresponds
  7935. to when @GNUTAR{} initially attempted to write it,
  7936. often soon after the operator launches @command{tar} or types the
  7937. carriage return telling that the next tape is ready. Comparing date
  7938. labels does give an idea of tape throughput only if the delays for
  7939. rewinding tapes and the operator switching them were negligible, which
  7940. is usually not the case.
  7941. @node verify
  7942. @section Verifying Data as It is Stored
  7943. @cindex Verifying a write operation
  7944. @cindex Double-checking a write operation
  7945. @table @option
  7946. @item -W
  7947. @itemx --verify
  7948. @opindex verify, short description
  7949. Attempt to verify the archive after writing.
  7950. @end table
  7951. This option causes @command{tar} to verify the archive after writing it.
  7952. Each volume is checked after it is written, and any discrepancies
  7953. are recorded on the standard error output.
  7954. Verification requires that the archive be on a back-space-able medium.
  7955. This means pipes, some cartridge tape drives, and some other devices
  7956. cannot be verified.
  7957. You can insure the accuracy of an archive by comparing files in the
  7958. system with archive members. @command{tar} can compare an archive to the
  7959. file system as the archive is being written, to verify a write
  7960. operation, or can compare a previously written archive, to insure that
  7961. it is up to date.
  7962. @opindex verify, using with @option{--create}
  7963. @opindex create, using with @option{--verify}
  7964. To check for discrepancies in an archive immediately after it is
  7965. written, use the @option{--verify} (@option{-W}) option in conjunction with
  7966. the @option{--create} operation. When this option is
  7967. specified, @command{tar} checks archive members against their counterparts
  7968. in the file system, and reports discrepancies on the standard error.
  7969. To verify an archive, you must be able to read it from before the end
  7970. of the last written entry. This option is useful for detecting data
  7971. errors on some tapes. Archives written to pipes, some cartridge tape
  7972. drives, and some other devices cannot be verified.
  7973. One can explicitly compare an already made archive with the file
  7974. system by using the @option{--compare} (@option{--diff}, @option{-d})
  7975. option, instead of using the more automatic @option{--verify} option.
  7976. @xref{compare}.
  7977. Note that these two options have a slightly different intent. The
  7978. @option{--compare} option checks how identical are the logical contents of some
  7979. archive with what is on your disks, while the @option{--verify} option is
  7980. really for checking if the physical contents agree and if the recording
  7981. media itself is of dependable quality. So, for the @option{--verify}
  7982. operation, @command{tar} tries to defeat all in-memory cache pertaining to
  7983. the archive, while it lets the speed optimization undisturbed for the
  7984. @option{--compare} option. If you nevertheless use @option{--compare} for
  7985. media verification, you may have to defeat the in-memory cache yourself,
  7986. maybe by opening and reclosing the door latch of your recording unit,
  7987. forcing some doubt in your operating system about the fact this is really
  7988. the same volume as the one just written or read.
  7989. The @option{--verify} option would not be necessary if drivers were indeed
  7990. able to detect dependably all write failures. This sometimes require many
  7991. magnetic heads, some able to read after the writes occurred. One would
  7992. not say that drivers unable to detect all cases are necessarily flawed,
  7993. as long as programming is concerned.
  7994. The @option{--verify} (@option{-W}) option will not work in
  7995. conjunction with the @option{--multi-volume} (@option{-M}) option or
  7996. the @option{--append} (@option{-r}), @option{--update} (@option{-u})
  7997. and @option{--delete} operations. @xref{Operations}, for more
  7998. information on these operations.
  7999. Also, since @command{tar} normally strips leading @samp{/} from file
  8000. names (@pxref{absolute}), a command like @samp{tar --verify -cf
  8001. /tmp/foo.tar /etc} will work as desired only if the working directory is
  8002. @file{/}, as @command{tar} uses the archive's relative member names
  8003. (e.g., @file{etc/motd}) when verifying the archive.
  8004. @node Write Protection
  8005. @section Write Protection
  8006. Almost all tapes and diskettes, and in a few rare cases, even disks can
  8007. be @dfn{write protected}, to protect data on them from being changed.
  8008. Once an archive is written, you should write protect the media to prevent
  8009. the archive from being accidentally overwritten or deleted. (This will
  8010. protect the archive from being changed with a tape or floppy drive---it
  8011. will not protect it from magnet fields or other physical hazards).
  8012. The write protection device itself is usually an integral part of the
  8013. physical media, and can be a two position (write enabled/write
  8014. disabled) switch, a notch which can be popped out or covered, a ring
  8015. which can be removed from the center of a tape reel, or some other
  8016. changeable feature.
  8017. @node Changes
  8018. @appendix Changes
  8019. This appendix lists some important user-visible changes between
  8020. version @GNUTAR{} @value{VERSION} and previous versions. An up-to-date
  8021. version of this document is available at
  8022. @uref{http://www.gnu.org/@/software/@/tar/manual/changes.html,the
  8023. @GNUTAR{} documentation page}.
  8024. @table @asis
  8025. @item Use of globbing patterns when listing and extracting.
  8026. Previous versions of GNU tar assumed shell-style globbing when
  8027. extracting from or listing an archive. For example:
  8028. @smallexample
  8029. $ @kbd{tar xf foo.tar '*.c'}
  8030. @end smallexample
  8031. would extract all files whose names end in @samp{.c}. This behavior
  8032. was not documented and was incompatible with traditional tar
  8033. implementations. Therefore, starting from version 1.15.91, GNU tar
  8034. no longer uses globbing by default. For example, the above invocation
  8035. is now interpreted as a request to extract from the archive the file
  8036. named @file{*.c}.
  8037. To facilitate transition to the new behavior for those users who got
  8038. used to the previous incorrect one, @command{tar} will print a warning
  8039. if it finds out that a requested member was not found in the archive
  8040. and its name looks like a globbing pattern. For example:
  8041. @smallexample
  8042. $ @kbd{tar xf foo.tar '*.c'}
  8043. tar: Pattern matching characters used in file names. Please,
  8044. tar: use --wildcards to enable pattern matching, or --no-wildcards to
  8045. tar: suppress this warning.
  8046. tar: *.c: Not found in archive
  8047. tar: Error exit delayed from previous errors
  8048. @end smallexample
  8049. To treat member names as globbing patterns, use --wildcards option.
  8050. If you want to tar to mimic the behavior of versions prior to 1.15.91,
  8051. add this option to your @env{TAR_OPTIONS} variable.
  8052. @xref{Wildcards}, for the detailed discussion of the use of globbing
  8053. patterns by @GNUTAR{}.
  8054. @item Use of short option @option{-o}.
  8055. Earlier versions of @GNUTAR{} understood @option{-o} command line
  8056. option as a synonym for @option{--old-archive}.
  8057. @GNUTAR{} starting from version 1.13.90 understands this option as
  8058. a synonym for @option{--no-same-owner}. This is compatible with
  8059. UNIX98 @command{tar} implementations.
  8060. However, to facilitate transition, @option{-o} option retains its
  8061. old semantics when it is used with one of archive-creation commands.
  8062. Users are encouraged to use @option{--format=oldgnu} instead.
  8063. It is especially important, since versions of @acronym{GNU} Automake
  8064. up to and including 1.8.4 invoke tar with this option to produce
  8065. distribution tarballs. @xref{Formats,v7}, for the detailed discussion
  8066. of this issue and its implications.
  8067. @FIXME{Change the first argument to tar-formats if and when Automake
  8068. people accept my patch to the documentation, and the new Automake is
  8069. out --Sergey 2006-05-25}.
  8070. @xref{Options, tar-v7, Changing Automake's Behavior,
  8071. automake, GNU Automake}, for a description on how to use various
  8072. archive formats with @command{automake}.
  8073. Future versions of @GNUTAR{} will understand @option{-o} only as a
  8074. synonym for @option{--no-same-owner}.
  8075. @item Use of short option @option{-l}
  8076. Earlier versions of @GNUTAR{} understood @option{-l} option as a
  8077. synonym for @option{--one-file-system}. Since such usage contradicted
  8078. to UNIX98 specification and harmed compatibility with other
  8079. implementation, it was declared deprecated in version 1.14. However,
  8080. to facilitate transition to its new semantics, it was supported by
  8081. versions 1.15 and 1.15.90. The present use of @option{-l} as a short
  8082. variant of @option{--check-links} was introduced in version 1.15.91.
  8083. @item Use of options @option{--portability} and @option{--old-archive}
  8084. These options are deprecated. Please use @option{--format=v7} instead.
  8085. @item Use of option @option{--posix}
  8086. This option is deprecated. Please use @option{--format=posix} instead.
  8087. @end table
  8088. @node Configuring Help Summary
  8089. @appendix Configuring Help Summary
  8090. Running @kbd{tar --help} displays the short @command{tar} option
  8091. summary (@pxref{help}). This summary is organised by @dfn{groups} of
  8092. semantically close options. The options within each group are printed
  8093. in the following order: a short option, eventually followed by a list
  8094. of corresponding long option names, followed by a short description of
  8095. the option. For example, here is an excerpt from the actual @kbd{tar
  8096. --help} output:
  8097. @verbatim
  8098. Main operation mode:
  8099. -A, --catenate, --concatenate append tar files to an archive
  8100. -c, --create create a new archive
  8101. -d, --diff, --compare find differences between archive and
  8102. file system
  8103. --delete delete from the archive
  8104. @end verbatim
  8105. @vrindex ARGP_HELP_FMT, environment variable
  8106. The exact visual representation of the help output is configurable via
  8107. @env{ARGP_HELP_FMT} environment variable. The value of this variable
  8108. is a comma-separated list of @dfn{format variable} assignments. There
  8109. are two kinds of format variables. An @dfn{offset variable} keeps the
  8110. offset of some part of help output text from the leftmost column on
  8111. the screen. A @dfn{boolean} variable is a flag that toggles some
  8112. output feature on or off. Depending on the type of the corresponding
  8113. variable, there are two kinds of assignments:
  8114. @table @asis
  8115. @item Offset assignment
  8116. The assignment to an offset variable has the following syntax:
  8117. @smallexample
  8118. @var{variable}=@var{value}
  8119. @end smallexample
  8120. @noindent
  8121. where @var{variable} is the variable name, and @var{value} is a
  8122. numeric value to be assigned to the variable.
  8123. @item Boolean assignment
  8124. To assign @code{true} value to a variable, simply put this variable name. To
  8125. assign @code{false} value, prefix the variable name with @samp{no-}. For
  8126. example:
  8127. @smallexample
  8128. @group
  8129. # Assign @code{true} value:
  8130. dup-args
  8131. # Assign @code{false} value:
  8132. no-dup-args
  8133. @end group
  8134. @end smallexample
  8135. @end table
  8136. Following variables are declared:
  8137. @deftypevr {Help Output} boolean dup-args
  8138. If true, arguments for an option are shown with both short and long
  8139. options, even when a given option has both forms, for example:
  8140. @smallexample
  8141. -f ARCHIVE, --file=ARCHIVE use archive file or device ARCHIVE
  8142. @end smallexample
  8143. If false, then if an option has both short and long forms, the
  8144. argument is only shown with the long one, for example:
  8145. @smallexample
  8146. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8147. @end smallexample
  8148. @noindent
  8149. and a message indicating that the argument is applicable to both
  8150. forms is printed below the options. This message can be disabled
  8151. using @code{dup-args-note} (see below).
  8152. The default is false.
  8153. @end deftypevr
  8154. @deftypevr {Help Output} boolean dup-args-note
  8155. If this variable is true, which is the default, the following notice
  8156. is displayed at the end of the help output:
  8157. @quotation
  8158. Mandatory or optional arguments to long options are also mandatory or
  8159. optional for any corresponding short options.
  8160. @end quotation
  8161. Setting @code{no-dup-args-note} inhibits this message. Normally, only one of
  8162. variables @code{dup-args} or @code{dup-args-note} should be set.
  8163. @end deftypevr
  8164. @deftypevr {Help Output} offset short-opt-col
  8165. Column in which short options start. Default is 2.
  8166. @smallexample
  8167. @group
  8168. $ @kbd{tar --help|grep ARCHIVE}
  8169. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8170. $ @kbd{ARGP_HELP_FMT=short-opt-col=6 tar --help|grep ARCHIVE}
  8171. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8172. @end group
  8173. @end smallexample
  8174. @end deftypevr
  8175. @deftypevr {Help Output} offset long-opt-col
  8176. Column in which long options start. Default is 6. For example:
  8177. @smallexample
  8178. @group
  8179. $ @kbd{tar --help|grep ARCHIVE}
  8180. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8181. $ @kbd{ARGP_HELP_FMT=long-opt-col=16 tar --help|grep ARCHIVE}
  8182. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8183. @end group
  8184. @end smallexample
  8185. @end deftypevr
  8186. @deftypevr {Help Output} offset doc-opt-col
  8187. Column in which @dfn{doc options} start. A doc option isn't actually
  8188. an option, but rather an arbitrary piece of documentation that is
  8189. displayed in much the same manner as the options. For example, in
  8190. the description of @option{--format} option:
  8191. @smallexample
  8192. @group
  8193. -H, --format=FORMAT create archive of the given format.
  8194. FORMAT is one of the following:
  8195. gnu GNU tar 1.13.x format
  8196. oldgnu GNU format as per tar <= 1.12
  8197. pax POSIX 1003.1-2001 (pax) format
  8198. posix same as pax
  8199. ustar POSIX 1003.1-1988 (ustar) format
  8200. v7 old V7 tar format
  8201. @end group
  8202. @end smallexample
  8203. @noindent
  8204. the format names are doc options. Thus, if you set
  8205. @kbd{ARGP_HELP_FMT=doc-opt-col=6} the above part of the help output
  8206. will look as follows:
  8207. @smallexample
  8208. @group
  8209. -H, --format=FORMAT create archive of the given format.
  8210. FORMAT is one of the following:
  8211. gnu GNU tar 1.13.x format
  8212. oldgnu GNU format as per tar <= 1.12
  8213. pax POSIX 1003.1-2001 (pax) format
  8214. posix same as pax
  8215. ustar POSIX 1003.1-1988 (ustar) format
  8216. v7 old V7 tar format
  8217. @end group
  8218. @end smallexample
  8219. @end deftypevr
  8220. @deftypevr {Help Output} offset opt-doc-col
  8221. Column in which option description starts. Default is 29.
  8222. @smallexample
  8223. @group
  8224. $ @kbd{tar --help|grep ARCHIVE}
  8225. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8226. $ @kbd{ARGP_HELP_FMT=opt-doc-col=19 tar --help|grep ARCHIVE}
  8227. -f, --file=ARCHIVE use archive file or device ARCHIVE
  8228. $ @kbd{ARGP_HELP_FMT=opt-doc-col=9 tar --help|grep ARCHIVE}
  8229. -f, --file=ARCHIVE
  8230. use archive file or device ARCHIVE
  8231. @end group
  8232. @end smallexample
  8233. @noindent
  8234. Notice, that the description starts on a separate line if
  8235. @code{opt-doc-col} value is too small.
  8236. @end deftypevr
  8237. @deftypevr {Help Output} offset header-col
  8238. Column in which @dfn{group headers} are printed. A group header is a
  8239. descriptive text preceding an option group. For example, in the
  8240. following text:
  8241. @verbatim
  8242. Main operation mode:
  8243. -A, --catenate, --concatenate append tar files to
  8244. an archive
  8245. -c, --create create a new archive
  8246. @end verbatim
  8247. @noindent
  8248. @samp{Main operation mode:} is the group header.
  8249. The default value is 1.
  8250. @end deftypevr
  8251. @deftypevr {Help Output} offset usage-indent
  8252. Indentation of wrapped usage lines. Affects @option{--usage}
  8253. output. Default is 12.
  8254. @end deftypevr
  8255. @deftypevr {Help Output} offset rmargin
  8256. Right margin of the text output. Used for wrapping.
  8257. @end deftypevr
  8258. @node Genfile
  8259. @appendix Genfile
  8260. @include genfile.texi
  8261. @node Snapshot Files
  8262. @appendix Format of the Incremental Snapshot Files
  8263. @include snapshot.texi
  8264. @node Free Software Needs Free Documentation
  8265. @appendix Free Software Needs Free Documentation
  8266. @include freemanuals.texi
  8267. @node Copying This Manual
  8268. @appendix Copying This Manual
  8269. @menu
  8270. * GNU Free Documentation License:: License for copying this manual
  8271. @end menu
  8272. @include fdl.texi
  8273. @node Index of Command Line Options
  8274. @appendix Index of Command Line Options
  8275. This appendix contains an index of all @GNUTAR{} long command line
  8276. options. The options are listed without the preceeding double-dash.
  8277. @FIXME{@itemize
  8278. @item Make sure @emph{all} options are indexed.
  8279. @item Provide an index of short options
  8280. @end itemize}
  8281. @printindex op
  8282. @node Index
  8283. @appendix Index
  8284. @printindex cp
  8285. @summarycontents
  8286. @contents
  8287. @bye
  8288. @c Local variables:
  8289. @c texinfo-column-for-description: 32
  8290. @c End: