tar.texi 352 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205
  1. \input texinfo @c -*-texinfo-*-
  2. @comment %**start of header
  3. @setfilename tar.info
  4. @include version.texi
  5. @settitle GNU tar @value{VERSION}
  6. @setchapternewpage odd
  7. @finalout
  8. @smallbook
  9. @c %**end of header
  10. @c ======================================================================
  11. @c This document has three levels of rendition: PUBLISH, DISTRIB or PROOF,
  12. @c as decided by @set symbols. The PUBLISH rendition does not show
  13. @c notes or marks asking for revision. Most users will prefer having more
  14. @c information, even if this information is not fully revised for adequacy,
  15. @c so DISTRIB is the default for tar distributions. The PROOF rendition
  16. @c show all marks to the point of ugliness, but is nevertheless useful to
  17. @c those working on the manual itself.
  18. @c ======================================================================
  19. @ifclear PUBLISH
  20. @ifclear DISTRIB
  21. @ifclear PROOF
  22. @set DISTRIB
  23. @end ifclear
  24. @end ifclear
  25. @end ifclear
  26. @ifset PUBLISH
  27. @set RENDITION The book, version
  28. @end ifset
  29. @ifset DISTRIB
  30. @set RENDITION FTP release, version
  31. @end ifset
  32. @ifset PROOF
  33. @set RENDITION Proof reading version
  34. @end ifset
  35. @c ---------------------------------------------------------------------
  36. @c The @FIXME's, @UNREVISED and @c comments are part Fran@,{c}ois's work
  37. @c plan. These annotations are somewhat precious to him; he asks that I
  38. @c do not alter them inconsiderately. Much work is needed for GNU tar
  39. @c internals (the sources, the programs themselves). Revising the
  40. @c adequacy of the manual while revising the sources, and cleaning them
  41. @c both at the same time, is a good way to proceed.
  42. @c ---------------------------------------------------------------------
  43. @c Output marks for nodes needing revision, but not in PUBLISH rendition.
  44. @macro UNREVISED
  45. @ifclear PUBLISH
  46. @quotation
  47. @emph{(This message will disappear, once this node revised.)}
  48. @end quotation
  49. @end ifclear
  50. @end macro
  51. @c Output various FIXME information only in PROOF rendition.
  52. @macro FIXME{string}
  53. @allow-recursion
  54. @quote-arg
  55. @ifset PROOF
  56. @strong{<FIXME>} \string\ @strong{</>}
  57. @end ifset
  58. @end macro
  59. @macro FIXME-ref{string}
  60. @quote-arg
  61. @ifset PROOF
  62. @strong{<REF>} \string\ @strong{</>}
  63. @end ifset
  64. @end macro
  65. @macro FIXME-pxref{string}
  66. @quote-arg
  67. @ifset PROOF
  68. @strong{<PXREF>} \string\ @strong{</>}
  69. @end ifset
  70. @end macro
  71. @macro FIXME-xref{string}
  72. @quote-arg
  73. @ifset PROOF
  74. @strong{<XREF>} \string\ @strong{</>}
  75. @end ifset
  76. @end macro
  77. @c @macro option{entry}
  78. @c @quote-arg
  79. @c @opindex{--\entry\}
  80. @c @value{\entry\}
  81. @c @end macro
  82. @macro GNUTAR
  83. @acronym{GNU} @command{tar}
  84. @end macro
  85. @set op-absolute-names @kbd{--absolute-names} (@kbd{-P})
  86. @set ref-absolute-names @ref{absolute}
  87. @set xref-absolute-names @xref{absolute}
  88. @set pxref-absolute-names @pxref{absolute}
  89. @set op-after-date @kbd{--after-date=@var{date}} (@kbd{--newer=@var{date}}, @kbd{-N @var{date}})
  90. @set ref-after-date @ref{after}
  91. @set xref-after-date @xref{after}
  92. @set pxref-after-date @pxref{after}
  93. @set op-append @kbd{--append} (@kbd{-r})
  94. @set ref-append @ref{add}
  95. @set xref-append @xref{add}
  96. @set pxref-append @pxref{add}
  97. @set op-atime-preserve @kbd{--atime-preserve}
  98. @set ref-atime-preserve @ref{Attributes}
  99. @set xref-atime-preserve @xref{Attributes}
  100. @set pxref-atime-preserve @pxref{Attributes}
  101. @set op-backup @kbd{--backup}
  102. @set ref-backup @ref{Backup options}
  103. @set xref-backup @xref{Backup options}
  104. @set pxref-backup @pxref{Backup options}
  105. @set op-block-number @kbd{--block-number} (@kbd{-R})
  106. @set ref-block-number @ref{verbose}
  107. @set xref-block-number @xref{verbose}
  108. @set pxref-block-number @pxref{verbose}
  109. @set op-blocking-factor @kbd{--blocking-factor=@var{512-size}} (@kbd{-b @var{512-size}})
  110. @set ref-blocking-factor @ref{Blocking Factor}
  111. @set xref-blocking-factor @xref{Blocking Factor}
  112. @set pxref-blocking-factor @pxref{Blocking Factor}
  113. @set op-bzip2 @kbd{--bzip2} (@kbd{-j})
  114. @set ref-bzip2 @ref{gzip}
  115. @set xref-bzip2 @xref{gzip}
  116. @set pxref-bzip2 @pxref{gzip}
  117. @set op-check-links @kbd{--check-links} (@kbd{-l})
  118. @set ref-check-links @ref{--check-links}
  119. @set xref-check-links @xref{--check-links}
  120. @set pxref-check-links @pxref{--check-links}
  121. @set op-checkpoint @kbd{--checkpoint}
  122. @set ref-checkpoint @ref{verbose}
  123. @set xref-checkpoint @xref{verbose}
  124. @set pxref-checkpoint @pxref{verbose}
  125. @set op-check-links @kbd{--check-links}
  126. @set op-compare @kbd{--compare} (@kbd{--diff}, @kbd{-d})
  127. @set ref-compare @ref{compare}
  128. @set xref-compare @xref{compare}
  129. @set pxref-compare @pxref{compare}
  130. @set op-compress @kbd{--compress} (@kbd{--uncompress}, @kbd{-Z})
  131. @set ref-compress @ref{gzip}
  132. @set xref-compress @xref{gzip}
  133. @set pxref-compress @pxref{gzip}
  134. @set op-concatenate @kbd{--concatenate} (@kbd{--catenate}, @kbd{-A})
  135. @set ref-concatenate @ref{concatenate}
  136. @set xref-concatenate @xref{concatenate}
  137. @set pxref-concatenate @pxref{concatenate}
  138. @set op-create @kbd{--create} (@kbd{-c})
  139. @set ref-create @ref{create}
  140. @set xref-create @xref{create}
  141. @set pxref-create @pxref{create}
  142. @set op-delete @kbd{--delete}
  143. @set ref-delete @ref{delete}
  144. @set xref-delete @xref{delete}
  145. @set pxref-delete @pxref{delete}
  146. @set op-dereference @kbd{--dereference} (@kbd{-h})
  147. @set ref-dereference @ref{dereference}
  148. @set xref-dereference @xref{dereference}
  149. @set pxref-dereference @pxref{dereference}
  150. @set op-directory @kbd{--directory=@var{directory}} (@kbd{-C @var{directory}})
  151. @set ref-directory @ref{directory}
  152. @set xref-directory @xref{directory}
  153. @set pxref-directory @pxref{directory}
  154. @set op-exclude @kbd{--exclude=@var{pattern}}
  155. @set ref-exclude @ref{exclude}
  156. @set xref-exclude @xref{exclude}
  157. @set pxref-exclude @pxref{exclude}
  158. @set op-exclude-from @kbd{--exclude-from=@var{file-of-patterns}} (@kbd{-X @var{file-of-patterns}})
  159. @set ref-exclude-from @ref{exclude}
  160. @set xref-exclude-from @xref{exclude}
  161. @set pxref-exclude-from @pxref{exclude}
  162. @set op-extract @kbd{--extract} (@kbd{--get}, @kbd{-x})
  163. @set ref-extract @ref{extract}
  164. @set xref-extract @xref{extract}
  165. @set pxref-extract @pxref{extract}
  166. @set op-file @kbd{--file=@var{archive-name}} (@kbd{-f @var{archive-name}})
  167. @set ref-file @ref{file}
  168. @set xref-file @xref{file}
  169. @set pxref-file @pxref{file}
  170. @set op-files-from @kbd{--files-from=@var{file-of-names}} (@kbd{-T @var{file-of-names}})
  171. @set ref-files-from @ref{files}
  172. @set xref-files-from @xref{files}
  173. @set pxref-files-from @pxref{files}
  174. @set op-force-local @kbd{--force-local}
  175. @set ref-force-local @ref{file}
  176. @set xref-force-local @xref{file}
  177. @set pxref-force-local @pxref{file}
  178. @set op-group @kbd{--group=@var{group}}
  179. @set ref-group @ref{Option Summary}
  180. @set xref-group @xref{Option Summary}
  181. @set pxref-group @pxref{Option Summary}
  182. @set op-gzip @kbd{--gzip} (@kbd{--gunzip}, @kbd{--ungzip}, @kbd{-z})
  183. @set ref-gzip @ref{gzip}
  184. @set xref-gzip @xref{gzip}
  185. @set pxref-gzip @pxref{gzip}
  186. @set op-help @kbd{--help}
  187. @set ref-help @ref{help}
  188. @set xref-help @xref{help}
  189. @set pxref-help @pxref{help}
  190. @set op-ignore-failed-read @kbd{--ignore-failed-read}
  191. @set ref-ignore-failed-read @ref{create options}
  192. @set xref-ignore-failed-read @xref{create options}
  193. @set pxref-ignore-failed-read @pxref{create options}
  194. @set op-ignore-zeros @kbd{--ignore-zeros} (@kbd{-i})
  195. @set ref-ignore-zeros @ref{Reading}
  196. @set xref-ignore-zeros @xref{Reading}
  197. @set pxref-ignore-zeros @pxref{Reading}
  198. @set op-incremental @kbd{--incremental} (@kbd{-G})
  199. @set ref-incremental @ref{Inc Dumps}
  200. @set xref-incremental @xref{Inc Dumps}
  201. @set pxref-incremental @pxref{Inc Dumps}
  202. @set op-info-script @kbd{--info-script=@var{script-name}} (@kbd{--new-volume-script=@var{script-name}}, @kbd{-F @var{script-name}})
  203. @set ref-info-script @ref{Multi-Volume Archives}
  204. @set xref-info-script @xref{Multi-Volume Archives}
  205. @set pxref-info-script @pxref{Multi-Volume Archives}
  206. @set op-interactive @kbd{--interactive} (@kbd{-w})
  207. @set ref-interactive @ref{interactive}
  208. @set xref-interactive @xref{interactive}
  209. @set pxref-interactive @pxref{interactive}
  210. @set op-keep-old-files @kbd{--keep-old-files} (@kbd{-k})
  211. @set ref-keep-old-files @ref{Keep Old Files}
  212. @set xref-keep-old-files @xref{Keep Old Files}
  213. @set pxref-keep-old-files @pxref{Keep Old Files}
  214. @set op-keep-newer-files @kbd{--keep-old-files}
  215. @set ref-keep-newer-files @ref{Keep Newer Files}
  216. @set xref-keep-newer-files @xref{Keep Newer Files}
  217. @set pxref-keep-newer-files @pxref{Keep Newer Files}
  218. @set op-label @kbd{--label=@var{archive-label}} (@kbd{-V @var{archive-label}})
  219. @set ref-label @ref{label}
  220. @set xref-label @xref{label}
  221. @set pxref-label @pxref{label}
  222. @set op-list @kbd{--list} (@kbd{-t})
  223. @set ref-list @ref{list}
  224. @set xref-list @xref{list}
  225. @set pxref-list @pxref{list}
  226. @set op-listed-incremental @kbd{--listed-incremental=@var{snapshot-file}} (@kbd{-g @var{snapshot-file}})
  227. @set ref-listed-incremental @ref{Inc Dumps}
  228. @set xref-listed-incremental @xref{Inc Dumps}
  229. @set pxref-listed-incremental @pxref{Inc Dumps}
  230. @set op-mode @kbd{--mode=@var{permissions}}
  231. @set ref-mode @ref{Option Summary}
  232. @set xref-mode @xref{Option Summary}
  233. @set pxref-mode @pxref{Option Summary}
  234. @set op-multi-volume @kbd{--multi-volume} (@kbd{-M})
  235. @set ref-multi-volume @ref{Multi-Volume Archives}
  236. @set xref-multi-volume @xref{Multi-Volume Archives}
  237. @set pxref-multi-volume @pxref{Multi-Volume Archives}
  238. @set op-newer-mtime @kbd{--newer-mtime=@var{date}}
  239. @set ref-newer-mtime @ref{after}
  240. @set xref-newer-mtime @xref{after}
  241. @set pxref-newer-mtime @pxref{after}
  242. @set op-no-recursion @kbd{--no-recursion}
  243. @set ref-no-recursion @ref{recurse}
  244. @set xref-no-recursion @xref{recurse}
  245. @set pxref-no-recursion @pxref{recurse}
  246. @set op-no-same-owner @kbd{--no-same-owner} (@kbd{-o})
  247. @set ref-no-same-owner @ref{Attributes}
  248. @set xref-no-same-owner @xref{Attributes}
  249. @set pxref-no-same-owner @pxref{Attributes}
  250. @set op-no-same-permissions @kbd{--no-same-permissions}
  251. @set ref-no-same-permissions @ref{Attributes}
  252. @set xref-no-same-permissions @xref{Attributes}
  253. @set pxref-no-same-permissions @pxref{Attributes}
  254. @set op-null @kbd{--null}
  255. @set ref-null @ref{files}
  256. @set xref-null @xref{files}
  257. @set pxref-null @pxref{files}
  258. @set op-numeric-owner @kbd{--numeric-owner}
  259. @set ref-numeric-owner @ref{Attributes}
  260. @set xref-numeric-owner @xref{Attributes}
  261. @set pxref-numeric-owner @pxref{Attributes}
  262. @set op-occurrence @kbd{--occurrence}
  263. @set ref-occurrence @ref{--occurrence}
  264. @set xref-occurrence @xref{--occurrence}
  265. @set pxref-occurrence @pxref{--occurrence}
  266. @set op-old-archive @kbd{--old-archive} (@kbd{-o})
  267. @set ref-old-archive @ref{old}
  268. @set xref-old-archive @xref{old}
  269. @set pxref-old-archive @pxref{old}
  270. @set op-one-file-system @kbd{--one-file-system} (@kbd{-l})
  271. @set ref-one-file-system @ref{one}
  272. @set xref-one-file-system @xref{one}
  273. @set pxref-one-file-system @pxref{one}
  274. @set op-overwrite @kbd{--overwrite}
  275. @set ref-overwrite @ref{Overwrite Old Files}
  276. @set xref-overwrite @xref{Overwrite Old Files}
  277. @set pxref-overwrite @pxref{Overwrite Old Files}
  278. @set op-owner @kbd{--owner=@var{user}}
  279. @set ref-owner @ref{Option Summary}
  280. @set xref-owner @xref{Option Summary}
  281. @set pxref-owner @pxref{Option Summary}
  282. @set op-format @kbd{--format} (@kbd{-H})
  283. @set ref-format @ref{format}
  284. @set xref-format @xref{format}
  285. @set pxref-format @pxref{format}
  286. @set op-format-v7 @kbd{--format=v7}
  287. @set op-format-gnu @kbd{--format=gnu}
  288. @set op-format-oldgnu @kbd{--format=oldgnu}
  289. @set op-format-posix @kbd{--format=posix}
  290. @set op-format-ustar @kbd{--format=ustar}
  291. @set op-posix @kbd{--posix}
  292. @set ref-posix @ref{posix}
  293. @set xref-posix @xref{posix}
  294. @set pxref-posix @pxref{posix}
  295. @set op-preserve @kbd{--preserve}
  296. @set ref-preserve @ref{Attributes}
  297. @set xref-preserve @xref{Attributes}
  298. @set pxref-preserve @pxref{Attributes}
  299. @set op-record-size @kbd{--record-size=@var{size}}
  300. @set ref-record-size @ref{Blocking}
  301. @set xref-record-size @xref{Blocking}
  302. @set pxref-record-size @pxref{Blocking}
  303. @set op-recursive-unlink @kbd{--recursive-unlink}
  304. @set ref-recursive-unlink @ref{Writing}
  305. @set xref-recursive-unlink @xref{Writing}
  306. @set pxref-recursive-unlink @pxref{Writing}
  307. @set op-read-full-records @kbd{--read-full-records} (@kbd{-B})
  308. @set ref-read-full-records @ref{Blocking}
  309. @set xref-read-full-records @xref{Blocking}
  310. @set pxref-read-full-records @pxref{Blocking}
  311. @c FIXME: or should it be Reading, or Blocking Factor
  312. @set op-remove-files @kbd{--remove-files}
  313. @set ref-remove-files @ref{Writing}
  314. @set xref-remove-files @xref{Writing}
  315. @set pxref-remove-files @pxref{Writing}
  316. @set op-rmt-command @kbd{rmt-command=@var{command}}
  317. @set op-rsh-command @kbd{rsh-command=@var{command}}
  318. @set op-same-order @kbd{--same-order} (@kbd{--preserve-order}, @kbd{-s})
  319. @set ref-same-order @ref{Scarce}
  320. @set xref-same-order @xref{Scarce}
  321. @set pxref-same-order @pxref{Scarce}
  322. @c FIXME: or should it be Reading, or Attributes?
  323. @set op-same-owner @kbd{--same-owner}
  324. @set ref-same-owner @ref{Attributes}
  325. @set xref-same-owner @xref{Attributes}
  326. @set pxref-same-owner @pxref{Attributes}
  327. @set op-same-permissions @kbd{--same-permissions} (@kbd{--preserve-permissions}, @kbd{-p})
  328. @set ref-same-permissions @ref{Attributes}
  329. @set xref-same-permissions @xref{Attributes}
  330. @set pxref-same-permissions @pxref{Attributes}
  331. @c FIXME: or should it be Writing?
  332. @set op-show-omitted-dirs @kbd{--show-omitted-dirs}
  333. @set ref-show-omitted-dirs @ref{verbose}
  334. @set xref-show-omitted-dirs @xref{verbose}
  335. @set pxref-show-omitted-dirs @pxref{verbose}
  336. @set op-sparse @kbd{--sparse} (@kbd{-S})
  337. @set ref-sparse @ref{sparse}
  338. @set xref-sparse @xref{sparse}
  339. @set pxref-sparse @pxref{sparse}
  340. @set op-starting-file @kbd{--starting-file=@var{name}} (@kbd{-K @var{name}})
  341. @set ref-starting-file @ref{Scarce}
  342. @set xref-starting-file @xref{Scarce}
  343. @set pxref-starting-file @pxref{Scarce}
  344. @set op-strip-components @kbd{--strip-components}
  345. @set ref-strip-components @ref{--strip-components}
  346. @set xref-strip-components @xref{--strip-components}
  347. @set pxref-strip-components @pxref{--strip-components}
  348. @set op-suffix @kbd{--suffix=@var{suffix}}
  349. @set ref-suffix @ref{Backup options}
  350. @set xref-suffix @xref{Backup options}
  351. @set pxref-suffix @pxref{Backup options}
  352. @set op-tape-length @kbd{--tape-length=@var{1024-size}} (@kbd{-L @var{1024-size}})
  353. @set ref-tape-length @ref{Using Multiple Tapes}
  354. @set xref-tape-length @xref{Using Multiple Tapes}
  355. @set pxref-tape-length @pxref{Using Multiple Tapes}
  356. @set op-to-stdout @kbd{--to-stdout} (@kbd{-O})
  357. @set ref-to-stdout @ref{Writing}
  358. @set xref-to-stdout @xref{Writing}
  359. @set pxref-to-stdout @pxref{Writing}
  360. @set op-totals @kbd{--totals}
  361. @set ref-totals @ref{verbose}
  362. @set xref-totals @xref{verbose}
  363. @set pxref-totals @pxref{verbose}
  364. @set op-touch @kbd{--touch} (@kbd{-m})
  365. @set ref-touch @ref{Writing}
  366. @set xref-touch @xref{Writing}
  367. @set pxref-touch @pxref{Writing}
  368. @set op-unlink-first @kbd{--unlink-first} (@kbd{-U})
  369. @set ref-unlink-first @ref{Writing}
  370. @set xref-unlink-first @xref{Writing}
  371. @set pxref-unlink-first @pxref{Writing}
  372. @set op-update @kbd{--update} (@kbd{-u})
  373. @set ref-update @ref{update}
  374. @set xref-update @xref{update}
  375. @set pxref-update @pxref{update}
  376. @set op-use-compress-prog @kbd{--use-compress-prog=@var{program}}
  377. @set ref-use-compress-prog @ref{gzip}
  378. @set xref-use-compress-prog @xref{gzip}
  379. @set pxref-use-compress-prog @pxref{gzip}
  380. @set op-verbose @kbd{--verbose} (@kbd{-v})
  381. @set ref-verbose @ref{verbose}
  382. @set xref-verbose @xref{verbose}
  383. @set pxref-verbose @pxref{verbose}
  384. @set op-verify @kbd{--verify} (@kbd{-W})
  385. @set ref-verify @ref{verify}
  386. @set xref-verify @xref{verify}
  387. @set pxref-verify @pxref{verify}
  388. @set op-version @kbd{--version}
  389. @set ref-version @ref{help}
  390. @set xref-version @xref{help}
  391. @set pxref-version @pxref{help}
  392. @set op-volno-file @kbd{--volno-file=@var{file-of-number}}
  393. @set ref-volno-file @ref{Using Multiple Tapes}
  394. @set xref-volno-file @xref{Using Multiple Tapes}
  395. @set pxref-volno-file @pxref{Using Multiple Tapes}
  396. @set op-seek @kbd{--seek}
  397. @set ref-seek @ref{seek}
  398. @set xref-seek @xref{seek}
  399. @set pxref-seek @pxref{seek}
  400. @c Put everything in one index (arbitrarily chosen to be the concept index).
  401. @syncodeindex fn cp
  402. @syncodeindex ky cp
  403. @syncodeindex pg cp
  404. @syncodeindex vr cp
  405. @defindex op
  406. @syncodeindex op cp
  407. @copying
  408. This manual is for @acronym{GNU} @command{tar} (version
  409. @value{VERSION}, @value{UPDATED}), which creates and extracts files
  410. from archives.
  411. Copyright @copyright{} 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2001,
  412. 2003, 2004 Free Software Foundation, Inc.
  413. @quotation
  414. Permission is granted to copy, distribute and/or modify this document
  415. under the terms of the GNU Free Documentation License, Version 1.1 or
  416. any later version published by the Free Software Foundation; with the
  417. Invariant Sections being "GNU General Public License", with the
  418. Front-Cover Texts being ``A GNU Manual,'' and with the Back-Cover Texts
  419. as in (a) below. A copy of the license is included in the section
  420. entitled "GNU Free Documentation License".
  421. (a) The FSF's Back-Cover Text is: ``You are free to copy and modify
  422. this GNU Manual. Buying copies from GNU Press supports the FSF in
  423. developing GNU and promoting software freedom.''
  424. @end quotation
  425. @end copying
  426. @dircategory Archiving
  427. @direntry
  428. * Tar: (tar). Making tape (or disk) archives.
  429. @end direntry
  430. @dircategory Individual utilities
  431. @direntry
  432. * tar: (tar)tar invocation. Invoking @GNUTAR{}.
  433. @end direntry
  434. @shorttitlepage @acronym{GNU} @command{tar}
  435. @titlepage
  436. @title @acronym{GNU} tar: an archiver tool
  437. @subtitle @value{RENDITION} @value{VERSION}, @value{UPDATED}
  438. @author Melissa Weisshaus, Jay Fenlason,
  439. @author Thomas Bushnell, n/BSG, Amy Gorin
  440. @c he said to remove it: Fran@,{c}ois Pinard
  441. @c i'm thinking about how the author page *should* look. -mew 2may96
  442. @page
  443. @vskip 0pt plus 1filll
  444. @insertcopying
  445. @end titlepage
  446. @ifnottex
  447. @node Top
  448. @top @acronym{GNU} tar: an archiver tool
  449. @insertcopying
  450. @cindex file archival
  451. @cindex archiving files
  452. The first part of this master menu lists the major nodes in this Info
  453. document. The rest of the menu lists all the lower level nodes.
  454. @end ifnottex
  455. @c The master menu, created with texinfo-master-menu, goes here.
  456. @c (However, getdate.texi's menu is interpolated by hand.)
  457. @menu
  458. * Introduction::
  459. * Tutorial::
  460. * tar invocation::
  461. * operations::
  462. * Backups::
  463. * Choosing::
  464. * Date input formats::
  465. * Formats::
  466. * Media::
  467. * Free Software Needs Free Documentation::
  468. * Copying This Manual::
  469. * Index::
  470. @detailmenu
  471. --- The Detailed Node Listing ---
  472. Introduction
  473. * Book Contents:: What this Book Contains
  474. * Definitions:: Some Definitions
  475. * What tar Does:: What @command{tar} Does
  476. * Naming tar Archives:: How @command{tar} Archives are Named
  477. * Current status:: Current development status of @GNUTAR{}
  478. * Authors:: @GNUTAR{} Authors
  479. * Reports:: Reporting bugs or suggestions
  480. Tutorial Introduction to @command{tar}
  481. * assumptions::
  482. * stylistic conventions::
  483. * basic tar options:: Basic @command{tar} Operations and Options
  484. * frequent operations::
  485. * Two Frequent Options::
  486. * create:: How to Create Archives
  487. * list:: How to List Archives
  488. * extract:: How to Extract Members from an Archive
  489. * going further::
  490. Two Frequently Used Options
  491. * file tutorial::
  492. * verbose tutorial::
  493. * help tutorial::
  494. How to Create Archives
  495. * prepare for examples::
  496. * Creating the archive::
  497. * create verbose::
  498. * short create::
  499. * create dir::
  500. How to List Archives
  501. * list dir::
  502. How to Extract Members from an Archive
  503. * extracting archives::
  504. * extracting files::
  505. * extract dir::
  506. * failing commands::
  507. Invoking @GNUTAR{}
  508. * Synopsis::
  509. * using tar options::
  510. * Styles::
  511. * All Options::
  512. * help::
  513. * verbose::
  514. * interactive::
  515. The Three Option Styles
  516. * Mnemonic Options:: Mnemonic Option Style
  517. * Short Options:: Short Option Style
  518. * Old Options:: Old Option Style
  519. * Mixing:: Mixing Option Styles
  520. All @command{tar} Options
  521. * Operation Summary::
  522. * Option Summary::
  523. * Short Option Summary::
  524. @GNUTAR{} Operations
  525. * Basic tar::
  526. * Advanced tar::
  527. * create options::
  528. * extract options::
  529. * backup::
  530. * Applications::
  531. * looking ahead::
  532. Advanced @GNUTAR{} Operations
  533. * Operations::
  534. * append::
  535. * update::
  536. * concatenate::
  537. * delete::
  538. * compare::
  539. How to Add Files to Existing Archives: @code{--append}
  540. * appending files:: Appending Files to an Archive
  541. * multiple::
  542. Updating an Archive
  543. * how to update::
  544. Options Used by @code{--create}
  545. * Ignore Failed Read::
  546. Options Used by @code{--extract}
  547. * Reading:: Options to Help Read Archives
  548. * Writing:: Changing How @command{tar} Writes Files
  549. * Scarce:: Coping with Scarce Resources
  550. Options to Help Read Archives
  551. * read full records::
  552. * Ignore Zeros::
  553. Changing How @command{tar} Writes Files
  554. * Dealing with Old Files::
  555. * Overwrite Old Files::
  556. * Keep Old Files::
  557. * Keep Newer Files::
  558. * Unlink First::
  559. * Recursive Unlink::
  560. * Modification Times::
  561. * Setting Access Permissions::
  562. * Writing to Standard Output::
  563. * remove files::
  564. Coping with Scarce Resources
  565. * Starting File::
  566. * Same Order::
  567. Performing Backups and Restoring Files
  568. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  569. * Inc Dumps:: Using @command{tar} to Perform Incremental Dumps
  570. * incremental and listed-incremental:: The Incremental Options
  571. * Backup Levels:: Levels of Backups
  572. * Backup Parameters:: Setting Parameters for Backups and Restoration
  573. * Scripted Backups:: Using the Backup Scripts
  574. * Scripted Restoration:: Using the Restore Script
  575. Setting Parameters for Backups and Restoration
  576. * General-Purpose Variables::
  577. * Magnetic Tape Control::
  578. * User Hooks::
  579. * backup-specs example:: An Example Text of @file{Backup-specs}
  580. Choosing Files and Names for @command{tar}
  581. * file:: Choosing the Archive's Name
  582. * Selecting Archive Members::
  583. * files:: Reading Names from a File
  584. * exclude:: Excluding Some Files
  585. * Wildcards::
  586. * after:: Operating Only on New Files
  587. * recurse:: Descending into Directories
  588. * one:: Crossing Filesystem Boundaries
  589. Reading Names from a File
  590. * nul::
  591. Excluding Some Files
  592. * controlling pattern-patching with exclude::
  593. * problems with exclude::
  594. Crossing Filesystem Boundaries
  595. * directory:: Changing Directory
  596. * absolute:: Absolute File Names
  597. Date input formats
  598. * General date syntax:: Common rules.
  599. * Calendar date items:: 19 Dec 1994.
  600. * Time of day items:: 9:20pm.
  601. * Time zone items:: @sc{est}, @sc{pdt}, @sc{gmt}, ...
  602. * Day of week items:: Monday and others.
  603. * Relative items in date strings:: next tuesday, 2 years ago.
  604. * Pure numbers in date strings:: 19931219, 1440.
  605. * Seconds since the Epoch:: @@1078100502.
  606. * Authors of get_date:: Bellovin, Eggert, Salz, Berets, et al.
  607. Controlling the Archive Format
  608. * Portability:: Making @command{tar} Archives More Portable
  609. * Compression:: Using Less Space through Compression
  610. * Attributes:: Handling File Attributes
  611. * Standard:: The Standard Format
  612. * Extensions:: @acronym{GNU} Extensions to the Archive Format
  613. * cpio:: Comparison of @command{tar} and @command{cpio}
  614. Making @command{tar} Archives More Portable
  615. * Portable Names:: Portable Names
  616. * dereference:: Symbolic Links
  617. * old:: Old V7 Archives
  618. * posix:: @acronym{POSIX} archives
  619. * Checksumming:: Checksumming Problems
  620. * Large or Negative Values:: Large files, negative time stamps, etc.
  621. Using Less Space through Compression
  622. * gzip:: Creating and Reading Compressed Archives
  623. * sparse:: Archiving Sparse Files
  624. Tapes and Other Archive Media
  625. * Device:: Device selection and switching
  626. * Remote Tape Server::
  627. * Common Problems and Solutions::
  628. * Blocking:: Blocking
  629. * Many:: Many archives on one tape
  630. * Using Multiple Tapes:: Using Multiple Tapes
  631. * label:: Including a Label in the Archive
  632. * verify::
  633. * Write Protection::
  634. Blocking
  635. * Format Variations:: Format Variations
  636. * Blocking Factor:: The Blocking Factor of an Archive
  637. Many Archives on One Tape
  638. * Tape Positioning:: Tape Positions and Tape Marks
  639. * mt:: The @command{mt} Utility
  640. Using Multiple Tapes
  641. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  642. * Tape Files:: Tape Files
  643. Copying This Manual
  644. * GNU Free Documentation License:: License for copying this manual
  645. @end detailmenu
  646. @end menu
  647. @node Introduction
  648. @chapter Introduction
  649. @GNUTAR{} creates
  650. and manipulates @dfn{archives} which are actually collections of
  651. many other files; the program provides users with an organized and
  652. systematic method for controlling a large amount of data.
  653. The name ``tar'' originally came from the phrase ``Tape ARchive'', but
  654. archives need not (and these days, typically do not) reside on tapes.
  655. @menu
  656. * Book Contents:: What this Book Contains
  657. * Definitions:: Some Definitions
  658. * What tar Does:: What @command{tar} Does
  659. * Naming tar Archives:: How @command{tar} Archives are Named
  660. * Current status:: Current development status of @GNUTAR{}
  661. * Authors:: @GNUTAR{} Authors
  662. * Reports:: Reporting bugs or suggestions
  663. @end menu
  664. @node Book Contents
  665. @section What this Book Contains
  666. The first part of this chapter introduces you to various terms that will
  667. recur throughout the book. It also tells you who has worked on @GNUTAR{}
  668. and its documentation, and where you should send bug reports
  669. or comments.
  670. The second chapter is a tutorial (@pxref{Tutorial}) which provides a
  671. gentle introduction for people who are new to using @command{tar}. It is
  672. meant to be self contained, not requiring any reading from subsequent
  673. chapters to make sense. It moves from topic to topic in a logical,
  674. progressive order, building on information already explained.
  675. Although the tutorial is paced and structured to allow beginners to
  676. learn how to use @command{tar}, it is not intended solely for beginners.
  677. The tutorial explains how to use the three most frequently used
  678. operations (@samp{create}, @samp{list}, and @samp{extract}) as well as
  679. two frequently used options (@samp{file} and @samp{verbose}). The other
  680. chapters do not refer to the tutorial frequently; however, if a section
  681. discusses something which is a complex variant of a basic concept, there
  682. may be a cross reference to that basic concept. (The entire book,
  683. including the tutorial, assumes that the reader understands some basic
  684. concepts of using a Unix-type operating system; @pxref{Tutorial}.)
  685. The third chapter presents the remaining five operations, and
  686. information about using @command{tar} options and option syntax.
  687. @FIXME{this sounds more like a @acronym{GNU} Project Manuals Concept [tm] more
  688. than the reality. should think about whether this makes sense to say
  689. here, or not.} The other chapters are meant to be used as a
  690. reference. Each chapter presents everything that needs to be said
  691. about a specific topic.
  692. One of the chapters (@pxref{Date input formats}) exists in its
  693. entirety in other @acronym{GNU} manuals, and is mostly self-contained.
  694. In addition, one section of this manual (@pxref{Standard}) contains a
  695. big quote which is taken directly from @command{tar} sources.
  696. In general, we give both long and short (abbreviated) option names
  697. at least once in each section where the relevant option is covered, so
  698. that novice readers will become familiar with both styles. (A few
  699. options have no short versions, and the relevant sections will
  700. indicate this.)
  701. @node Definitions
  702. @section Some Definitions
  703. @cindex archive
  704. @cindex tar archive
  705. The @command{tar} program is used to create and manipulate @command{tar}
  706. archives. An @dfn{archive} is a single file which contains the contents
  707. of many files, while still identifying the names of the files, their
  708. owner(s), and so forth. (In addition, archives record access
  709. permissions, user and group, size in bytes, and last modification time.
  710. Some archives also record the file names in each archived directory, as
  711. well as other file and directory information.) You can use @command{tar}
  712. to @dfn{create} a new archive in a specified directory.
  713. @cindex member
  714. @cindex archive member
  715. @cindex file name
  716. @cindex member name
  717. The files inside an archive are called @dfn{members}. Within this
  718. manual, we use the term @dfn{file} to refer only to files accessible in
  719. the normal ways (by @command{ls}, @command{cat}, and so forth), and the term
  720. @dfn{member} to refer only to the members of an archive. Similarly, a
  721. @dfn{file name} is the name of a file, as it resides in the filesystem,
  722. and a @dfn{member name} is the name of an archive member within the
  723. archive.
  724. @cindex extraction
  725. @cindex unpacking
  726. The term @dfn{extraction} refers to the process of copying an archive
  727. member (or multiple members) into a file in the filesystem. Extracting
  728. all the members of an archive is often called @dfn{extracting the
  729. archive}. The term @dfn{unpack} can also be used to refer to the
  730. extraction of many or all the members of an archive. Extracting an
  731. archive does not destroy the archive's structure, just as creating an
  732. archive does not destroy the copies of the files that exist outside of
  733. the archive. You may also @dfn{list} the members in a given archive
  734. (this is often thought of as ``printing'' them to the standard output,
  735. or the command line), or @dfn{append} members to a pre-existing archive.
  736. All of these operations can be performed using @command{tar}.
  737. @node What tar Does
  738. @section What @command{tar} Does
  739. @cindex tar
  740. The @command{tar} program provides the ability to create @command{tar}
  741. archives, as well as various other kinds of manipulation. For example,
  742. you can use @command{tar} on previously created archives to extract files,
  743. to store additional files, or to update or list files which were already
  744. stored.
  745. Initially, @command{tar} archives were used to store files conveniently on
  746. magnetic tape. The name @command{tar} comes from this use; it stands for
  747. @code{t}ape @code{ar}chiver. Despite the utility's name, @command{tar} can
  748. direct its output to available devices, files, or other programs (using
  749. pipes). @command{tar} may even access remote devices or files (as archives).
  750. @FIXME{the following table entries need a bit of work..}
  751. You can use @command{tar} archives in many ways. We want to stress a few
  752. of them: storage, backup, and transportation.
  753. @table @asis
  754. @item Storage
  755. Often, @command{tar} archives are used to store related files for
  756. convenient file transfer over a network. For example, the
  757. @acronym{GNU} Project distributes its software bundled into
  758. @command{tar} archives, so that all the files relating to a particular
  759. program (or set of related programs) can be transferred as a single
  760. unit.
  761. A magnetic tape can store several files in sequence. However, the tape
  762. has no names for these files; it only knows their relative position on
  763. the tape. One way to store several files on one tape and retain their
  764. names is by creating a @command{tar} archive. Even when the basic transfer
  765. mechanism can keep track of names, as FTP can, the nuisance of handling
  766. multiple files, directories, and multiple links makes @command{tar}
  767. archives useful.
  768. Archive files are also used for long-term storage. You can think of
  769. this as transportation from the present into the future. (It is a
  770. science-fiction idiom that you can move through time as well as in
  771. space; the idea here is that @command{tar} can be used to move archives in
  772. all dimensions, even time!)
  773. @item Backup
  774. Because the archive created by @command{tar} is capable of preserving
  775. file information and directory structure, @command{tar} is commonly
  776. used for performing full and incremental backups of disks. A backup
  777. puts a collection of files (possibly pertaining to many users and
  778. projects) together on a disk or a tape. This guards against
  779. accidental destruction of the information in those files.
  780. @GNUTAR{} has special features that allow it to be
  781. used to make incremental and full dumps of all the files in a
  782. filesystem.
  783. @item Transportation
  784. You can create an archive on one system, transfer it to another system,
  785. and extract the contents there. This allows you to transport a group of
  786. files from one system to another.
  787. @end table
  788. @node Naming tar Archives
  789. @section How @command{tar} Archives are Named
  790. Conventionally, @command{tar} archives are given names ending with
  791. @samp{.tar}. This is not necessary for @command{tar} to operate properly,
  792. but this manual follows that convention in order to accustom readers to
  793. it and to make examples more clear.
  794. @cindex tar file
  795. @cindex entry
  796. @cindex tar entry
  797. Often, people refer to @command{tar} archives as ``@command{tar} files,'' and
  798. archive members as ``files'' or ``entries''. For people familiar with
  799. the operation of @command{tar}, this causes no difficulty. However, in
  800. this manual, we consistently refer to ``archives'' and ``archive
  801. members'' to make learning to use @command{tar} easier for novice users.
  802. @node Current status
  803. @section Current development status of @GNUTAR{}
  804. @GNUTAR{} is currently in the process of active development, whose
  805. primary aims are:
  806. @itemize @bullet
  807. @item Improve compatibility between @GNUTAR{} and other @command{tar}
  808. implementations.
  809. @item Switch to using @acronym{POSIX} archives.
  810. @item Revise sparse file handling and multiple volume processing.
  811. @item Merge with the @acronym{GNU} @code{paxutils} project.
  812. @end itemize
  813. Some of these aims are already attained, while others are still
  814. being worked upon. From the point of view of an end user, the
  815. following issues need special mentioning:
  816. @table @asis
  817. @item Use of short option @option{-o}.
  818. Earlier versions of @GNUTAR{} understood @option{-o} command line
  819. option as a synonym for @option{--old-archive}.
  820. @GNUTAR{} starting from version 1.13.90 understands this option as
  821. a synonym for @option{--no-same-owner}. This is compatible with
  822. UNIX98 @command{tar} implementations.
  823. However, to facilitate transition, @option{-o} option retains its
  824. old semantics when it is used with one of archive-creation commands.
  825. Users are encouraged to use @value{op-format-oldgnu} instead.
  826. It is especially important, since versions of @acronym{GNU} Automake
  827. up to and including 1.8.4 invoke tar with this option to produce
  828. distribution tarballs. @xref{Formats,v7}, for the detailed discussion
  829. of this issue and its implications.
  830. Future versions of @GNUTAR{} will understand @option{-o} only as a
  831. synonym for @option{--no-same-owner}.
  832. @item Use of short option @option{-l}
  833. Earlier versions of @GNUTAR{} understood @option{-l} option as a
  834. synonym for @samp{--one-file-system}. Such usage is deprecated.
  835. For compatibility with other implementations future versions of
  836. @GNUTAR{} will understand this option as a synonym for
  837. @option{--check-links}.
  838. @item Use of options @option{--portability} and @option{--old-archive}
  839. These options are deprecated. Please use @option{--format=v7} instead.
  840. @item Use of option @option{--posix}
  841. This option is deprecated. Please use @option{--format=posix} instead.
  842. @end table
  843. @node Authors
  844. @section @GNUTAR{} Authors
  845. @GNUTAR{} was originally written by John Gilmore,
  846. and modified by many people. The @acronym{GNU} enhancements were
  847. written by Jay Fenlason, then Joy Kendall, and the whole package has
  848. been further maintained by Thomas Bushnell, n/BSG, Fran@,{c}ois
  849. Pinard, Paul Eggert, and finally Sergey Poznyakoff with the help of
  850. numerous and kind users.
  851. We wish to stress that @command{tar} is a collective work, and owes much to
  852. all those people who reported problems, offered solutions and other
  853. insights, or shared their thoughts and suggestions. An impressive, yet
  854. partial list of those contributors can be found in the @file{THANKS}
  855. file from the @GNUTAR{} distribution.
  856. @FIXME{i want all of these names mentioned, Absolutely. BUT, i'm not
  857. sure i want to spell out the history in this detail, at least not for
  858. the printed book. i'm just not sure it needs to be said this way.
  859. i'll think about it.}
  860. @FIXME{History is more important, and surely more interesting, than
  861. actual names. Quoting names without history would be meaningless. FP}
  862. Jay Fenlason put together a draft of a @GNUTAR{}
  863. manual, borrowing notes from the original man page from John Gilmore.
  864. This was withdrawn in version 1.11. Thomas Bushnell, n/BSG and Amy
  865. Gorin worked on a tutorial and manual for @GNUTAR{}.
  866. Fran@,{c}ois Pinard put version 1.11.8 of the manual together by
  867. taking information from all these sources and merging them. Melissa
  868. Weisshaus finally edited and redesigned the book to create version
  869. 1.12. @FIXME{update version number as necessary; i'm being
  870. optimistic!} @FIXME{Someone [maybe karl berry? maybe bob chassell?
  871. maybe melissa? maybe julie sussman?] needs to properly index the
  872. thing.}
  873. For version 1.12, Daniel Hagerty contributed a great deal of technical
  874. consulting. In particular, he is the primary author of @ref{Backups}.
  875. In July, 2003 @GNUTAR{} was put on CVS at savannah.gnu.org
  876. (see @url{http://savannah.gnu.org/projects/tar}), and
  877. active development and maintenance work has started
  878. again. Currently @GNUTAR{} is being maintained by Paul Eggert, Sergey
  879. Poznyakoff and Jeff Bailey.
  880. Support for @acronym{POSIX} archives was added by Sergey Poznyakoff.
  881. @node Reports
  882. @section Reporting bugs or suggestions
  883. @cindex bug reports
  884. @cindex reporting bugs
  885. If you find problems or have suggestions about this program or manual,
  886. please report them to @file{bug-tar@@gnu.org}.
  887. When reporting a bug, please be sure to include as much detail as
  888. possible, in order to reproduce it. @FIXME{Be more specific, I'd
  889. like to make this node as detailed as 'Bug reporting' node in Emacs
  890. manual}.
  891. @node Tutorial
  892. @chapter Tutorial Introduction to @command{tar}
  893. This chapter guides you through some basic examples of three @command{tar}
  894. operations: @samp{--create}, @samp{--list}, and @samp{--extract}. If
  895. you already know how to use some other version of @command{tar}, then you
  896. may not need to read this chapter. This chapter omits most complicated
  897. details about how @command{tar} works.
  898. @menu
  899. * assumptions::
  900. * stylistic conventions::
  901. * basic tar options:: Basic @command{tar} Operations and Options
  902. * frequent operations::
  903. * Two Frequent Options::
  904. * create:: How to Create Archives
  905. * list:: How to List Archives
  906. * extract:: How to Extract Members from an Archive
  907. * going further::
  908. @end menu
  909. @node assumptions
  910. @section Assumptions this Tutorial Makes
  911. This chapter is paced to allow beginners to learn about @command{tar}
  912. slowly. At the same time, we will try to cover all the basic aspects of
  913. these three operations. In order to accomplish both of these tasks, we
  914. have made certain assumptions about your knowledge before reading this
  915. manual, and the hardware you will be using:
  916. @itemize @bullet
  917. @item
  918. Before you start to work through this tutorial, you should understand
  919. what the terms ``archive'' and ``archive member'' mean
  920. (@pxref{Definitions}). In addition, you should understand something
  921. about how Unix-type operating systems work, and you should know how to
  922. use some basic utilities. For example, you should know how to create,
  923. list, copy, rename, edit, and delete files and directories; how to
  924. change between directories; and how to figure out where you are in the
  925. filesystem. You should have some basic understanding of directory
  926. structure and how files are named according to which directory they are
  927. in. You should understand concepts such as standard output and standard
  928. input, what various definitions of the term ``argument'' mean, and the
  929. differences between relative and absolute path names. @FIXME{and what
  930. else?}
  931. @item
  932. This manual assumes that you are working from your own home directory
  933. (unless we state otherwise). In this tutorial, you will create a
  934. directory to practice @command{tar} commands in. When we show path names,
  935. we will assume that those paths are relative to your home directory.
  936. For example, my home directory path is @file{/home/fsf/melissa}. All of
  937. my examples are in a subdirectory of the directory named by that path
  938. name; the subdirectory is called @file{practice}.
  939. @item
  940. In general, we show examples of archives which exist on (or can be
  941. written to, or worked with from) a directory on a hard disk. In most
  942. cases, you could write those archives to, or work with them on any other
  943. device, such as a tape drive. However, some of the later examples in
  944. the tutorial and next chapter will not work on tape drives.
  945. Additionally, working with tapes is much more complicated than working
  946. with hard disks. For these reasons, the tutorial does not cover working
  947. with tape drives. @xref{Media}, for complete information on using
  948. @command{tar} archives with tape drives.
  949. @FIXME{this is a cop out. need to add some simple tape drive info.}
  950. @end itemize
  951. @node stylistic conventions
  952. @section Stylistic Conventions
  953. In the examples, @samp{$} represents a typical shell prompt. It
  954. precedes lines you should type; to make this more clear, those lines are
  955. shown in @kbd{this font}, as opposed to lines which represent the
  956. computer's response; those lines are shown in @code{this font}, or
  957. sometimes @samp{like this}.
  958. @c When we have lines which are too long to be
  959. @c displayed in any other way, we will show them like this:
  960. @node basic tar options
  961. @section Basic @command{tar} Operations and Options
  962. @command{tar} can take a wide variety of arguments which specify and define
  963. the actions it will have on the particular set of files or the archive.
  964. The main types of arguments to @command{tar} fall into one of two classes:
  965. operations, and options.
  966. Some arguments fall into a class called @dfn{operations}; exactly one of
  967. these is both allowed and required for any instance of using @command{tar};
  968. you may @emph{not} specify more than one. People sometimes speak of
  969. @dfn{operating modes}. You are in a particular operating mode when you
  970. have specified the operation which specifies it; there are eight
  971. operations in total, and thus there are eight operating modes.
  972. The other arguments fall into the class known as @dfn{options}. You are
  973. not required to specify any options, and you are allowed to specify more
  974. than one at a time (depending on the way you are using @command{tar} at
  975. that time). Some options are used so frequently, and are so useful for
  976. helping you type commands more carefully that they are effectively
  977. ``required''. We will discuss them in this chapter.
  978. You can write most of the @command{tar} operations and options in any
  979. of three forms: long (mnemonic) form, short form, and old style. Some
  980. of the operations and options have no short or ``old'' forms; however,
  981. the operations and options which we will cover in this tutorial have
  982. corresponding abbreviations. @FIXME{make sure this is still the case,
  983. at the end}We will indicate those abbreviations appropriately to get
  984. you used to seeing them. (Note that the ``old style'' option forms
  985. exist in @GNUTAR{} for compatibility with Unix
  986. @command{tar}. We present a full discussion of this way of writing
  987. options and operations appears in @ref{Old Options}, and we discuss
  988. the other two styles of writing options in @ref{Mnemonic Options}, and
  989. @ref{Short Options}.)
  990. In the examples and in the text of this tutorial, we usually use the
  991. long forms of operations and options; but the ``short'' forms produce
  992. the same result and can make typing long @command{tar} commands easier.
  993. For example, instead of typing
  994. @smallexample
  995. @kbd{tar --create --verbose --file=afiles.tar apple angst aspic}
  996. @end smallexample
  997. @noindent
  998. you can type
  999. @smallexample
  1000. @kbd{tar -c -v -f afiles.tar apple angst aspic}
  1001. @end smallexample
  1002. @noindent
  1003. or even
  1004. @smallexample
  1005. @kbd{tar -cvf afiles.tar apple angst aspic}
  1006. @end smallexample
  1007. @noindent
  1008. For more information on option syntax, see @ref{Advanced tar}. In
  1009. discussions in the text, when we name an option by its long form, we
  1010. also give the corresponding short option in parentheses.
  1011. The term, ``option'', can be confusing at times, since ``operations''
  1012. are often lumped in with the actual, @emph{optional} ``options'' in certain
  1013. general class statements. For example, we just talked about ``short and
  1014. long forms of options and operations''. However, experienced @command{tar}
  1015. users often refer to these by shorthand terms such as, ``short and long
  1016. options''. This term assumes that the ``operations'' are included, also.
  1017. Context will help you determine which definition of ``options'' to use.
  1018. Similarly, the term ``command'' can be confusing, as it is often used in
  1019. two different ways. People sometimes refer to @command{tar} ``commands''.
  1020. A @command{tar} @dfn{command} is the entire command line of user input
  1021. which tells @command{tar} what to do --- including the operation, options,
  1022. and any arguments (file names, pipes, other commands, etc). However,
  1023. you will also sometimes hear the term ``the @command{tar} command''. When
  1024. the word ``command'' is used specifically like this, a person is usually
  1025. referring to the @command{tar} @emph{operation}, not the whole line.
  1026. Again, use context to figure out which of the meanings the speaker
  1027. intends.
  1028. @node frequent operations
  1029. @section The Three Most Frequently Used Operations
  1030. Here are the three most frequently used operations (both short and long
  1031. forms), as well as a brief description of their meanings. The rest of
  1032. this chapter will cover how to use these operations in detail. We will
  1033. present the rest of the operations in the next chapter.
  1034. @table @kbd
  1035. @item --create
  1036. @itemx -c
  1037. Create a new @command{tar} archive.
  1038. @item --list
  1039. @itemx -t
  1040. List the contents of an archive.
  1041. @item --extract
  1042. @itemx -x
  1043. Extract one or more members from an archive.
  1044. @end table
  1045. @node Two Frequent Options
  1046. @section Two Frequently Used Options
  1047. To understand how to run @command{tar} in the three operating modes listed
  1048. previously, you also need to understand how to use two of the options to
  1049. @command{tar}: @samp{--file} (which takes an archive file as an argument)
  1050. and @samp{--verbose}. (You are usually not @emph{required} to specify
  1051. either of these options when you run @command{tar}, but they can be very
  1052. useful in making things more clear and helping you avoid errors.)
  1053. @menu
  1054. * file tutorial::
  1055. * verbose tutorial::
  1056. * help tutorial::
  1057. @end menu
  1058. @node file tutorial
  1059. @unnumberedsubsec The @samp{--file} Option
  1060. @table @kbd
  1061. @item --file=@var{archive-name}
  1062. @itemx -f @var{archive-name}
  1063. Specify the name of an archive file.
  1064. @end table
  1065. You can specify an argument for the @value{op-file} option whenever you
  1066. use @command{tar}; this option determines the name of the archive file
  1067. that @command{tar} will work on.
  1068. If you don't specify this argument, then @command{tar} will use a
  1069. default, usually some physical tape drive attached to your machine.
  1070. If there is no tape drive attached, or the default is not meaningful,
  1071. then @command{tar} will print an error message. The error message might
  1072. look roughly like one of the following:
  1073. @smallexample
  1074. tar: can't open /dev/rmt8 : No such device or address
  1075. tar: can't open /dev/rsmt0 : I/O error
  1076. @end smallexample
  1077. @noindent
  1078. To avoid confusion, we recommend that you always specify an archive file
  1079. name by using @value{op-file} when writing your @command{tar} commands.
  1080. For more information on using the @value{op-file} option, see
  1081. @ref{file}.
  1082. @node verbose tutorial
  1083. @unnumberedsubsec The @samp{--verbose} Option
  1084. @table @kbd
  1085. @item --verbose
  1086. @itemx -v
  1087. Show the files being worked on as @command{tar} is running.
  1088. @end table
  1089. @value{op-verbose} shows details about the results of running
  1090. @command{tar}. This can be especially useful when the results might not be
  1091. obvious. For example, if you want to see the progress of @command{tar} as
  1092. it writes files into the archive, you can use the @samp{--verbose}
  1093. option. In the beginning, you may find it useful to use
  1094. @samp{--verbose} at all times; when you are more accustomed to
  1095. @command{tar}, you will likely want to use it at certain times but not at
  1096. others. We will use @samp{--verbose} at times to help make something
  1097. clear, and we will give many examples both using and not using
  1098. @samp{--verbose} to show the differences.
  1099. Sometimes, a single instance of @samp{--verbose} on the command line
  1100. will show a full, @samp{ls} style listing of an archive or files,
  1101. @c FIXME: Describe the exact output format, e.g., how hard links are displayed.
  1102. giving sizes, owners, and similar information. Other times,
  1103. @samp{--verbose} will only show files or members that the particular
  1104. operation is operating on at the time. In the latter case, you can
  1105. use @samp{--verbose} twice in a command to get a listing such as that
  1106. in the former case. For example, instead of saying
  1107. @smallexample
  1108. @kbd{tar -cvf afiles.tar apple angst aspic}
  1109. @end smallexample
  1110. @noindent
  1111. above, you might say
  1112. @smallexample
  1113. @kbd{tar -cvvf afiles.tar apple angst aspic}
  1114. @end smallexample
  1115. @noindent
  1116. This works equally well using short or long forms of options. Using
  1117. long forms, you would simply write out the mnemonic form of the option
  1118. twice, like this:
  1119. @smallexample
  1120. $ @kbd{tar --create --verbose --verbose @dots{}}
  1121. @end smallexample
  1122. @noindent
  1123. Note that you must double the hyphens properly each time.
  1124. Later in the tutorial, we will give examples using @w{@samp{--verbose
  1125. --verbose}}.
  1126. @node help tutorial
  1127. @unnumberedsubsec Getting Help: Using the @code{--help} Option
  1128. @table @kbd
  1129. @item --help
  1130. The @samp{--help} option to @command{tar} prints out a very brief list of
  1131. all operations and option available for the current version of
  1132. @command{tar} available on your system.
  1133. @end table
  1134. @node create
  1135. @section How to Create Archives
  1136. @UNREVISED
  1137. One of the basic operations of @command{tar} is @value{op-create}, which
  1138. you use to create a @command{tar} archive. We will explain
  1139. @samp{--create} first because, in order to learn about the other
  1140. operations, you will find it useful to have an archive available to
  1141. practice on.
  1142. To make this easier, in this section you will first create a directory
  1143. containing three files. Then, we will show you how to create an
  1144. @emph{archive} (inside the new directory). Both the directory, and
  1145. the archive are specifically for you to practice on. The rest of this
  1146. chapter and the next chapter will show many examples using this
  1147. directory and the files you will create: some of those files may be
  1148. other directories and other archives.
  1149. The three files you will archive in this example are called
  1150. @file{blues}, @file{folk}, and @file{jazz}. The archive is called
  1151. @file{collection.tar}.
  1152. This section will proceed slowly, detailing how to use @samp{--create}
  1153. in @code{verbose} mode, and showing examples using both short and long
  1154. forms. In the rest of the tutorial, and in the examples in the next
  1155. chapter, we will proceed at a slightly quicker pace. This section
  1156. moves more slowly to allow beginning users to understand how
  1157. @command{tar} works.
  1158. @menu
  1159. * prepare for examples::
  1160. * Creating the archive::
  1161. * create verbose::
  1162. * short create::
  1163. * create dir::
  1164. @end menu
  1165. @node prepare for examples
  1166. @subsection Preparing a Practice Directory for Examples
  1167. To follow along with this and future examples, create a new directory
  1168. called @file{practice} containing files called @file{blues}, @file{folk}
  1169. and @file{jazz}. The files can contain any information you like:
  1170. ideally, they should contain information which relates to their names,
  1171. and be of different lengths. Our examples assume that @file{practice}
  1172. is a subdirectory of your home directory.
  1173. Now @command{cd} to the directory named @file{practice}; @file{practice}
  1174. is now your @dfn{working directory}. (@emph{Please note}: Although
  1175. the full path name of this directory is
  1176. @file{/@var{homedir}/practice}, in our examples we will refer to
  1177. this directory as @file{practice}; the @var{homedir} is presumed.
  1178. In general, you should check that the files to be archived exist where
  1179. you think they do (in the working directory) by running @command{ls}.
  1180. Because you just created the directory and the files and have changed to
  1181. that directory, you probably don't need to do that this time.
  1182. It is very important to make sure there isn't already a file in the
  1183. working directory with the archive name you intend to use (in this case,
  1184. @samp{collection.tar}), or that you don't care about its contents.
  1185. Whenever you use @samp{create}, @command{tar} will erase the current
  1186. contents of the file named by @value{op-file} if it exists. @command{tar}
  1187. will not tell you if you are about to overwrite an archive unless you
  1188. specify an option which does this. @FIXME{xref to the node for
  1189. --backup!}To add files to an existing archive, you need to use a
  1190. different option, such as @value{op-append}; see @ref{append} for
  1191. information on how to do this.
  1192. @node Creating the archive
  1193. @subsection Creating the Archive
  1194. To place the files @file{blues}, @file{folk}, and @file{jazz} into an
  1195. archive named @file{collection.tar}, use the following command:
  1196. @smallexample
  1197. $ @kbd{tar --create --file=collection.tar blues folk jazz}
  1198. @end smallexample
  1199. The order of the arguments is not very important, @emph{when using long
  1200. option forms}. You could also say:
  1201. @smallexample
  1202. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  1203. @end smallexample
  1204. @noindent
  1205. However, you can see that this order is harder to understand; this is
  1206. why we will list the arguments in the order that makes the commands
  1207. easiest to understand (and we encourage you to do the same when you use
  1208. @command{tar}, to avoid errors).
  1209. Note that the part of the command which says,
  1210. @w{@kbd{--file=collection.tar}} is considered to be @emph{one} argument.
  1211. If you substituted any other string of characters for
  1212. @kbd{collection.tar}, then that string would become the name of the
  1213. archive file you create.
  1214. The order of the options becomes more important when you begin to use
  1215. short forms. With short forms, if you type commands in the wrong order
  1216. (even if you type them correctly in all other ways), you may end up with
  1217. results you don't expect. For this reason, it is a good idea to get
  1218. into the habit of typing options in the order that makes inherent sense.
  1219. @xref{short create}, for more information on this.
  1220. In this example, you type the command as shown above: @samp{--create}
  1221. is the operation which creates the new archive
  1222. (@file{collection.tar}), and @samp{--file} is the option which lets
  1223. you give it the name you chose. The files, @file{blues}, @file{folk},
  1224. and @file{jazz}, are now members of the archive, @file{collection.tar}
  1225. (they are @dfn{file name arguments} to the @samp{--create} operation).
  1226. @FIXME{xref here to the discussion of file name args?}Now that they are
  1227. in the archive, they are called @emph{archive members}, not files.
  1228. (@pxref{Definitions,members}).
  1229. When you create an archive, you @emph{must} specify which files you
  1230. want placed in the archive. If you do not specify any archive
  1231. members, @GNUTAR{} will complain.
  1232. If you now list the contents of the working directory (@kbd{ls}), you will
  1233. find the archive file listed as well as the files you saw previously:
  1234. @smallexample
  1235. blues folk jazz collection.tar
  1236. @end smallexample
  1237. @noindent
  1238. Creating the archive @samp{collection.tar} did not destroy the copies of
  1239. the files in the directory.
  1240. Keep in mind that if you don't indicate an operation, @command{tar} will not
  1241. run and will prompt you for one. If you don't name any files, @command{tar}
  1242. will complain. You must have write access to the working directory,
  1243. or else you will not be able to create an archive in that directory.
  1244. @emph{Caution}: Do not attempt to use @value{op-create} to add files to
  1245. an existing archive; it will delete the archive and write a new one.
  1246. Use @value{op-append} instead. @xref{append}.
  1247. @node create verbose
  1248. @subsection Running @samp{--create} with @samp{--verbose}
  1249. If you include the @value{op-verbose} option on the command line,
  1250. @command{tar} will list the files it is acting on as it is working. In
  1251. verbose mode, the @code{create} example above would appear as:
  1252. @smallexample
  1253. $ @kbd{tar --create --verbose --file=collection.tar blues folk jazz}
  1254. blues
  1255. folk
  1256. jazz
  1257. @end smallexample
  1258. This example is just like the example we showed which did not use
  1259. @samp{--verbose}, except that @command{tar} generated the remaining lines
  1260. @iftex
  1261. (note the different font styles).
  1262. @end iftex
  1263. @ifinfo
  1264. .
  1265. @end ifinfo
  1266. In the rest of the examples in this chapter, we will frequently use
  1267. @code{verbose} mode so we can show actions or @command{tar} responses that
  1268. you would otherwise not see, and which are important for you to
  1269. understand.
  1270. @node short create
  1271. @subsection Short Forms with @samp{create}
  1272. As we said before, the @value{op-create} operation is one of the most
  1273. basic uses of @command{tar}, and you will use it countless times.
  1274. Eventually, you will probably want to use abbreviated (or ``short'')
  1275. forms of options. A full discussion of the three different forms that
  1276. options can take appears in @ref{Styles}; for now, here is what the
  1277. previous example (including the @value{op-verbose} option) looks like
  1278. using short option forms:
  1279. @smallexample
  1280. $ @kbd{tar -cvf collection.tar blues folk jazz}
  1281. blues
  1282. folk
  1283. jazz
  1284. @end smallexample
  1285. @noindent
  1286. As you can see, the system responds the same no matter whether you use
  1287. long or short option forms.
  1288. @FIXME{i don't like how this is worded:} One difference between using
  1289. short and long option forms is that, although the exact placement of
  1290. arguments following options is no more specific when using short forms,
  1291. it is easier to become confused and make a mistake when using short
  1292. forms. For example, suppose you attempted the above example in the
  1293. following way:
  1294. @smallexample
  1295. $ @kbd{tar -cfv collection.tar blues folk jazz}
  1296. @end smallexample
  1297. @noindent
  1298. In this case, @command{tar} will make an archive file called @file{v},
  1299. containing the files @file{blues}, @file{folk}, and @file{jazz}, because
  1300. the @samp{v} is the closest ``file name'' to the @samp{-f} option, and
  1301. is thus taken to be the chosen archive file name. @command{tar} will try
  1302. to add a file called @file{collection.tar} to the @file{v} archive file;
  1303. if the file @file{collection.tar} did not already exist, @command{tar} will
  1304. report an error indicating that this file does not exist. If the file
  1305. @file{collection.tar} does already exist (e.g., from a previous command
  1306. you may have run), then @command{tar} will add this file to the archive.
  1307. Because the @samp{-v} option did not get registered, @command{tar} will not
  1308. run under @samp{verbose} mode, and will not report its progress.
  1309. The end result is that you may be quite confused about what happened,
  1310. and possibly overwrite a file. To illustrate this further, we will show
  1311. you how an example we showed previously would look using short forms.
  1312. This example,
  1313. @smallexample
  1314. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  1315. @end smallexample
  1316. @noindent
  1317. is confusing as it is. When shown using short forms, however, it
  1318. becomes much more so:
  1319. @smallexample
  1320. $ @kbd{tar blues -c folk -f collection.tar jazz}
  1321. @end smallexample
  1322. @noindent
  1323. It would be very easy to put the wrong string of characters
  1324. immediately following the @samp{-f}, but doing that could sacrifice
  1325. valuable data.
  1326. For this reason, we recommend that you pay very careful attention to
  1327. the order of options and placement of file and archive names,
  1328. especially when using short option forms. Not having the option name
  1329. written out mnemonically can affect how well you remember which option
  1330. does what, and therefore where different names have to be placed.
  1331. (Placing options in an unusual order can also cause @command{tar} to
  1332. report an error if you have set the shell environment variable
  1333. @env{POSIXLY_CORRECT}.)
  1334. @node create dir
  1335. @subsection Archiving Directories
  1336. @cindex Archiving Directories
  1337. @cindex Directories, Archiving
  1338. You can archive a directory by specifying its directory name as a
  1339. file name argument to @command{tar}. The files in the directory will be
  1340. archived relative to the working directory, and the directory will be
  1341. re-created along with its contents when the archive is extracted.
  1342. To archive a directory, first move to its superior directory. If you
  1343. have followed the previous instructions in this tutorial, you should
  1344. type:
  1345. @smallexample
  1346. $ @kbd{cd ..}
  1347. $
  1348. @end smallexample
  1349. @noindent
  1350. This will put you into the directory which contains @file{practice},
  1351. i.e. your home directory. Once in the superior directory, you can
  1352. specify the subdirectory, @file{practice}, as a file name argument. To
  1353. store @file{practice} in the new archive file @file{music.tar}, type:
  1354. @smallexample
  1355. $ @kbd{tar --create --verbose --file=music.tar practice}
  1356. @end smallexample
  1357. @noindent
  1358. @command{tar} should output:
  1359. @smallexample
  1360. practice/
  1361. practice/blues
  1362. practice/folk
  1363. practice/jazz
  1364. practice/collection.tar
  1365. @end smallexample
  1366. Note that the archive thus created is not in the subdirectory
  1367. @file{practice}, but rather in the current working directory---the
  1368. directory from which @command{tar} was invoked. Before trying to archive a
  1369. directory from its superior directory, you should make sure you have
  1370. write access to the superior directory itself, not only the directory
  1371. you are trying archive with @command{tar}. For example, you will probably
  1372. not be able to store your home directory in an archive by invoking
  1373. @command{tar} from the root directory; @value{xref-absolute-names}. (Note
  1374. also that @file{collection.tar}, the original archive file, has itself
  1375. been archived. @command{tar} will accept any file as a file to be
  1376. archived, regardless of its content. When @file{music.tar} is
  1377. extracted, the archive file @file{collection.tar} will be re-written
  1378. into the file system).
  1379. If you give @command{tar} a command such as
  1380. @smallexample
  1381. $ @kbd{tar --create --file=foo.tar .}
  1382. @end smallexample
  1383. @noindent
  1384. @command{tar} will report @samp{tar: ./foo.tar is the archive; not
  1385. dumped}. This happens because @command{tar} creates the archive
  1386. @file{foo.tar} in the current directory before putting any files into
  1387. it. Then, when @command{tar} attempts to add all the files in the
  1388. directory @file{.} to the archive, it notices that the file
  1389. @file{./foo.tar} is the same as the archive @file{foo.tar}, and skips
  1390. it. (It makes no sense to put an archive into itself.) @GNUTAR{}
  1391. will continue in this case, and create the archive
  1392. normally, except for the exclusion of that one file. (@emph{Please
  1393. note:} Other versions of @command{tar} are not so clever; they will
  1394. enter an infinite loop when this happens, so you should not depend on
  1395. this behavior unless you are certain you are running @GNUTAR{}.)
  1396. @FIXME{bob doesn't like this sentence, since he does
  1397. it all the time, and we've been doing it in the editing passes for
  1398. this manual: In general, make sure that the archive is not inside a
  1399. directory being dumped.}
  1400. @node list
  1401. @section How to List Archives
  1402. Frequently, you will find yourself wanting to determine exactly what a
  1403. particular archive contains. You can use the @value{op-list} operation
  1404. to get the member names as they currently appear in the archive, as well
  1405. as various attributes of the files at the time they were archived. For
  1406. example, you can examine the archive @file{collection.tar} that you
  1407. created in the last section with the command,
  1408. @smallexample
  1409. $ @kbd{tar --list --file=collection.tar}
  1410. @end smallexample
  1411. @noindent
  1412. The output of @command{tar} would then be:
  1413. @smallexample
  1414. blues
  1415. folk
  1416. jazz
  1417. @end smallexample
  1418. @FIXME{we hope this will change. if it doesn't, need to show the
  1419. creation of bfiles somewhere above!!! : }
  1420. @noindent
  1421. The archive @file{bfiles.tar} would list as follows:
  1422. @smallexample
  1423. ./birds
  1424. baboon
  1425. ./box
  1426. @end smallexample
  1427. @noindent
  1428. Be sure to use a @value{op-file} option just as with @value{op-create}
  1429. to specify the name of the archive.
  1430. If you use the @value{op-verbose} option with @samp{--list}, then
  1431. @command{tar} will print out a listing reminiscent of @w{@samp{ls -l}},
  1432. showing owner, file size, and so forth.
  1433. If you had used @value{op-verbose} mode, the example above would look
  1434. like:
  1435. @smallexample
  1436. $ @kbd{tar --list --verbose --file=collection.tar folk}
  1437. -rw-rw-rw- myself user 62 1990-05-23 10:55 folk
  1438. @end smallexample
  1439. @cindex File name arguments, using @code{--list} with
  1440. @cindex @code{--list} with file name arguments
  1441. You can specify one or more individual member names as arguments when
  1442. using @samp{list}. In this case, @command{tar} will only list the
  1443. names of members you identify. For example, @w{@kbd{tar --list
  1444. --file=afiles.tar apple}} would only print @file{apple}.
  1445. @FIXME{we hope the relevant aspects of this will change:}Because
  1446. @command{tar} preserves paths, file names must be specified as they appear
  1447. in the archive (ie., relative to the directory from which the archive
  1448. was created). Therefore, it is essential when specifying member names
  1449. to @command{tar} that you give the exact member names. For example,
  1450. @w{@kbd{tar --list --file=bfiles birds}} would produce an error message
  1451. something like @samp{tar: birds: Not found in archive}, because there is
  1452. no member named @file{birds}, only one named @file{./birds}. While the
  1453. names @file{birds} and @file{./birds} name the same file, @emph{member}
  1454. names are compared using a simplistic name comparison, in which an exact
  1455. match is necessary. @xref{absolute}.
  1456. However, @w{@kbd{tar --list --file=collection.tar folk}} would respond
  1457. with @file{folk}, because @file{folk} is in the archive file
  1458. @file{collection.tar}. If you are not sure of the exact file name, try
  1459. listing all the files in the archive and searching for the one you
  1460. expect to find; remember that if you use @samp{--list} with no file
  1461. names as arguments, @command{tar} will print the names of all the members
  1462. stored in the specified archive.
  1463. @menu
  1464. * list dir::
  1465. @end menu
  1466. @node list dir
  1467. @unnumberedsubsec Listing the Contents of a Stored Directory
  1468. To get information about the contents of an archived directory,
  1469. use the directory name as a file name argument in conjunction with
  1470. @value{op-list}. To find out file attributes, include the
  1471. @value{op-verbose} option.
  1472. For example, to find out about files in the directory @file{practice}, in
  1473. the archive file @file{music.tar}, type:
  1474. @smallexample
  1475. $ @kbd{tar --list --verbose --file=music.tar practice}
  1476. @end smallexample
  1477. @command{tar} responds:
  1478. @smallexample
  1479. drwxrwxrwx myself user 0 1990-05-31 21:49 practice/
  1480. -rw-rw-rw- myself user 42 1990-05-21 13:29 practice/blues
  1481. -rw-rw-rw- myself user 62 1990-05-23 10:55 practice/folk
  1482. -rw-rw-rw- myself user 40 1990-05-21 13:30 practice/jazz
  1483. -rw-rw-rw- myself user 10240 1990-05-31 21:49 practice/collection.tar
  1484. @end smallexample
  1485. When you use a directory name as a file name argument, @command{tar} acts on
  1486. all the files (including sub-directories) in that directory.
  1487. @node extract
  1488. @section How to Extract Members from an Archive
  1489. @UNREVISED
  1490. @cindex Extraction
  1491. @cindex Retrieving files from an archive
  1492. @cindex Resurrecting files from an archive
  1493. Creating an archive is only half the job---there is no point in storing
  1494. files in an archive if you can't retrieve them. The act of retrieving
  1495. members from an archive so they can be used and manipulated as
  1496. unarchived files again is called @dfn{extraction}. To extract files
  1497. from an archive, use the @value{op-extract} operation. As with
  1498. @value{op-create}, specify the name of the archive with @value{op-file}.
  1499. Extracting an archive does not modify the archive in any way; you can
  1500. extract it multiple times if you want or need to.
  1501. Using @samp{--extract}, you can extract an entire archive, or specific
  1502. files. The files can be directories containing other files, or not. As
  1503. with @value{op-create} and @value{op-list}, you may use the short or the
  1504. long form of the operation without affecting the performance.
  1505. @menu
  1506. * extracting archives::
  1507. * extracting files::
  1508. * extract dir::
  1509. * extracting untrusted archives::
  1510. * failing commands::
  1511. @end menu
  1512. @node extracting archives
  1513. @subsection Extracting an Entire Archive
  1514. To extract an entire archive, specify the archive file name only, with
  1515. no individual file names as arguments. For example,
  1516. @smallexample
  1517. $ @kbd{tar -xvf collection.tar}
  1518. @end smallexample
  1519. @noindent
  1520. produces this:
  1521. @smallexample
  1522. -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
  1523. -rw-rw-rw- me user 21 1996-09-23 16:44 blues
  1524. -rw-rw-rw- me user 20 1996-09-23 16:44 folk
  1525. @end smallexample
  1526. @node extracting files
  1527. @subsection Extracting Specific Files
  1528. To extract specific archive members, give their exact member names as
  1529. arguments, as printed by @value{op-list}. If you had mistakenly deleted
  1530. one of the files you had placed in the archive @file{collection.tar}
  1531. earlier (say, @file{blues}), you can extract it from the archive without
  1532. changing the archive's structure. It will be identical to the original
  1533. file @file{blues} that you deleted. @FIXME{At the time of this
  1534. writing, atime and ctime are not restored. Since this is a tutorial
  1535. for a beginnig user, it should hardly be mentioned here. Maybe in
  1536. a footnote? --gray}.
  1537. First, make sure you are in the @file{practice} directory, and list the
  1538. files in the directory. Now, delete the file, @samp{blues}, and list
  1539. the files in the directory again.
  1540. You can now extract the member @file{blues} from the archive file
  1541. @file{collection.tar} like this:
  1542. @smallexample
  1543. $ @kbd{tar --extract --file=collection.tar blues}
  1544. @end smallexample
  1545. @noindent
  1546. If you list the files in the directory again, you will see that the file
  1547. @file{blues} has been restored, with its original permissions, creation
  1548. times, and owner.@FIXME{This is only accidentally true, but not in
  1549. general. In most cases, one has to be root for restoring the owner, and
  1550. use a special option for restoring permissions. Here, it just happens
  1551. that the restoring user is also the owner of the archived members, and
  1552. that the current @code{umask} is compatible with original permissions.}
  1553. (These parameters will be identical to those which
  1554. the file had when you originally placed it in the archive; any changes
  1555. you may have made before deleting the file from the file system,
  1556. however, will @emph{not} have been made to the archive member.) The
  1557. archive file, @samp{collection.tar}, is the same as it was before you
  1558. extracted @samp{blues}. You can confirm this by running @command{tar} with
  1559. @value{op-list}.
  1560. @FIXME{we hope this will change:}Remember that as with other operations,
  1561. specifying the exact member name is important. @w{@kbd{tar --extract
  1562. --file=bfiles.tar birds}} will fail, because there is no member named
  1563. @file{birds}. To extract the member named @file{./birds}, you must
  1564. specify @w{@kbd{tar --extract --file=bfiles.tar ./birds}}. To find the
  1565. exact member names of the members of an archive, use @value{op-list}
  1566. (@pxref{list}).
  1567. You can extract a file to standard output by combining the above options
  1568. with the @value{op-to-stdout} option (@pxref{Writing to Standard
  1569. Output}).
  1570. If you give the @value{op-verbose} option, then @value{op-extract} will
  1571. print the names of the archive members as it extracts them.
  1572. @node extract dir
  1573. @subsection Extracting Files that are Directories
  1574. Extracting directories which are members of an archive is similar to
  1575. extracting other files. The main difference to be aware of is that if
  1576. the extracted directory has the same name as any directory already in
  1577. the working directory, then files in the extracted directory will be
  1578. placed into the directory of the same name. Likewise, if there are
  1579. files in the pre-existing directory with the same names as the members
  1580. which you extract, the files from the extracted archive will replace
  1581. the files already in the working directory (and possible
  1582. subdirectories). This will happen regardless of whether or not the
  1583. files in the working directory were more recent than those extracted
  1584. (there exist, however, special options that alter this behavior
  1585. @pxref{Writing}).
  1586. However, if a file was stored with a directory name as part of its file
  1587. name, and that directory does not exist under the working directory when
  1588. the file is extracted, @command{tar} will create the directory.
  1589. We can demonstrate how to use @samp{--extract} to extract a directory
  1590. file with an example. Change to the @file{practice} directory if you
  1591. weren't there, and remove the files @file{folk} and @file{jazz}. Then,
  1592. go back to the parent directory and extract the archive
  1593. @file{music.tar}. You may either extract the entire archive, or you may
  1594. extract only the files you just deleted. To extract the entire archive,
  1595. don't give any file names as arguments after the archive name
  1596. @file{music.tar}. To extract only the files you deleted, use the
  1597. following command:
  1598. @smallexample
  1599. $ @kbd{tar -xvf music.tar practice/folk practice/jazz}
  1600. practice/folk
  1601. practice/jazz
  1602. @end smallexample
  1603. @noindent
  1604. If you were to specify two @value{op-verbose} options, @command{tar}
  1605. would have displayed more detail about the extracted files, as shown
  1606. in the example below:
  1607. @smallexample
  1608. $ @kbd{tar -xvvf music.tar practice/folk practice/jazz}
  1609. -rw-rw-rw- me user 28 1996-10-18 16:31 practice/jazz
  1610. -rw-rw-rw- me user 20 1996-09-23 16:44 practice/folk
  1611. @end smallexample
  1612. @noindent
  1613. Because you created the directory with @file{practice} as part of the
  1614. file names of each of the files by archiving the @file{practice}
  1615. directory as @file{practice}, you must give @file{practice} as part
  1616. of the file names when you extract those files from the archive.
  1617. @FIXME{IMPORTANT! show the final structure, here. figure out what it
  1618. will be.}
  1619. @node extracting untrusted archives
  1620. @subsection Extracting Archives from Untrusted Sources
  1621. Extracting files from archives can overwrite files that already exist.
  1622. If you receive an archive from an untrusted source, you should make a
  1623. new directory and extract into that directory, so that you don't have
  1624. to worry about the extraction overwriting one of your existing files.
  1625. For example, if @file{untrusted.tar} came from somewhere else on the
  1626. Internet, and you don't necessarily trust its contents, you can
  1627. extract it as follows:
  1628. @smallexample
  1629. $ @kbd{mkdir newdir}
  1630. $ @kbd{cd newdir}
  1631. $ @kbd{tar -xvf ../untrusted.tar}
  1632. @end smallexample
  1633. It is also a good practice to examine contents of the archive
  1634. before extracting it, using @value{op-list} option, possibly combined
  1635. with @value{op-verbose}.
  1636. @node failing commands
  1637. @subsection Commands That Will Fail
  1638. Here are some sample commands you might try which will not work, and why
  1639. they won't work.
  1640. If you try to use this command,
  1641. @smallexample
  1642. $ @kbd{tar -xvf music.tar folk jazz}
  1643. @end smallexample
  1644. @noindent
  1645. you will get the following response:
  1646. @smallexample
  1647. tar: folk: Not found in archive
  1648. tar: jazz: Not found in archive
  1649. $
  1650. @end smallexample
  1651. @noindent
  1652. This is because these files were not originally @emph{in} the parent
  1653. directory @file{..}, where the archive is located; they were in the
  1654. @file{practice} directory, and their file names reflect this:
  1655. @smallexample
  1656. $ @kbd{tar -tvf music.tar}
  1657. practice/folk
  1658. practice/jazz
  1659. practice/rock
  1660. @end smallexample
  1661. @FIXME{make sure the above works when going through the examples in
  1662. order...}
  1663. @noindent
  1664. Likewise, if you try to use this command,
  1665. @smallexample
  1666. $ @kbd{tar -tvf music.tar folk jazz}
  1667. @end smallexample
  1668. @noindent
  1669. you would get a similar response. Members with those names are not in the
  1670. archive. You must use the correct member names in order to extract the
  1671. files from the archive.
  1672. If you have forgotten the correct names of the files in the archive,
  1673. use @w{@kbd{tar --list --verbose}} to list them correctly.
  1674. @FIXME{more examples, here? hag thinks it's a good idea.}
  1675. @node going further
  1676. @section Going Further Ahead in this Manual
  1677. @FIXME{need to write up a node here about the things that are going to
  1678. be in the rest of the manual.}
  1679. @node tar invocation
  1680. @chapter Invoking @GNUTAR{}
  1681. @UNREVISED
  1682. This chapter is about how one invokes the @GNUTAR{}
  1683. command, from the command synopsis (@pxref{Synopsis}). There are
  1684. numerous options, and many styles for writing them. One mandatory
  1685. option specifies the operation @command{tar} should perform
  1686. (@pxref{Operation Summary}), other options are meant to detail how
  1687. this operation should be performed (@pxref{Option Summary}).
  1688. Non-option arguments are not always interpreted the same way,
  1689. depending on what the operation is.
  1690. You will find in this chapter everything about option styles and rules for
  1691. writing them (@pxref{Styles}). On the other hand, operations and options
  1692. are fully described elsewhere, in other chapters. Here, you will find
  1693. only synthetic descriptions for operations and options, together with
  1694. pointers to other parts of the @command{tar} manual.
  1695. Some options are so special they are fully described right in this
  1696. chapter. They have the effect of inhibiting the normal operation of
  1697. @command{tar} or else, they globally alter the amount of feedback the user
  1698. receives about what is going on. These are the @value{op-help} and
  1699. @value{op-version} (@pxref{help}), @value{op-verbose} (@pxref{verbose})
  1700. and @value{op-interactive} options (@pxref{interactive}).
  1701. @menu
  1702. * Synopsis::
  1703. * using tar options::
  1704. * Styles::
  1705. * All Options::
  1706. * help::
  1707. * verbose::
  1708. * interactive::
  1709. @end menu
  1710. @node Synopsis
  1711. @section General Synopsis of @command{tar}
  1712. The @GNUTAR{} program is invoked as either one of:
  1713. @smallexample
  1714. @kbd{tar @var{option}@dots{} [@var{name}]@dots{}}
  1715. @kbd{tar @var{letter}@dots{} [@var{argument}]@dots{} [@var{option}]@dots{} [@var{name}]@dots{}}
  1716. @end smallexample
  1717. The second form is for when old options are being used.
  1718. You can use @command{tar} to store files in an archive, to extract them from
  1719. an archive, and to do other types of archive manipulation. The primary
  1720. argument to @command{tar}, which is called the @dfn{operation}, specifies
  1721. which action to take. The other arguments to @command{tar} are either
  1722. @dfn{options}, which change the way @command{tar} performs an operation,
  1723. or file names or archive members, which specify the files or members
  1724. @command{tar} is to act on.
  1725. You can actually type in arguments in any order, even if in this manual
  1726. the options always precede the other arguments, to make examples easier
  1727. to understand. Further, the option stating the main operation mode
  1728. (the @command{tar} main command) is usually given first.
  1729. Each @var{name} in the synopsis above is interpreted as an archive member
  1730. name when the main command is one of @value{op-compare}, @value{op-delete},
  1731. @value{op-extract}, @value{op-list} or @value{op-update}. When naming
  1732. archive members, you must give the exact name of the member in the
  1733. archive, as it is printed by @value{op-list}. For @value{op-append}
  1734. and @value{op-create}, these @var{name} arguments specify the names
  1735. of either files or directory hierarchies to place in the archive.
  1736. These files or hierarchies should already exist in the file system,
  1737. prior to the execution of the @command{tar} command.
  1738. @command{tar} interprets relative file names as being relative to the
  1739. working directory. @command{tar} will make all file names relative
  1740. (by removing leading slashes when archiving or restoring files),
  1741. unless you specify otherwise (using the @value{op-absolute-names}
  1742. option). @value{xref-absolute-names}, for more information about
  1743. @value{op-absolute-names}.
  1744. If you give the name of a directory as either a file name or a member
  1745. name, then @command{tar} acts recursively on all the files and directories
  1746. beneath that directory. For example, the name @file{/} identifies all
  1747. the files in the filesystem to @command{tar}.
  1748. The distinction between file names and archive member names is especially
  1749. important when shell globbing is used, and sometimes a source of confusion
  1750. for newcomers. @xref{Wildcards}, for more information about globbing.
  1751. The problem is that shells may only glob using existing files in the
  1752. file system. Only @command{tar} itself may glob on archive members, so when
  1753. needed, you must ensure that wildcard characters reach @command{tar} without
  1754. being interpreted by the shell first. Using a backslash before @samp{*}
  1755. or @samp{?}, or putting the whole argument between quotes, is usually
  1756. sufficient for this.
  1757. Even if @var{name}s are often specified on the command line, they
  1758. can also be read from a text file in the file system, using the
  1759. @value{op-files-from} option.
  1760. If you don't use any file name arguments, @value{op-append},
  1761. @value{op-delete} and @value{op-concatenate} will do nothing, while
  1762. @value{op-create} will usually yield a diagnostic and inhibit @command{tar}
  1763. execution. The other operations of @command{tar} (@value{op-list},
  1764. @value{op-extract}, @value{op-compare}, and @value{op-update}) will act
  1765. on the entire contents of the archive.
  1766. @cindex exit status
  1767. @cindex return status
  1768. Besides successful exits, @GNUTAR{} may fail for
  1769. many reasons. Some reasons correspond to bad usage, that is, when the
  1770. @command{tar} command is improperly written. Errors may be
  1771. encountered later, while encountering an error processing the archive
  1772. or the files. Some errors are recoverable, in which case the failure
  1773. is delayed until @command{tar} has completed all its work. Some
  1774. errors are such that it would not meaningful, or at least risky, to
  1775. continue processing: @command{tar} then aborts processing immediately.
  1776. All abnormal exits, whether immediate or delayed, should always be
  1777. clearly diagnosed on @code{stderr}, after a line stating the nature of
  1778. the error.
  1779. @GNUTAR{} returns only a few exit statuses. I'm really
  1780. aiming simplicity in that area, for now. If you are not using the
  1781. @value{op-compare} option, zero means that everything went well, besides
  1782. maybe innocuous warnings. Nonzero means that something went wrong.
  1783. Right now, as of today, ``nonzero'' is almost always 2, except for
  1784. remote operations, where it may be 128.
  1785. @node using tar options
  1786. @section Using @command{tar} Options
  1787. @GNUTAR{} has a total of eight operating modes which
  1788. allow you to perform a variety of tasks. You are required to choose
  1789. one operating mode each time you employ the @command{tar} program by
  1790. specifying one, and only one operation as an argument to the
  1791. @command{tar} command (two lists of four operations each may be found
  1792. at @ref{frequent operations} and @ref{Operations}). Depending on
  1793. circumstances, you may also wish to customize how the chosen operating
  1794. mode behaves. For example, you may wish to change the way the output
  1795. looks, or the format of the files that you wish to archive may require
  1796. you to do something special in order to make the archive look right.
  1797. You can customize and control @command{tar}'s performance by running
  1798. @command{tar} with one or more options (such as @value{op-verbose}, which
  1799. we used in the tutorial). As we said in the tutorial, @dfn{options} are
  1800. arguments to @command{tar} which are (as their name suggests) optional.
  1801. Depending on the operating mode, you may specify one or more options.
  1802. Different options will have different effects, but in general they all
  1803. change details of the operation, such as archive format, archive name,
  1804. or level of user interaction. Some options make sense with all
  1805. operating modes, while others are meaningful only with particular modes.
  1806. You will likely use some options frequently, while you will only use
  1807. others infrequently, or not at all. (A full list of options is
  1808. available in @pxref{All Options}.)
  1809. The @env{TAR_OPTIONS} environment variable specifies default options to
  1810. be placed in front of any explicit options. For example, if
  1811. @code{TAR_OPTIONS} is @samp{-v --unlink-first}, @command{tar} behaves as
  1812. if the two options @option{-v} and @option{--unlink-first} had been
  1813. specified before any explicit options. Option specifications are
  1814. separated by whitespace. A backslash escapes the next character, so it
  1815. can be used to specify an option containing whitespace or a backslash.
  1816. Note that @command{tar} options are case sensitive. For example, the
  1817. options @samp{-T} and @samp{-t} are different; the first requires an
  1818. argument for stating the name of a file providing a list of @var{name}s,
  1819. while the second does not require an argument and is another way to
  1820. write @value{op-list}.
  1821. In addition to the eight operations, there are many options to
  1822. @command{tar}, and three different styles for writing both: long (mnemonic)
  1823. form, short form, and old style. These styles are discussed below.
  1824. Both the options and the operations can be written in any of these three
  1825. styles.
  1826. @FIXME{menu at end of this node. need to think of an actual outline
  1827. for this chapter; probably do that after stuff from chap. 4 is
  1828. incorporated.}
  1829. @node Styles
  1830. @section The Three Option Styles
  1831. There are three styles for writing operations and options to the command
  1832. line invoking @command{tar}. The different styles were developed at
  1833. different times during the history of @command{tar}. These styles will be
  1834. presented below, from the most recent to the oldest.
  1835. Some options must take an argument. (For example, @value{op-file} takes
  1836. the name of an archive file as an argument. If you do not supply an
  1837. archive file name, @command{tar} will use a default, but this can be
  1838. confusing; thus, we recommend that you always supply a specific archive
  1839. file name.) Where you @emph{place} the arguments generally depends on
  1840. which style of options you choose. We will detail specific information
  1841. relevant to each option style in the sections on the different option
  1842. styles, below. The differences are subtle, yet can often be very
  1843. important; incorrect option placement can cause you to overwrite a
  1844. number of important files. We urge you to note these differences, and
  1845. only use the option style(s) which makes the most sense to you until you
  1846. feel comfortable with the others.
  1847. Some options @emph{may} take an argument (currently, there are
  1848. two such options: @value{op-backup} and @value{op-occurrence}). Such
  1849. options may have at most long and short forms, they do not have old style
  1850. equivalent. The rules for specifying an argument for such options
  1851. are stricter than those for specifying mandatory arguments. Please,
  1852. pay special attention to them.
  1853. @menu
  1854. * Mnemonic Options:: Mnemonic Option Style
  1855. * Short Options:: Short Option Style
  1856. * Old Options:: Old Option Style
  1857. * Mixing:: Mixing Option Styles
  1858. @end menu
  1859. @node Mnemonic Options
  1860. @subsection Mnemonic Option Style
  1861. @FIXME{have to decide whether or not to replace other occurrences of
  1862. "mnemonic" with "long", or *ugh* vice versa.}
  1863. Each option has at least one long (or mnemonic) name starting with two
  1864. dashes in a row, e.g.@: @samp{--list}. The long names are more clear than
  1865. their corresponding short or old names. It sometimes happens that a
  1866. single mnemonic option has many different different names which are
  1867. synonymous, such as @samp{--compare} and @samp{--diff}. In addition,
  1868. long option names can be given unique abbreviations. For example,
  1869. @samp{--cre} can be used in place of @samp{--create} because there is no
  1870. other mnemonic option which begins with @samp{cre}. (One way to find
  1871. this out is by trying it and seeing what happens; if a particular
  1872. abbreviation could represent more than one option, @command{tar} will tell
  1873. you that that abbreviation is ambiguous and you'll know that that
  1874. abbreviation won't work. You may also choose to run @samp{tar --help}
  1875. to see a list of options. Be aware that if you run @command{tar} with a
  1876. unique abbreviation for the long name of an option you didn't want to
  1877. use, you are stuck; @command{tar} will perform the command as ordered.)
  1878. Mnemonic options are meant to be obvious and easy to remember, and their
  1879. meanings are generally easier to discern than those of their
  1880. corresponding short options (see below). For example:
  1881. @smallexample
  1882. $ @kbd{tar --create --verbose --blocking-factor=20 --file=/dev/rmt0}
  1883. @end smallexample
  1884. @noindent
  1885. gives a fairly good set of hints about what the command does, even
  1886. for those not fully acquainted with @command{tar}.
  1887. Mnemonic options which require arguments take those arguments
  1888. immediately following the option name. There are two ways of
  1889. specifying a mandatory argument. It can be separated from the
  1890. option name either by an equal sign, or by any amount of
  1891. white space characters. For example, the @samp{--file} option (which
  1892. tells the name of the @command{tar} archive) is given a file such as
  1893. @file{archive.tar} as argument by using any of the following notations:
  1894. @samp{--file=archive.tar} or @samp{--file archive.tar}.
  1895. In contrast, optional arguments must always be introduced using
  1896. an equal sign. For example, the @samp{--backup} option takes
  1897. an optional argument specifying backup type. It must be used
  1898. as @samp{--backup=@var{backup-type}}.
  1899. @node Short Options
  1900. @subsection Short Option Style
  1901. Most options also have a short option name. Short options start with
  1902. a single dash, and are followed by a single character, e.g.@: @samp{-t}
  1903. (which is equivalent to @samp{--list}). The forms are absolutely
  1904. identical in function; they are interchangeable.
  1905. The short option names are faster to type than long option names.
  1906. Short options which require arguments take their arguments immediately
  1907. following the option, usually separated by white space. It is also
  1908. possible to stick the argument right after the short option name, using
  1909. no intervening space. For example, you might write @w{@samp{-f
  1910. archive.tar}} or @samp{-farchive.tar} instead of using
  1911. @samp{--file=archive.tar}. Both @samp{--file=@var{archive-name}} and
  1912. @w{@samp{-f @var{archive-name}}} denote the option which indicates a
  1913. specific archive, here named @file{archive.tar}.
  1914. Short options which take optional arguments take their arguments
  1915. immediately following the option letter, @emph{without any intervening
  1916. white space characters}.
  1917. Short options' letters may be clumped together, but you are not
  1918. required to do this (as compared to old options; see below). When
  1919. short options are clumped as a set, use one (single) dash for them
  1920. all, e.g.@: @w{@samp{@command{tar} -cvf}}. Only the last option in
  1921. such a set is allowed to have an argument@footnote{Clustering many
  1922. options, the last of which has an argument, is a rather opaque way to
  1923. write options. Some wonder if @acronym{GNU} @code{getopt} should not
  1924. even be made helpful enough for considering such usages as invalid.}.
  1925. When the options are separated, the argument for each option which requires
  1926. an argument directly follows that option, as is usual for Unix programs.
  1927. For example:
  1928. @smallexample
  1929. $ @kbd{tar -c -v -b 20 -f /dev/rmt0}
  1930. @end smallexample
  1931. If you reorder short options' locations, be sure to move any arguments
  1932. that belong to them. If you do not move the arguments properly, you may
  1933. end up overwriting files.
  1934. @node Old Options
  1935. @subsection Old Option Style
  1936. @UNREVISED
  1937. Like short options, old options are single letters. However, old options
  1938. must be written together as a single clumped set, without spaces separating
  1939. them or dashes preceding them@footnote{Beware that if you precede options
  1940. with a dash, you are announcing the short option style instead of the
  1941. old option style; short options are decoded differently.}. This set
  1942. of letters must be the first to appear on the command line, after the
  1943. @command{tar} program name and some white space; old options cannot appear
  1944. anywhere else. The letter of an old option is exactly the same letter as
  1945. the corresponding short option. For example, the old option @samp{t} is
  1946. the same as the short option @samp{-t}, and consequently, the same as the
  1947. mnemonic option @samp{--list}. So for example, the command @w{@samp{tar
  1948. cv}} specifies the option @samp{-v} in addition to the operation @samp{-c}.
  1949. @FIXME{bob suggests having an uglier example. :-) }
  1950. When options that need arguments are given together with the command,
  1951. all the associated arguments follow, in the same order as the options.
  1952. Thus, the example given previously could also be written in the old
  1953. style as follows:
  1954. @smallexample
  1955. $ @kbd{tar cvbf 20 /dev/rmt0}
  1956. @end smallexample
  1957. @noindent
  1958. Here, @samp{20} is the argument of @samp{-b} and @samp{/dev/rmt0} is
  1959. the argument of @samp{-f}.
  1960. On the other hand, this old style syntax makes it difficult to match
  1961. option letters with their corresponding arguments, and is often
  1962. confusing. In the command @w{@samp{tar cvbf 20 /dev/rmt0}}, for example,
  1963. @samp{20} is the argument for @samp{-b}, @samp{/dev/rmt0} is the
  1964. argument for @samp{-f}, and @samp{-v} does not have a corresponding
  1965. argument. Even using short options like in @w{@samp{tar -c -v -b 20 -f
  1966. /dev/rmt0}} is clearer, putting all arguments next to the option they
  1967. pertain to.
  1968. If you want to reorder the letters in the old option argument, be
  1969. sure to reorder any corresponding argument appropriately.
  1970. This old way of writing @command{tar} options can surprise even experienced
  1971. users. For example, the two commands:
  1972. @smallexample
  1973. @kbd{tar cfz archive.tar.gz file}
  1974. @kbd{tar -cfz archive.tar.gz file}
  1975. @end smallexample
  1976. @noindent
  1977. are quite different. The first example uses @file{archive.tar.gz} as
  1978. the value for option @samp{f} and recognizes the option @samp{z}. The
  1979. second example, however, uses @file{z} as the value for option
  1980. @samp{f} --- probably not what was intended.
  1981. Old options are kept for compatibility with old versions of @command{tar}.
  1982. This second example could be corrected in many ways, among which the
  1983. following are equivalent:
  1984. @smallexample
  1985. @kbd{tar -czf archive.tar.gz file}
  1986. @kbd{tar -cf archive.tar.gz -z file}
  1987. @kbd{tar cf archive.tar.gz -z file}
  1988. @end smallexample
  1989. @FIXME{still could explain this better; it's redundant:}
  1990. @cindex option syntax, traditional
  1991. As far as we know, all @command{tar} programs, @acronym{GNU} and
  1992. non-@acronym{GNU}, support old options. @GNUTAR{}
  1993. supports them not only for historical reasons, but also because many
  1994. people are used to them. For compatibility with Unix @command{tar},
  1995. the first argument is always treated as containing command and option
  1996. letters even if it doesn't start with @samp{-}. Thus, @samp{tar c} is
  1997. equivalent to @w{@samp{tar -c}:} both of them specify the
  1998. @value{op-create} command to create an archive.
  1999. @node Mixing
  2000. @subsection Mixing Option Styles
  2001. All three styles may be intermixed in a single @command{tar} command,
  2002. so long as the rules for each style are fully
  2003. respected@footnote{Before @GNUTAR{} version 1.11.6,
  2004. a bug prevented intermixing old style options with mnemonic options in
  2005. some cases.}. Old style options and either of the modern styles of
  2006. options may be mixed within a single @command{tar} command. However,
  2007. old style options must be introduced as the first arguments only,
  2008. following the rule for old options (old options must appear directly
  2009. after the @command{tar} command and some white space). Modern options
  2010. may be given only after all arguments to the old options have been
  2011. collected. If this rule is not respected, a modern option might be
  2012. falsely interpreted as the value of the argument to one of the old
  2013. style options.
  2014. For example, all the following commands are wholly equivalent, and
  2015. illustrate the many combinations and orderings of option styles.
  2016. @smallexample
  2017. @kbd{tar --create --file=archive.tar}
  2018. @kbd{tar --create -f archive.tar}
  2019. @kbd{tar --create -farchive.tar}
  2020. @kbd{tar --file=archive.tar --create}
  2021. @kbd{tar --file=archive.tar -c}
  2022. @kbd{tar -c --file=archive.tar}
  2023. @kbd{tar -c -f archive.tar}
  2024. @kbd{tar -c -farchive.tar}
  2025. @kbd{tar -cf archive.tar}
  2026. @kbd{tar -cfarchive.tar}
  2027. @kbd{tar -f archive.tar --create}
  2028. @kbd{tar -f archive.tar -c}
  2029. @kbd{tar -farchive.tar --create}
  2030. @kbd{tar -farchive.tar -c}
  2031. @kbd{tar c --file=archive.tar}
  2032. @kbd{tar c -f archive.tar}
  2033. @kbd{tar c -farchive.tar}
  2034. @kbd{tar cf archive.tar}
  2035. @kbd{tar f archive.tar --create}
  2036. @kbd{tar f archive.tar -c}
  2037. @kbd{tar fc archive.tar}
  2038. @end smallexample
  2039. On the other hand, the following commands are @emph{not} equivalent to
  2040. the previous set:
  2041. @smallexample
  2042. @kbd{tar -f -c archive.tar}
  2043. @kbd{tar -fc archive.tar}
  2044. @kbd{tar -fcarchive.tar}
  2045. @kbd{tar -farchive.tarc}
  2046. @kbd{tar cfarchive.tar}
  2047. @end smallexample
  2048. @noindent
  2049. These last examples mean something completely different from what the
  2050. user intended (judging based on the example in the previous set which
  2051. uses long options, whose intent is therefore very clear). The first
  2052. four specify that the @command{tar} archive would be a file named
  2053. @samp{-c}, @samp{c}, @samp{carchive.tar} or @samp{archive.tarc},
  2054. respectively. The first two examples also specify a single non-option,
  2055. @var{name} argument having the value @samp{archive.tar}. The last
  2056. example contains only old style option letters (repeating option
  2057. @samp{c} twice), not all of which are meaningful (eg., @samp{.},
  2058. @samp{h}, or @samp{i}), with no argument value. @FIXME{not sure i liked
  2059. the first sentence of this paragraph..}
  2060. @node All Options
  2061. @section All @command{tar} Options
  2062. The coming manual sections contain an alphabetical listing of all
  2063. @command{tar} operations and options, with brief descriptions and cross
  2064. references to more in-depth explanations in the body of the manual.
  2065. They also contain an alphabetically arranged table of the short option
  2066. forms with their corresponding long option. You can use this table as
  2067. a reference for deciphering @command{tar} commands in scripts.
  2068. @menu
  2069. * Operation Summary::
  2070. * Option Summary::
  2071. * Short Option Summary::
  2072. @end menu
  2073. @node Operation Summary
  2074. @subsection Operations
  2075. @table @kbd
  2076. @item --append
  2077. @itemx -r
  2078. Appends files to the end of the archive. @xref{append}.
  2079. @item --catenate
  2080. @itemx -A
  2081. Same as @samp{--concatenate}. @xref{concatenate}.
  2082. @item --compare
  2083. @itemx -d
  2084. Compares archive members with their counterparts in the file
  2085. system, and reports differences in file size, mode, owner,
  2086. modification date and contents. @xref{compare}.
  2087. @item --concatenate
  2088. @itemx -A
  2089. Appends other @command{tar} archives to the end of the archive.
  2090. @xref{concatenate}.
  2091. @item --create
  2092. @itemx -c
  2093. Creates a new @command{tar} archive. @xref{create}.
  2094. @item --delete
  2095. Deletes members from the archive. Don't try this on a archive on a
  2096. tape! @xref{delete}.
  2097. @item --diff
  2098. @itemx -d
  2099. Same @samp{--compare}. @xref{compare}.
  2100. @item --extract
  2101. @itemx -x
  2102. Extracts members from the archive into the file system. @xref{extract}.
  2103. @item --get
  2104. @itemx -x
  2105. Same as @samp{--extract}. @xref{extract}.
  2106. @item --list
  2107. @itemx -t
  2108. Lists the members in an archive. @xref{list}.
  2109. @item --update
  2110. @itemx -u
  2111. @FIXME{It was: A combination of the @samp{--compare} and
  2112. @samp{--append} operations. This is not true and rather misleading,
  2113. as @value{op-compare} does a lot more than @value{op-update} for
  2114. ensuring files are identical.} Adds files to the end of the archive,
  2115. but only if they are newer than their counterparts already in the
  2116. archive, or if they do not already exist in the archive.
  2117. @xref{update}.
  2118. @end table
  2119. @node Option Summary
  2120. @subsection @command{tar} Options
  2121. @table @kbd
  2122. @item --absolute-names
  2123. @itemx -P
  2124. Normally when creating an archive, @command{tar} strips an initial
  2125. @samp{/} from member names. This option disables that behavior.
  2126. @FIXME-xref{}
  2127. @item --after-date
  2128. (See @samp{--newer}.) @FIXME-pxref{}
  2129. @item --anchored
  2130. An exclude pattern must match an initial subsequence of the name's components.
  2131. @FIXME-xref{}
  2132. @item --atime-preserve
  2133. Tells @command{tar} to preserve the access time field in a file's inode when
  2134. reading it. Due to limitations in the @code{utimes} system call, the
  2135. modification time field is also preserved, which may cause problems if
  2136. the file is simultaneously being modified by another program.
  2137. This option is incompatible with incremental backups, because
  2138. preserving the access time involves updating the last-changed time.
  2139. Also, this option does not work on files that you do not own,
  2140. unless you're root.
  2141. @FIXME-xref{}
  2142. @item --backup=@var{backup-type}
  2143. Rather than deleting files from the file system, @command{tar} will
  2144. back them up using simple or numbered backups, depending upon
  2145. @var{backup-type}. @FIXME-xref{}
  2146. @item --block-number
  2147. @itemx -R
  2148. With this option present, @command{tar} prints error messages for read errors
  2149. with the block number in the archive file. @FIXME-xref{}
  2150. @item --blocking-factor=@var{blocking}
  2151. @itemx -b @var{blocking}
  2152. Sets the blocking factor @command{tar} uses to @var{blocking} x 512 bytes per
  2153. record. @FIXME-xref{}
  2154. @item --bzip2
  2155. @itemx -j
  2156. This option tells @command{tar} to read or write archives through
  2157. @code{bzip2}. @FIXME-xref{}
  2158. @item --checkpoint
  2159. This option directs @command{tar} to print periodic checkpoint messages as it
  2160. reads through the archive. Its intended for when you want a visual
  2161. indication that @command{tar} is still running, but don't want to see
  2162. @samp{--verbose} output. @FIXME-xref{}
  2163. @item --check-links
  2164. @itemx -l
  2165. If this option was given, @command{tar} will check the number of links
  2166. dumped for each processed file. If this number does not match the
  2167. total number of hard links for the file, a warning message will be
  2168. output.
  2169. Future versions will take @option{-l} as a short version of
  2170. @option{--check-links}. However, current release still retains the old
  2171. semantics for @option{-l}.
  2172. @xref{Current status}, for more information.
  2173. @item --compress
  2174. @itemx --uncompress
  2175. @itemx -Z
  2176. @command{tar} will use the @command{compress} program when reading or
  2177. writing the archive. This allows you to directly act on archives
  2178. while saving space. @FIXME-xref{}
  2179. @item --confirmation
  2180. (See @samp{--interactive}.) @FIXME-pxref{}
  2181. @item --dereference
  2182. @itemx -h
  2183. When creating a @command{tar} archive, @command{tar} will archive the
  2184. file that a symbolic link points to, rather than archiving the
  2185. symlink. @FIXME-xref{}
  2186. @item --directory=@var{dir}
  2187. @itemx -C @var{dir}
  2188. When this option is specified, @command{tar} will change its current directory
  2189. to @var{dir} before performing any operations. When this option is used
  2190. during archive creation, it is order sensitive. @FIXME-xref{}
  2191. @item --exclude=@var{pattern}
  2192. When performing operations, @command{tar} will skip files that match
  2193. @var{pattern}. @FIXME-xref{}
  2194. @item --exclude-from=@var{file}
  2195. @itemx -X @var{file}
  2196. Similar to @samp{--exclude}, except @command{tar} will use the list of
  2197. patterns in the file @var{file}. @FIXME-xref{}
  2198. @item --file=@var{archive}
  2199. @itemx -f @var{archive}
  2200. @command{tar} will use the file @var{archive} as the @command{tar} archive it
  2201. performs operations on, rather than @command{tar}'s compilation dependent
  2202. default. @FIXME-xref{}
  2203. @item --files-from=@var{file}
  2204. @itemx -T @var{file}
  2205. @command{tar} will use the contents of @var{file} as a list of archive members
  2206. or files to operate on, in addition to those specified on the
  2207. command-line. @FIXME-xref{}
  2208. @item --force-local
  2209. Forces @command{tar} to interpret the filename given to @samp{--file}
  2210. as a local file, even if it looks like a remote tape drive name.
  2211. @FIXME-xref{}
  2212. @item --format=@var{format}
  2213. Selects output archive format. @var{Format} may be one of the
  2214. following:
  2215. @table @samp
  2216. @item v7
  2217. Creates an archive that is compatible with Unix V7 @command{tar}.
  2218. @item oldgnu
  2219. Creates an archive that is compatible with GNU @command{tar} version
  2220. 1.12 or earlier.
  2221. @item gnu
  2222. Creates archive in GNU tar 1.13 format. Basically it is the same as
  2223. @samp{oldgnu} with the only difference in the way it handles long
  2224. numeric fields.
  2225. @item ustar
  2226. Creates a @acronym{POSIX.1-1988} compatible archive.
  2227. @item posix
  2228. Creates a @acronym{POSIX.1-2001 archive}.
  2229. @end table
  2230. @xref{Formats}, for a detailed discussion of these formats.
  2231. @item --group=@var{group}
  2232. Files added to the @command{tar} archive will have a group id of @var{group},
  2233. rather than the group from the source file. @var{group} is first decoded
  2234. as a group symbolic name, but if this interpretation fails, it has to be
  2235. a decimal numeric group ID. @FIXME-xref{}
  2236. Also see the comments for the @value{op-owner} option.
  2237. @item --gzip
  2238. @itemx --gunzip
  2239. @itemx --ungzip
  2240. @itemx -z
  2241. This option tells @command{tar} to read or write archives through
  2242. @command{gzip}, allowing @command{tar} to directly operate on several
  2243. kinds of compressed archives transparently. @FIXME-xref{}
  2244. @item --help
  2245. @command{tar} will print out a short message summarizing the operations and
  2246. options to @command{tar} and exit. @FIXME-xref{}
  2247. @item --ignore-case
  2248. Ignore case when excluding files.
  2249. @FIXME-xref{}
  2250. @item --ignore-failed-read
  2251. Do not exit unsuccessfully merely because an unreadable file was encountered.
  2252. @xref{Reading}.
  2253. @item --ignore-zeros
  2254. @itemx -i
  2255. With this option, @command{tar} will ignore zeroed blocks in the
  2256. archive, which normally signals EOF. @xref{Reading}.
  2257. @item --incremental
  2258. @itemx -G
  2259. Used to inform @command{tar} that it is working with an old
  2260. @acronym{GNU}-format incremental backup archive. It is intended
  2261. primarily for backwards compatibility only. @FIXME-xref{}
  2262. @item --index-file=@var{file}
  2263. Send verbose output to @var{file} instead of to standard output.
  2264. @item --info-script=@var{script-file}
  2265. @itemx --new-volume-script=@var{script-file}
  2266. @itemx -F @var{script-file}
  2267. When @command{tar} is performing multi-tape backups, @var{script-file} is run
  2268. at the end of each tape. If @var{script-file} exits with nonzero status,
  2269. @command{tar} fails immediately. @FIXME-xref{}
  2270. @item --interactive
  2271. @itemx --confirmation
  2272. @itemx -w
  2273. Specifies that @command{tar} should ask the user for confirmation before
  2274. performing potentially destructive options, such as overwriting files.
  2275. @FIXME-xref{}
  2276. @item --keep-newer-files
  2277. Do not replace existing files that are newer than their archive copies
  2278. when extracting files from an archive.
  2279. @item --keep-old-files
  2280. @itemx -k
  2281. Do not overwrite existing files when extracting files from an archive.
  2282. @xref{Writing}.
  2283. @item --label=@var{name}
  2284. @itemx -V @var{name}
  2285. When creating an archive, instructs @command{tar} to write @var{name}
  2286. as a name record in the archive. When extracting or listing archives,
  2287. @command{tar} will only operate on archives that have a label matching
  2288. the pattern specified in @var{name}. @FIXME-xref{}
  2289. @item --listed-incremental=@var{snapshot-file}
  2290. @itemx -g @var{snapshot-file}
  2291. During a @samp{--create} operation, specifies that the archive that
  2292. @command{tar} creates is a new @acronym{GNU}-format incremental
  2293. backup, using @var{snapshot-file} to determine which files to backup.
  2294. With other operations, informs @command{tar} that the archive is in
  2295. incremental format. @FIXME-xref{}
  2296. @item --mode=@var{permissions}
  2297. When adding files to an archive, @command{tar} will use
  2298. @var{permissions} for the archive members, rather than the permissions
  2299. from the files. The program @command{chmod} and this @command{tar}
  2300. option share the same syntax for what @var{permissions} might be.
  2301. @xref{File permissions, Permissions, File permissions, fileutils,
  2302. @acronym{GNU} file utilities}. This reference also has useful
  2303. information for those not being overly familiar with the Unix
  2304. permission system.
  2305. Of course, @var{permissions} might be plainly specified as an octal number.
  2306. However, by using generic symbolic modifications to mode bits, this allows
  2307. more flexibility. For example, the value @samp{a+rw} adds read and write
  2308. permissions for everybody, while retaining executable bits on directories
  2309. or on any other file already marked as executable.
  2310. @item --multi-volume
  2311. @itemx -M
  2312. Informs @command{tar} that it should create or otherwise operate on a
  2313. multi-volume @command{tar} archive. @FIXME-xref{}
  2314. @item --new-volume-script
  2315. (see --info-script)
  2316. @item -n
  2317. @itemx --seek
  2318. Assume that the archive media supports seeks to arbitrary
  2319. locations. Usually @command{tar} determines automatically whether
  2320. the archive can be seeked or not. This option is intended for use
  2321. in cases when such recognition fails.
  2322. @item --newer=@var{date}
  2323. @itemx --after-date=@var{date}
  2324. @itemx -N
  2325. When creating an archive, @command{tar} will only add files that have changed
  2326. since @var{date}. If @var{date} begins with @samp{/} or @samp{.}, it
  2327. is taken to be the name of a file whose last-modified time specifies
  2328. the date. @FIXME-xref{}
  2329. @item --newer-mtime=@var{date}
  2330. Like @samp{--newer}, but add only files whose
  2331. contents have changed (as opposed to just @samp{--newer}, which will
  2332. also back up files for which any status information has changed).
  2333. @item --no-anchored
  2334. An exclude pattern can match any subsequence of the name's components.
  2335. @FIXME-xref{}
  2336. @item --no-ignore-case
  2337. Use case-sensitive matching when excluding files.
  2338. @FIXME-xref{}
  2339. @item --no-recursion
  2340. With this option, @command{tar} will not recurse into directories.
  2341. @FIXME-xref{}
  2342. @item --no-same-owner
  2343. @itemx -o
  2344. When extracting an archive, do not attempt to preserve the owner
  2345. specified in the @command{tar} archive. This the default behavior
  2346. for ordinary users; this option has an effect only for the superuser.
  2347. @item --no-same-permissions
  2348. When extracting an archive, subtract the user's umask from files from
  2349. the permissions specified in the archive. This is the default behavior
  2350. for ordinary users; this option has an effect only for the superuser.
  2351. @item --no-wildcards
  2352. Do not use wildcards when excluding files.
  2353. @FIXME-xref{}
  2354. @item --no-wildcards-match-slash
  2355. Wildcards do not match @samp{/} when excluding files.
  2356. @FIXME-xref{}
  2357. @item --null
  2358. When @command{tar} is using the @samp{--files-from} option, this option
  2359. instructs @command{tar} to expect filenames terminated with @kbd{NUL}, so
  2360. @command{tar} can correctly work with file names that contain newlines.
  2361. @FIXME-xref{}
  2362. @item --numeric-owner
  2363. This option will notify @command{tar} that it should use numeric user
  2364. and group IDs when creating a @command{tar} file, rather than names.
  2365. @FIXME-xref{}
  2366. @item -o
  2367. When extracting files, this option is a synonym for
  2368. @option{--no-same-owner}, i.e. it prevents @command{tar} from
  2369. restoring ownership of files being extracted.
  2370. When creating an archive, @option{-o} is a synonym for
  2371. @option{--old-archive}. This behavior is for compatibility
  2372. with previous versions of @GNUTAR{}, and will be
  2373. removed in the future releases.
  2374. @xref{Current status}, for more information.
  2375. @item --occurrence[=@var{number}]
  2376. This option can be used in conjunction with one of the subcommands
  2377. @option{--delete}, @option{--diff}, @option{--extract} or
  2378. @option{--list} when a list of files is given either on the command
  2379. line or via @option{-T} option.
  2380. This option instructs @command{tar} to process only the @var{number}th
  2381. occurrence of each named file. @var{Number} defaults to 1, so
  2382. @smallexample
  2383. tar -x -f archive.tar --occurrence filename
  2384. @end smallexample
  2385. @noindent
  2386. will extract the first occurrence of @file{filename} from @file{archive.tar}
  2387. and will terminate without scanning to the end of the archive.
  2388. @item --old-archive
  2389. Synonym for @option{--format=v7}.
  2390. @item --one-file-system
  2391. @itemx -l
  2392. Used when creating an archive. Prevents @command{tar} from recursing into
  2393. directories that are on different file systems from the current
  2394. directory.
  2395. Earlier versions of @GNUTAR{} understood @option{-l} as a
  2396. synonym for @option{--one-file-system}. Although such usage is still
  2397. allowed in the present version, it is @emph{strongly discouraged}.
  2398. The future versions of @GNUTAR{} will use @option{-l} as
  2399. a synonym for @option{--check-links}.
  2400. @xref{Current status}, for more information.
  2401. @item --overwrite
  2402. Overwrite existing files and directory metadata when extracting files
  2403. from an archive. @xref{Overwrite Old Files}.
  2404. @item --overwrite-dir
  2405. Overwrite the metadata of existing directories when extracting files
  2406. from an archive. @xref{Overwrite Old Files}.
  2407. @item --owner=@var{user}
  2408. Specifies that @command{tar} should use @var{user} as the owner of members
  2409. when creating archives, instead of the user associated with the source
  2410. file. @var{user} is first decoded as a user symbolic name, but if
  2411. this interpretation fails, it has to be a decimal numeric user ID.
  2412. @FIXME-xref{}
  2413. There is no value indicating a missing number, and @samp{0} usually means
  2414. @code{root}. Some people like to force @samp{0} as the value to offer in
  2415. their distributions for the owner of files, because the @code{root} user is
  2416. anonymous anyway, so that might as well be the owner of anonymous archives.
  2417. This option does not affect extraction from archives.
  2418. @item --pax-option=@var{keyword-list}
  2419. This option is meaningful only with @acronym{POSIX.1-2001} archives
  2420. (@FIXME-xref{}). It modifies the way @command{tar} handles the
  2421. extended header keywords. @var{Keyword-list} is a comma-separated
  2422. list of keyword options, each keyword option taking one of
  2423. the following forms:
  2424. @table @asis
  2425. @item delete=@var{pattern}
  2426. When used with one of archive-creation command (@FIXME-xref{}),
  2427. this option instructs @command{tar} to omit from extended header records
  2428. that it produces any keywords matching the string @var{pattern}.
  2429. When used in extract or list mode, this option instructs tar
  2430. to ignore any keywords matching the given @var{pattern} in the extended
  2431. header records. In both cases, matching is performed using the pattern
  2432. matching notation described in @acronym{POSIX 1003.2}, 3.13 @FIXME-xref{see
  2433. man 7 glob}. For example:
  2434. @smallexample
  2435. --pax-option delete=security.*
  2436. @end smallexample
  2437. would suppress security-related information.
  2438. @item exthdr.name=@var{string}
  2439. This keyword allows user control over the name that is written into the
  2440. ustar header blocks for the extended headers. The name is obtained
  2441. from @var{string} after substituting the following meta-characters:
  2442. @multitable @columnfractions .30 .70
  2443. @item Meta-character @tab Replaced By
  2444. @item %d @tab The directory name of the file, equivalent to the
  2445. result of the @command{dirname} utility on the translated pathname.
  2446. @item %f @tab The filename of the file, equivalent to the result
  2447. of the @command{basename} utility on the translated pathname.
  2448. @item %p @tab The process ID of the @command{tar} process.
  2449. @item %% @tab A @samp{%} character.
  2450. @end multitable
  2451. Any other @samp{%} characters in @var{string} produce undefined
  2452. results.
  2453. If no option @samp{exthdr.name=string} is specified, @command{tar}
  2454. will use the following default value:
  2455. @smallexample
  2456. %d/PaxHeaders.%p/%f
  2457. @end smallexample
  2458. @item globexthdr.name=@var{string}
  2459. This keyword allows user control over the name that is written into
  2460. the ustar header blocks for global extended header records. The name
  2461. shall will be obtained from the contents of @var{string}, after the
  2462. following character substitutions have been made:
  2463. @multitable @columnfractions .30 .70
  2464. @item Meta-character @tab Replaced By
  2465. @item %n @tab An integer that represents the
  2466. sequence number of the global extended header record in the archive,
  2467. starting at 1.
  2468. @item %p @tab The process ID of the @command{tar} process.
  2469. @item %% @tab A @samp{%} character.
  2470. @end multitable
  2471. Any other @samp{%} characters in string produce undefined results.
  2472. If no option @samp{globexthdr.name=string} is specified, @command{tar}
  2473. will use the following default value:
  2474. @smallexample
  2475. $TMPDIR/GlobalHead.%p.%n
  2476. @end smallexample
  2477. @noindent
  2478. where @samp{$TMPDIR} represents the value of the @var{TMPDIR}
  2479. environment variable. If @var{TMPDIR} is not set, @command{tar}
  2480. uses @samp{/tmp}.
  2481. @item @var{keyword}=@var{value}
  2482. When used with one of archive-creation commands, these keyword/value pairs
  2483. will be included at the beginning of the archive in a global extended
  2484. header record. When used with one of archive-reading commands,
  2485. @command{tar} will behave as if it has encountered these keyword/value
  2486. pairs at the beginning of the archive in a global extended header
  2487. record.
  2488. @item @var{keyword}:=@var{value}
  2489. When used with one of archive-creation commands, these keyword/value pairs
  2490. will be included as records at the beginning of an extended header for
  2491. each file. This is effectively equivalent to @var{keyword}=@var{value}
  2492. form except that it creates no global extended header records.
  2493. When used with one of archive-reading commands, @command{tar} will
  2494. behave as if these keyword/value pairs were included as records at the
  2495. end of each extended header; thus, they will override any global or
  2496. file-specific extended header record keywords of the same names.
  2497. For example, in the command:
  2498. @smallexample
  2499. tar --format=posix --create \
  2500. --file archive --pax-option gname:=user .
  2501. @end smallexample
  2502. the group name will be forced to a new value for all files
  2503. stored in the archive.
  2504. @end table
  2505. @item --portability
  2506. @itemx --old-archive
  2507. Synonym for @option{--format=v7}.
  2508. @item --posix
  2509. Same as @option{--format=posix}.
  2510. @item --preserve
  2511. Synonymous with specifying both @samp{--preserve-permissions} and
  2512. @samp{--same-order}. @FIXME-xref{}
  2513. @item --preserve-order
  2514. (See @samp{--same-order}; @pxref{Reading}.)
  2515. @item --preserve-permissions
  2516. @itemx --same-permissions
  2517. @itemx -p
  2518. When @command{tar} is extracting an archive, it normally subtracts the
  2519. users' umask from the permissions specified in the archive and uses
  2520. that number as the permissions to create the destination file.
  2521. Specifying this option instructs @command{tar} that it should use the
  2522. permissions directly from the archive. @xref{Writing}.
  2523. @item --read-full-records
  2524. @itemx -B
  2525. Specifies that @command{tar} should reblock its input, for reading
  2526. from pipes on systems with buggy implementations. @xref{Reading}.
  2527. @item --record-size=@var{size}
  2528. Instructs @command{tar} to use @var{size} bytes per record when accessing the
  2529. archive. @FIXME-xref{}
  2530. @item --recursion
  2531. With this option, @command{tar} recurses into directories.
  2532. @FIXME-xref{}
  2533. @item --recursive-unlink
  2534. Remove existing
  2535. directory hierarchies before extracting directories of the same name
  2536. from the archive. @xref{Writing}.
  2537. @item --remove-files
  2538. Directs @command{tar} to remove the source file from the file system after
  2539. appending it to an archive. @FIXME-xref{}
  2540. @item --rmt-command=@var{cmd}
  2541. Notifies @command{tar} that it should use @var{cmd} instead of
  2542. the default @file{/usr/libexec/rmt} (@pxref{Remote Tape Server}).
  2543. @item --rsh-command=@var{cmd}
  2544. Notifies @command{tar} that is should use @var{cmd} to communicate with remote
  2545. devices. @FIXME-xref{}
  2546. @item --same-order
  2547. @itemx --preserve-order
  2548. @itemx -s
  2549. This option is an optimization for @command{tar} when running on machines with
  2550. small amounts of memory. It informs @command{tar} that the list of file
  2551. arguments has already been sorted to match the order of files in the
  2552. archive. @xref{Reading}.
  2553. @item --same-owner
  2554. When extracting an archive, @command{tar} will attempt to preserve the owner
  2555. specified in the @command{tar} archive with this option present.
  2556. This is the default behavior for the superuser; this option has an
  2557. effect only for ordinary users. @FIXME-xref{}
  2558. @item --same-permissions
  2559. (See @samp{--preserve-permissions}; @pxref{Writing}.)
  2560. @item --show-defaults
  2561. Displays the default options used by @command{tar} and exits
  2562. successfully. This option is intended for use in shell scripts.
  2563. Here is an example of what you can see using this option:
  2564. @smallexample
  2565. $ tar --show-defaults
  2566. --format=gnu -f- -b20
  2567. @end smallexample
  2568. @item --show-omitted-dirs
  2569. Instructs @command{tar} to mention directories its skipping over when
  2570. operating on a @command{tar} archive. @FIXME-xref{}
  2571. @item --sparse
  2572. @itemx -S
  2573. Invokes a @acronym{GNU} extension when adding files to an archive that handles
  2574. sparse files efficiently. @FIXME-xref{}
  2575. @item --starting-file=@var{name}
  2576. @itemx -K @var{name}
  2577. This option affects extraction only; @command{tar} will skip extracting
  2578. files in the archive until it finds one that matches @var{name}.
  2579. @xref{Scarce}.
  2580. @item --strip-components=@var{number}
  2581. Strip given @var{number} of leading components from file names before
  2582. extraction.@footnote{This option was called @option{--strip-path} in
  2583. version 1.14.} For example, if archive @file{archive.tar} contained
  2584. @file{/some/file/name}, then running
  2585. @smallexample
  2586. tar --extract --file archive.tar --strip-components=2
  2587. @end smallexample
  2588. @noindent
  2589. would extracted this file to file @file{name}.
  2590. @item --suffix=@var{suffix}
  2591. Alters the suffix @command{tar} uses when backing up files from the default
  2592. @samp{~}. @FIXME-xref{}
  2593. @item --tape-length=@var{num}
  2594. @itemx -L @var{num}
  2595. Specifies the length of tapes that @command{tar} is writing as being
  2596. @w{@var{num} x 1024} bytes long. @FIXME-xref{}
  2597. @item --to-stdout
  2598. @itemx -O
  2599. During extraction, @command{tar} will extract files to stdout rather
  2600. than to the file system. @xref{Writing}.
  2601. @item --totals
  2602. Displays the total number of bytes written after creating an archive.
  2603. @FIXME-xref{}
  2604. @item --touch
  2605. @itemx -m
  2606. Sets the modification time of extracted files to the extraction time,
  2607. rather than the modification time stored in the archive.
  2608. @xref{Writing}.
  2609. @item --uncompress
  2610. (See @samp{--compress}.) @FIXME-pxref{}
  2611. @item --ungzip
  2612. (See @samp{--gzip}.) @FIXME-pxref{}
  2613. @item --unlink-first
  2614. @itemx -U
  2615. Directs @command{tar} to remove the corresponding file from the file
  2616. system before extracting it from the archive. @xref{Writing}.
  2617. @item --use-compress-program=@var{prog}
  2618. Instructs @command{tar} to access the archive through @var{prog}, which is
  2619. presumed to be a compression program of some sort. @FIXME-xref{}
  2620. @item --utc
  2621. Display file modification dates in @acronym{UTC}. This option implies
  2622. @samp{--verbose}.
  2623. @item --verbose
  2624. @itemx -v
  2625. Specifies that @command{tar} should be more verbose about the operations its
  2626. performing. This option can be specified multiple times for some
  2627. operations to increase the amount of information displayed. @FIXME-xref{}
  2628. @item --verify
  2629. @itemx -W
  2630. Verifies that the archive was correctly written when creating an
  2631. archive. @FIXME-xref{}
  2632. @item --version
  2633. @command{tar} will print an informational message about what version
  2634. it is and a copyright message, some credits, and then exit.
  2635. @FIXME-xref{}
  2636. @item --volno-file=@var{file}
  2637. Used in conjunction with @samp{--multi-volume}. @command{tar} will keep track
  2638. of which volume of a multi-volume archive its working in @var{file}.
  2639. @FIXME-xref{}
  2640. @item --wildcards
  2641. Use wildcards when excluding files.
  2642. @FIXME-xref{}
  2643. @item --wildcards-match-slash
  2644. Wildcards match @samp{/} when excluding files.
  2645. @FIXME-xref{}
  2646. @end table
  2647. @node Short Option Summary
  2648. @subsection Short Options Cross Reference
  2649. Here is an alphabetized list of all of the short option forms, matching
  2650. them with the equivalent long option.
  2651. @table @kbd
  2652. @item -A
  2653. @samp{--concatenate}
  2654. @item -B
  2655. @samp{--read-full-records}
  2656. @item -C
  2657. @samp{--directory}
  2658. @item -F
  2659. @samp{--info-script}
  2660. @item -G
  2661. @samp{--incremental}
  2662. @item -K
  2663. @samp{--starting-file}
  2664. @item -L
  2665. @samp{--tape-length}
  2666. @item -M
  2667. @samp{--multi-volume}
  2668. @item -N
  2669. @samp{--newer}
  2670. @item -O
  2671. @samp{--to-stdout}
  2672. @item -P
  2673. @samp{--absolute-names}
  2674. @item -R
  2675. @samp{--block-number}
  2676. @item -S
  2677. @samp{--sparse}
  2678. @item -T
  2679. @samp{--files-from}
  2680. @item -U
  2681. @samp{--unlink-first}
  2682. @item -V
  2683. @samp{--label}
  2684. @item -W
  2685. @samp{--verify}
  2686. @item -X
  2687. @samp{--exclude-from}
  2688. @item -Z
  2689. @samp{--compress}
  2690. @item -b
  2691. @samp{--blocking-factor}
  2692. @item -c
  2693. @samp{--create}
  2694. @item -d
  2695. @samp{--compare}
  2696. @item -f
  2697. @samp{--file}
  2698. @item -g
  2699. @samp{--listed-incremental}
  2700. @item -h
  2701. @samp{--dereference}
  2702. @item -i
  2703. @samp{--ignore-zeros}
  2704. @item -j
  2705. @samp{--bzip2}
  2706. @item -k
  2707. @samp{--keep-old-files}
  2708. @item -l
  2709. @samp{--one-file-system}. Use of this short option is deprecated. It
  2710. is retained for compatibility with the earlier versions of GNU
  2711. @command{tar}, and will be changed in future releases.
  2712. @xref{Current status}, for more information.
  2713. @item -m
  2714. @samp{--touch}
  2715. @item -o
  2716. When creating --- @samp{--no-same-owner}, when extracting ---
  2717. @samp{--portability}.
  2718. The later usage is deprecated. It is retained for compatibility with
  2719. the earlier versions of @GNUTAR{}. In the future releases
  2720. @option{-o} will be equivalent to @samp{--no-same-owner} only.
  2721. @item -p
  2722. @samp{--preserve-permissions}
  2723. @item -r
  2724. @samp{--append}
  2725. @item -s
  2726. @samp{--same-order}
  2727. @item -t
  2728. @samp{--list}
  2729. @item -u
  2730. @samp{--update}
  2731. @item -v
  2732. @samp{--verbose}
  2733. @item -w
  2734. @samp{--interactive}
  2735. @item -x
  2736. @samp{--extract}
  2737. @item -z
  2738. @samp{--gzip}
  2739. @end table
  2740. @node help
  2741. @section @GNUTAR{} documentation
  2742. Being careful, the first thing is really checking that you are using
  2743. @GNUTAR{}, indeed. The @value{op-version} option
  2744. will generate a message giving confirmation that you are using
  2745. @GNUTAR{}, with the precise version of @GNUTAR{}
  2746. you are using. @command{tar} identifies itself and
  2747. prints the version number to the standard output, then immediately
  2748. exits successfully, without doing anything else, ignoring all other
  2749. options. For example, @w{@samp{tar --version}} might return:
  2750. @smallexample
  2751. tar (@acronym{GNU} tar) @value{VERSION}
  2752. @end smallexample
  2753. @noindent
  2754. The first occurrence of @samp{tar} in the result above is the program
  2755. name in the package (for example, @command{rmt} is another program),
  2756. while the second occurrence of @samp{tar} is the name of the package
  2757. itself, containing possibly many programs. The package is currently
  2758. named @samp{tar}, after the name of the main program it
  2759. contains@footnote{There are plans to merge the @command{cpio} and
  2760. @command{tar} packages into a single one which would be called
  2761. @code{paxutils}. So, who knows if, one of this days, the
  2762. @value{op-version} would not yield @w{@samp{tar (@acronym{GNU}
  2763. paxutils) 3.2}}}.
  2764. Another thing you might want to do is checking the spelling or meaning
  2765. of some particular @command{tar} option, without resorting to this
  2766. manual, for once you have carefully read it. @GNUTAR{}
  2767. has a short help feature, triggerable through the
  2768. @value{op-help} option. By using this option, @command{tar} will
  2769. print a usage message listing all available options on standard
  2770. output, then exit successfully, without doing anything else and
  2771. ignoring all other options. Even if this is only a brief summary, it
  2772. may be several screens long. So, if you are not using some kind of
  2773. scrollable window, you might prefer to use something like:
  2774. @smallexample
  2775. $ @kbd{tar --help | less}
  2776. @end smallexample
  2777. @noindent
  2778. presuming, here, that you like using @command{less} for a pager. Other
  2779. popular pagers are @command{more} and @command{pg}. If you know about some
  2780. @var{keyword} which interests you and do not want to read all the
  2781. @value{op-help} output, another common idiom is doing:
  2782. @smallexample
  2783. tar --help | grep @var{keyword}
  2784. @end smallexample
  2785. @noindent
  2786. for getting only the pertinent lines.
  2787. The perceptive reader would have noticed some contradiction in the
  2788. previous paragraphs. It is written that both @value{op-version} and
  2789. @value{op-help} print something, and have all other options ignored. In
  2790. fact, they cannot ignore each other, and one of them has to win. We do
  2791. not specify which is stronger, here; experiment if you really wonder!
  2792. The short help output is quite succinct, and you might have to get
  2793. back to the full documentation for precise points. If you are reading
  2794. this paragraph, you already have the @command{tar} manual in some
  2795. form. This manual is available in printed form, as a kind of small
  2796. book. It may printed out of the @GNUTAR{}
  2797. distribution, provided you have @TeX{} already installed somewhere,
  2798. and a laser printer around. Just configure the distribution, execute
  2799. the command @w{@samp{make dvi}}, then print @file{doc/tar.dvi} the
  2800. usual way (contact your local guru to know how). If @GNUTAR{}
  2801. has been conveniently installed at your place, this
  2802. manual is also available in interactive, hypertextual form as an Info
  2803. file. Just call @w{@samp{info tar}} or, if you do not have the
  2804. @command{info} program handy, use the Info reader provided within
  2805. @acronym{GNU} Emacs, calling @samp{tar} from the main Info menu.
  2806. There is currently no @code{man} page for @GNUTAR{}.
  2807. If you observe such a @code{man} page on the system you are running,
  2808. either it does not long to @GNUTAR{}, or it has not
  2809. been produced by @acronym{GNU}. Currently, @GNUTAR{}
  2810. documentation is provided in Texinfo format only, if we
  2811. except, of course, the short result of @kbd{tar --help}.
  2812. @node verbose
  2813. @section Checking @command{tar} progress
  2814. @cindex Progress information
  2815. @cindex Status information
  2816. @cindex Information on progress and status of operations
  2817. @cindex Verbose operation
  2818. @cindex Block number where error occurred
  2819. @cindex Error message, block number of
  2820. @cindex Version of the @command{tar} program
  2821. @cindex Getting more information during the operation
  2822. @cindex Information during operation
  2823. @cindex Feedback from @command{tar}
  2824. Typically, @command{tar} performs most operations without reporting any
  2825. information to the user except error messages. When using @command{tar}
  2826. with many options, particularly ones with complicated or
  2827. difficult-to-predict behavior, it is possible to make serious mistakes.
  2828. @command{tar} provides several options that make observing @command{tar}
  2829. easier. These options cause @command{tar} to print information as it
  2830. progresses in its job, and you might want to use them just for being
  2831. more careful about what is going on, or merely for entertaining
  2832. yourself. If you have encountered a problem when operating on an
  2833. archive, however, you may need more information than just an error
  2834. message in order to solve the problem. The following options can be
  2835. helpful diagnostic tools.
  2836. Normally, the @value{op-list} command to list an archive prints just
  2837. the file names (one per line) and the other commands are silent.
  2838. When used with most operations, the @value{op-verbose} option causes
  2839. @command{tar} to print the name of each file or archive member as it
  2840. is processed. This and the other options which make @command{tar} print
  2841. status information can be useful in monitoring @command{tar}.
  2842. With @value{op-create} or @value{op-extract}, @value{op-verbose} used once
  2843. just prints the names of the files or members as they are processed.
  2844. Using it twice causes @command{tar} to print a longer listing (reminiscent
  2845. of @samp{ls -l}) for each member. Since @value{op-list} already prints
  2846. the names of the members, @value{op-verbose} used once with @value{op-list}
  2847. causes @command{tar} to print an @samp{ls -l} type listing of the files
  2848. in the archive. The following examples both extract members with
  2849. long list output:
  2850. @smallexample
  2851. $ @kbd{tar --extract --file=archive.tar --verbose --verbose}
  2852. $ @kbd{tar xvvf archive.tar}
  2853. @end smallexample
  2854. Verbose output appears on the standard output except when an archive is
  2855. being written to the standard output, as with @samp{tar --create
  2856. --file=- --verbose} (@samp{tar cfv -}, or even @samp{tar cv}---if the
  2857. installer let standard output be the default archive). In that case
  2858. @command{tar} writes verbose output to the standard error stream.
  2859. If @option{--index-file=@var{file}} is specified, @command{tar} sends
  2860. verbose output to @var{file} rather than to standard output or standard
  2861. error.
  2862. The @value{op-totals} option---which is only meaningful when used with
  2863. @value{op-create}---causes @command{tar} to print the total
  2864. amount written to the archive, after it has been fully created.
  2865. The @value{op-checkpoint} option prints an occasional message
  2866. as @command{tar} reads or writes the archive. In fact, it prints
  2867. a message each 10 records read or written. It is designed for
  2868. those who don't need the more detailed (and voluminous) output of
  2869. @value{op-block-number}, but do want visual confirmation that @command{tar}
  2870. is actually making forward progress.
  2871. @FIXME{There is some confusion here. It seems that -R once wrote a
  2872. message at @samp{every} record read or written.}
  2873. The @value{op-show-omitted-dirs} option, when reading an archive---with
  2874. @value{op-list} or @value{op-extract}, for example---causes a message
  2875. to be printed for each directory in the archive which is skipped.
  2876. This happens regardless of the reason for skipping: the directory might
  2877. not have been named on the command line (implicitly or explicitly),
  2878. it might be excluded by the use of the @value{op-exclude} option, or
  2879. some other reason.
  2880. If @value{op-block-number} is used, @command{tar} prints, along with
  2881. every message it would normally produce, the block number within the
  2882. archive where the message was triggered. Also, supplementary messages
  2883. are triggered when reading blocks full of NULs, or when hitting end of
  2884. file on the archive. As of now, if the archive if properly terminated
  2885. with a NUL block, the reading of the file may stop before end of file
  2886. is met, so the position of end of file will not usually show when
  2887. @value{op-block-number} is used. Note that @GNUTAR{}
  2888. drains the archive before exiting when reading the
  2889. archive from a pipe.
  2890. This option is especially useful when reading damaged archives, since
  2891. it helps pinpoint the damaged sections. It can also be used with
  2892. @value{op-list} when listing a file-system backup tape, allowing you to
  2893. choose among several backup tapes when retrieving a file later, in
  2894. favor of the tape where the file appears earliest (closest to the
  2895. front of the tape). @FIXME-xref{when the node name is set and the
  2896. backup section written.}
  2897. @node interactive
  2898. @section Asking for Confirmation During Operations
  2899. @cindex Interactive operation
  2900. Typically, @command{tar} carries out a command without stopping for
  2901. further instructions. In some situations however, you may want to
  2902. exclude some files and archive members from the operation (for instance
  2903. if disk or storage space is tight). You can do this by excluding
  2904. certain files automatically (@pxref{Choosing}), or by performing
  2905. an operation interactively, using the @value{op-interactive} option.
  2906. @command{tar} also accepts @samp{--confirmation} for this option.
  2907. When the @value{op-interactive} option is specified, before
  2908. reading, writing, or deleting files, @command{tar} first prints a message
  2909. for each such file, telling what operation it intends to take, then asks
  2910. for confirmation on the terminal. The actions which require
  2911. confirmation include adding a file to the archive, extracting a file
  2912. from the archive, deleting a file from the archive, and deleting a file
  2913. from disk. To confirm the action, you must type a line of input
  2914. beginning with @samp{y}. If your input line begins with anything other
  2915. than @samp{y}, @command{tar} skips that file.
  2916. If @command{tar} is reading the archive from the standard input,
  2917. @command{tar} opens the file @file{/dev/tty} to support the interactive
  2918. communications.
  2919. Verbose output is normally sent to standard output, separate from
  2920. other error messages. However, if the archive is produced directly
  2921. on standard output, then verbose output is mixed with errors on
  2922. @code{stderr}. Producing the archive on standard output may be used
  2923. as a way to avoid using disk space, when the archive is soon to be
  2924. consumed by another process reading it, say. Some people felt the need
  2925. of producing an archive on stdout, still willing to segregate between
  2926. verbose output and error output. A possible approach would be using a
  2927. named pipe to receive the archive, and having the consumer process to
  2928. read from that named pipe. This has the advantage of letting standard
  2929. output free to receive verbose output, all separate from errors.
  2930. @node operations
  2931. @chapter @GNUTAR{} Operations
  2932. @menu
  2933. * Basic tar::
  2934. * Advanced tar::
  2935. * create options::
  2936. * extract options::
  2937. * backup::
  2938. * Applications::
  2939. * looking ahead::
  2940. @end menu
  2941. @node Basic tar
  2942. @section Basic @GNUTAR{} Operations
  2943. The basic @command{tar} operations, @value{op-create}, @value{op-list} and
  2944. @value{op-extract}, are currently presented and described in the tutorial
  2945. chapter of this manual. This section provides some complementary notes
  2946. for these operations.
  2947. @table @asis
  2948. @item @value{op-create}
  2949. Creating an empty archive would have some kind of elegance. One can
  2950. initialize an empty archive and later use @value{op-append} for adding
  2951. all members. Some applications would not welcome making an exception
  2952. in the way of adding the first archive member. On the other hand,
  2953. many people reported that it is dangerously too easy for @command{tar}
  2954. to destroy a magnetic tape with an empty archive@footnote{This is well
  2955. described in @cite{Unix-haters Handbook}, by Simson Garfinkel, Daniel
  2956. Weise & Steven Strassmann, IDG Books, ISBN 1-56884-203-1.}. The two most
  2957. common errors are:
  2958. @enumerate
  2959. @item
  2960. Mistakingly using @code{create} instead of @code{extract}, when the
  2961. intent was to extract the full contents of an archive. This error
  2962. is likely: keys @kbd{c} and @kbd{x} are right next to each other on
  2963. the QWERTY keyboard. Instead of being unpacked, the archive then
  2964. gets wholly destroyed. When users speak about @dfn{exploding} an
  2965. archive, they usually mean something else :-).
  2966. @item
  2967. Forgetting the argument to @code{file}, when the intent was to create
  2968. an archive with a single file in it. This error is likely because a
  2969. tired user can easily add the @kbd{f} key to the cluster of option
  2970. letters, by the mere force of habit, without realizing the full
  2971. consequence of doing so. The usual consequence is that the single
  2972. file, which was meant to be saved, is rather destroyed.
  2973. @end enumerate
  2974. So, recognizing the likelihood and the catastrophical nature of these
  2975. errors, @GNUTAR{} now takes some distance from elegance, and
  2976. cowardly refuses to create an archive when @value{op-create} option is
  2977. given, there are no arguments besides options, and @value{op-files-from}
  2978. option is @emph{not} used. To get around the cautiousness of @GNUTAR{}
  2979. and nevertheless create an archive with nothing in it,
  2980. one may still use, as the value for the @value{op-files-from} option,
  2981. a file with no names in it, as shown in the following commands:
  2982. @smallexample
  2983. @kbd{tar --create --file=empty-archive.tar --files-from=/dev/null}
  2984. @kbd{tar cfT empty-archive.tar /dev/null}
  2985. @end smallexample
  2986. @item @value{op-extract}
  2987. A socket is stored, within a @GNUTAR{} archive, as a pipe.
  2988. @item @value{op-list}
  2989. @GNUTAR{} now shows dates as @samp{1996-08-30},
  2990. while it used to show them as @samp{Aug 30 1996}. (One can revert to
  2991. the old behavior by defining @code{USE_OLD_CTIME} in @file{src/list.c}
  2992. before reinstalling.) But preferably, people should get used to ISO
  2993. 8601 dates. Local American dates should be made available again with
  2994. full date localization support, once ready. In the meantime, programs
  2995. not being localizable for dates should prefer international dates,
  2996. that's really the way to go.
  2997. Look up @url{http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html} if you
  2998. are curious, it contains a detailed explanation of the ISO 8601 standard.
  2999. @end table
  3000. @node Advanced tar
  3001. @section Advanced @GNUTAR{} Operations
  3002. Now that you have learned the basics of using @GNUTAR{}, you may want
  3003. to learn about further ways in which @command{tar} can help you.
  3004. This chapter presents five, more advanced operations which you probably
  3005. won't use on a daily basis, but which serve more specialized functions.
  3006. We also explain the different styles of options and why you might want
  3007. to use one or another, or a combination of them in your @command{tar}
  3008. commands. Additionally, this chapter includes options which allow you to
  3009. define the output from @command{tar} more carefully, and provide help and
  3010. error correction in special circumstances.
  3011. @FIXME{check this after the chapter is actually revised to make sure
  3012. it still introduces the info in the chapter correctly : ).}
  3013. @menu
  3014. * Operations::
  3015. * append::
  3016. * update::
  3017. * concatenate::
  3018. * delete::
  3019. * compare::
  3020. @end menu
  3021. @node Operations
  3022. @subsection The Five Advanced @command{tar} Operations
  3023. @UNREVISED
  3024. In the last chapter, you learned about the first three operations to
  3025. @command{tar}. This chapter presents the remaining five operations to
  3026. @command{tar}: @samp{--append}, @samp{--update}, @samp{--concatenate},
  3027. @samp{--delete}, and @samp{--compare}.
  3028. You are not likely to use these operations as frequently as those
  3029. covered in the last chapter; however, since they perform specialized
  3030. functions, they are quite useful when you do need to use them. We
  3031. will give examples using the same directory and files that you created
  3032. in the last chapter. As you may recall, the directory is called
  3033. @file{practice}, the files are @samp{jazz}, @samp{blues}, @samp{folk},
  3034. @samp{rock}, and the two archive files you created are
  3035. @samp{collection.tar} and @samp{music.tar}.
  3036. We will also use the archive files @samp{afiles.tar} and
  3037. @samp{bfiles.tar}. @samp{afiles.tar} contains the members @samp{apple},
  3038. @samp{angst}, and @samp{aspic}. @samp{bfiles.tar} contains the members
  3039. @samp{./birds}, @samp{baboon}, and @samp{./box}.
  3040. Unless we state otherwise, all practicing you do and examples you follow
  3041. in this chapter will take place in the @file{practice} directory that
  3042. you created in the previous chapter; see @ref{prepare for examples}.
  3043. (Below in this section, we will remind you of the state of the examples
  3044. where the last chapter left them.)
  3045. The five operations that we will cover in this chapter are:
  3046. @table @kbd
  3047. @item --append
  3048. @itemx -r
  3049. Add new entries to an archive that already exists.
  3050. @item --update
  3051. @itemx -r
  3052. Add more recent copies of archive members to the end of an archive, if
  3053. they exist.
  3054. @item --concatenate
  3055. @itemx --catenate
  3056. @itemx -A
  3057. Add one or more pre-existing archives to the end of another archive.
  3058. @item --delete
  3059. Delete items from an archive (does not work on tapes).
  3060. @item --compare
  3061. @itemx --diff
  3062. @itemx -d
  3063. Compare archive members to their counterparts in the file system.
  3064. @end table
  3065. @node append
  3066. @subsection How to Add Files to Existing Archives: @code{--append}
  3067. @UNREVISED
  3068. If you want to add files to an existing archive, you don't need to
  3069. create a new archive; you can use @value{op-append}. The archive must
  3070. already exist in order to use @samp{--append}. (A related operation
  3071. is the @samp{--update} operation; you can use this to add newer
  3072. versions of archive members to an existing archive. To learn how to
  3073. do this with @samp{--update}, @pxref{update}.)
  3074. If you use @value{op-append} to add a file that has the same name as an
  3075. archive member to an archive containing that archive member, then the
  3076. old member is not deleted. What does happen, however, is somewhat
  3077. complex. @command{tar} @emph{allows} you to have infinite number of files
  3078. with the same name. Some operations treat these same-named members no
  3079. differently than any other set of archive members: for example, if you
  3080. view an archive with @value{op-list}, you will see all of those members
  3081. listed, with their modification times, owners, etc.
  3082. Other operations don't deal with these members as perfectly as you might
  3083. prefer; if you were to use @value{op-extract} to extract the archive,
  3084. only the most recently added copy of a member with the same name as four
  3085. other members would end up in the working directory. This is because
  3086. @samp{--extract} extracts an archive in the order the members appeared
  3087. in the archive; the most recently archived members will be extracted
  3088. last. Additionally, an extracted member will @emph{replace} a file of
  3089. the same name which existed in the directory already, and @command{tar}
  3090. will not prompt you about this@footnote{Unless you give it
  3091. @option{--keep-old-files} option, or the disk copy is newer than the
  3092. the one in the archive and you invoke @command{tar} with
  3093. @option{--keep-newer-files} option}. Thus, only the most recently archived
  3094. member will end up being extracted, as it will replace the one
  3095. extracted before it, and so on.
  3096. There exists a special option that allows you to get around this
  3097. behavior and extract (or list) only a particular copy of the file.
  3098. This is @option{--occurrence} option. If you run @command{tar} with
  3099. this option, it will extract only the first copy of the file. You
  3100. may also give this option an argument specifying the number of
  3101. copy to be extracted. Thus, for example if the archive
  3102. @file{archive.tar} contained three copies of file @file{myfile}, then
  3103. the command
  3104. @smallexample
  3105. tar --extract --file archive.tar --occurrence=2 myfile
  3106. @end smallexample
  3107. @noindent
  3108. would extract only the second copy. @xref{Option Summary,---occurrence}, for the description of @value{op-occurrence} option.
  3109. @FIXME{ hag -- you might want to incorporate some of the above into the
  3110. MMwtSN node; not sure. i didn't know how to make it simpler...
  3111. There are a few ways to get around this. (maybe xref Multiple Members
  3112. with the Same Name.}
  3113. @cindex Members, replacing with other members
  3114. @cindex Replacing members with other members
  3115. If you want to replace an archive member, use @value{op-delete} to
  3116. delete the member you want to remove from the archive, , and then use
  3117. @samp{--append} to add the member you want to be in the archive. Note
  3118. that you can not change the order of the archive; the most recently
  3119. added member will still appear last. In this sense, you cannot truly
  3120. ``replace'' one member with another. (Replacing one member with another
  3121. will not work on certain types of media, such as tapes; see @ref{delete}
  3122. and @ref{Media}, for more information.)
  3123. @menu
  3124. * appending files:: Appending Files to an Archive
  3125. * multiple::
  3126. @end menu
  3127. @node appending files
  3128. @subsubsection Appending Files to an Archive
  3129. @UNREVISED
  3130. @cindex Adding files to an Archive
  3131. @cindex Appending files to an Archive
  3132. @cindex Archives, Appending files to
  3133. The simplest way to add a file to an already existing archive is the
  3134. @value{op-append} operation, which writes specified files into the
  3135. archive whether or not they are already among the archived files.
  3136. When you use @samp{--append}, you @emph{must} specify file name
  3137. arguments, as there is no default. If you specify a file that already
  3138. exists in the archive, another copy of the file will be added to the
  3139. end of the archive. As with other operations, the member names of the
  3140. newly added files will be exactly the same as their names given on the
  3141. command line. The @value{op-verbose} option will print out the names
  3142. of the files as they are written into the archive.
  3143. @samp{--append} cannot be performed on some tape drives, unfortunately,
  3144. due to deficiencies in the formats those tape drives use. The archive
  3145. must be a valid @command{tar} archive, or else the results of using this
  3146. operation will be unpredictable. @xref{Media}.
  3147. To demonstrate using @samp{--append} to add a file to an archive,
  3148. create a file called @file{rock} in the @file{practice} directory.
  3149. Make sure you are in the @file{practice} directory. Then, run the
  3150. following @command{tar} command to add @file{rock} to
  3151. @file{collection.tar}:
  3152. @smallexample
  3153. $ @kbd{tar --append --file=collection.tar rock}
  3154. @end smallexample
  3155. @noindent
  3156. If you now use the @value{op-list} operation, you will see that
  3157. @file{rock} has been added to the archive:
  3158. @smallexample
  3159. $ @kbd{tar --list --file=collection.tar}
  3160. -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
  3161. -rw-rw-rw- me user 21 1996-09-23 16:44 blues
  3162. -rw-rw-rw- me user 20 1996-09-23 16:44 folk
  3163. -rw-rw-rw- me user 20 1996-09-23 16:44 rock
  3164. @end smallexample
  3165. @FIXME{in theory, dan will (soon) try to turn this node into what it's
  3166. title claims it will become...}
  3167. @node multiple
  3168. @subsubsection Multiple Files with the Same Name
  3169. You can use @value{op-append} to add copies of files which have been
  3170. updated since the archive was created. (However, we do not recommend
  3171. doing this since there is another @command{tar} option called
  3172. @samp{--update}; @pxref{update} for more information. We describe this
  3173. use of @samp{--append} here for the sake of completeness.) @FIXME{is
  3174. this really a good idea, to give this whole description for something
  3175. which i believe is basically a Stupid way of doing something? certain
  3176. aspects of it show ways in which tar is more broken than i'd personally
  3177. like to admit to, specifically the last sentence. On the other hand, i
  3178. don't think it's a good idea to be saying that we explicitly don't
  3179. recommend using something, but i can't see any better way to deal with
  3180. the situation.}When you extract the archive, the older version will be
  3181. effectively lost. This works because files are extracted from an
  3182. archive in the order in which they were archived. Thus, when the
  3183. archive is extracted, a file archived later in time will replace a
  3184. file of the same name which was archived earlier, even though the older
  3185. version of the file will remain in the archive unless you delete all
  3186. versions of the file.
  3187. Supposing you change the file @file{blues} and then append the changed
  3188. version to @file{collection.tar}. As you saw above, the original
  3189. @file{blues} is in the archive @file{collection.tar}. If you change the
  3190. file and append the new version of the file to the archive, there will
  3191. be two copies in the archive. When you extract the archive, the older
  3192. version of the file will be extracted first, and then replaced by the
  3193. newer version when it is extracted.
  3194. You can append the new, changed copy of the file @file{blues} to the
  3195. archive in this way:
  3196. @smallexample
  3197. $ @kbd{tar --append --verbose --file=collection.tar blues}
  3198. blues
  3199. @end smallexample
  3200. @noindent
  3201. Because you specified the @samp{--verbose} option, @command{tar} has
  3202. printed the name of the file being appended as it was acted on. Now
  3203. list the contents of the archive:
  3204. @smallexample
  3205. $ @kbd{tar --list --verbose --file=collection.tar}
  3206. -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
  3207. -rw-rw-rw- me user 21 1996-09-23 16:44 blues
  3208. -rw-rw-rw- me user 20 1996-09-23 16:44 folk
  3209. -rw-rw-rw- me user 20 1996-09-23 16:44 rock
  3210. -rw-rw-rw- me user 58 1996-10-24 18:30 blues
  3211. @end smallexample
  3212. @noindent
  3213. The newest version of @file{blues} is now at the end of the archive
  3214. (note the different creation dates and file sizes). If you extract
  3215. the archive, the older version of the file @file{blues} will be
  3216. replaced by the newer version. You can confirm this by extracting
  3217. the archive and running @samp{ls} on the directory.
  3218. If you wish to extract the first occurrence of the file @file{blues}
  3219. from the archive, use @value{op-occurrence} option, as shown in
  3220. the following example:
  3221. @smallexample
  3222. $ @kbd{tar --extract -vv --occurrence --file=collection.tar blues}
  3223. -rw-rw-rw- me user 21 1996-09-23 16:44 blues
  3224. @end smallexample
  3225. @xref{Writing}, for more information on @value{op-extract} and
  3226. @xref{Option Summary, --occurrence}, for the description of
  3227. @value{op-occurrence} option.
  3228. @node update
  3229. @subsection Updating an Archive
  3230. @UNREVISED
  3231. @cindex Updating an archive
  3232. In the previous section, you learned how to use @value{op-append} to add
  3233. a file to an existing archive. A related operation is
  3234. @value{op-update}. The @samp{--update} operation updates a @command{tar}
  3235. archive by comparing the date of the specified archive members against
  3236. the date of the file with the same name. If the file has been modified
  3237. more recently than the archive member, then the newer version of the
  3238. file is added to the archive (as with @value{op-append}).
  3239. Unfortunately, you cannot use @samp{--update} with magnetic tape drives.
  3240. The operation will fail.
  3241. @FIXME{other examples of media on which --update will fail? need to ask
  3242. charles and/or mib/thomas/dave shevett..}
  3243. Both @samp{--update} and @samp{--append} work by adding to the end
  3244. of the archive. When you extract a file from the archive, only the
  3245. version stored last will wind up in the file system, unless you use
  3246. the @value{op-backup} option. @FIXME-ref{Multiple Members with the
  3247. Same Name}
  3248. @menu
  3249. * how to update::
  3250. @end menu
  3251. @node how to update
  3252. @subsubsection How to Update an Archive Using @code{--update}
  3253. You must use file name arguments with the @value{op-update} operation.
  3254. If you don't specify any files, @command{tar} won't act on any files and
  3255. won't tell you that it didn't do anything (which may end up confusing
  3256. you).
  3257. @FIXME{note: the above parenthetical added because in fact, this
  3258. behavior just confused the author. :-) }
  3259. To see the @samp{--update} option at work, create a new file,
  3260. @file{classical}, in your practice directory, and some extra text to the
  3261. file @file{blues}, using any text editor. Then invoke @command{tar} with
  3262. the @samp{update} operation and the @value{op-verbose} option specified,
  3263. using the names of all the files in the practice directory as file name
  3264. arguments:
  3265. @smallexample
  3266. $ @kbd{tar --update -v -f collection.tar blues folk rock classical}
  3267. blues
  3268. classical
  3269. $
  3270. @end smallexample
  3271. @noindent
  3272. Because we have specified verbose mode, @command{tar} prints out the names
  3273. of the files it is working on, which in this case are the names of the
  3274. files that needed to be updated. If you run @samp{tar --list} and look
  3275. at the archive, you will see @file{blues} and @file{classical} at its
  3276. end. There will be a total of two versions of the member @samp{blues};
  3277. the one at the end will be newer and larger, since you added text before
  3278. updating it.
  3279. (The reason @command{tar} does not overwrite the older file when updating
  3280. it is because writing to the middle of a section of tape is a difficult
  3281. process. Tapes are not designed to go backward. @xref{Media}, for more
  3282. information about tapes.
  3283. @value{op-update} is not suitable for performing backups for two
  3284. reasons: it does not change directory content entries, and it
  3285. lengthens the archive every time it is used. The @GNUTAR{}
  3286. options intended specifically for backups are more
  3287. efficient. If you need to run backups, please consult @ref{Backups}.
  3288. @node concatenate
  3289. @subsection Combining Archives with @code{--concatenate}
  3290. @cindex Adding archives to an archive
  3291. @cindex Concatenating Archives
  3292. Sometimes it may be convenient to add a second archive onto the end of
  3293. an archive rather than adding individual files to the archive. To add
  3294. one or more archives to the end of another archive, you should use the
  3295. @value{op-concatenate} operation.
  3296. To use @samp{--concatenate}, name the archives to be concatenated on the
  3297. command line. (Nothing happens if you don't list any.) The members,
  3298. and their member names, will be copied verbatim from those archives. If
  3299. this causes multiple members to have the same name, it does not delete
  3300. any members; all the members with the same name coexist. @FIXME-ref{For
  3301. information on how this affects reading the archive, Multiple
  3302. Members with the Same Name.}
  3303. To demonstrate how @samp{--concatenate} works, create two small archives
  3304. called @file{bluesrock.tar} and @file{folkjazz.tar}, using the relevant
  3305. files from @file{practice}:
  3306. @smallexample
  3307. $ @kbd{tar -cvf bluesrock.tar blues rock}
  3308. blues
  3309. classical
  3310. $ @kbd{tar -cvf folkjazz.tar folk jazz}
  3311. folk
  3312. jazz
  3313. @end smallexample
  3314. @noindent
  3315. If you like, You can run @samp{tar --list} to make sure the archives
  3316. contain what they are supposed to:
  3317. @smallexample
  3318. $ @kbd{tar -tvf bluesrock.tar}
  3319. -rw-rw-rw- melissa user 105 1997-01-21 19:42 blues
  3320. -rw-rw-rw- melissa user 33 1997-01-20 15:34 rock
  3321. $ @kbd{tar -tvf folkjazz.tar}
  3322. -rw-rw-rw- melissa user 20 1996-09-23 16:44 folk
  3323. -rw-rw-rw- melissa user 65 1997-01-30 14:15 jazz
  3324. @end smallexample
  3325. We can concatenate these two archives with @command{tar}:
  3326. @smallexample
  3327. $ @kbd{cd ..}
  3328. $ @kbd{tar --concatenate --file=bluesrock.tar jazzfolk.tar}
  3329. @end smallexample
  3330. If you now list the contents of the @file{bluesclass.tar}, you will see
  3331. that now it also contains the archive members of @file{jazzfolk.tar}:
  3332. @smallexample
  3333. $ @kbd{tar --list --file=bluesrock.tar}
  3334. blues
  3335. rock
  3336. jazz
  3337. folk
  3338. @end smallexample
  3339. When you use @samp{--concatenate}, the source and target archives must
  3340. already exist and must have been created using compatible format
  3341. parameters. @FIXME-pxref{Matching Format Parameters}The new,
  3342. concatenated archive will be called by the same name as the first
  3343. archive listed on the command line. @FIXME{is there a way to specify a
  3344. new name?}
  3345. Like @value{op-append}, this operation cannot be performed on some
  3346. tape drives, due to deficiencies in the formats those tape drives use.
  3347. @cindex @code{concatenate} vs @command{cat}
  3348. @cindex @command{cat} vs @code{concatenate}
  3349. It may seem more intuitive to you to want or try to use @command{cat} to
  3350. concatenate two archives instead of using the @samp{--concatenate}
  3351. operation; after all, @command{cat} is the utility for combining files.
  3352. However, @command{tar} archives incorporate an end-of-file marker which
  3353. must be removed if the concatenated archives are to be read properly as
  3354. one archive. @samp{--concatenate} removes the end-of-archive marker
  3355. from the target archive before each new archive is appended. If you use
  3356. @command{cat} to combine the archives, the result will not be a valid
  3357. @command{tar} format archive. If you need to retrieve files from an
  3358. archive that was added to using the @command{cat} utility, use the
  3359. @value{op-ignore-zeros} option. @xref{Ignore Zeros}, for further
  3360. information on dealing with archives improperly combined using the
  3361. @command{cat} shell utility.
  3362. @FIXME{this shouldn't go here. where should it go?} You must specify
  3363. the source archives using @value{op-file} (@value{pxref-file}). If you
  3364. do not specify the target archive, @command{tar} uses the value of the
  3365. environment variable @env{TAPE}, or, if this has not been set, the
  3366. default archive name.
  3367. @node delete
  3368. @subsection Removing Archive Members Using @samp{--delete}
  3369. @UNREVISED
  3370. @cindex Deleting files from an archive
  3371. @cindex Removing files from an archive
  3372. You can remove members from an archive by using the @value{op-delete}
  3373. option. Specify the name of the archive with @value{op-file} and then
  3374. specify the names of the members to be deleted; if you list no member
  3375. names, nothing will be deleted. The @value{op-verbose} option will
  3376. cause @command{tar} to print the names of the members as they are deleted.
  3377. As with @value{op-extract}, you must give the exact member names when
  3378. using @samp{tar --delete}. @samp{--delete} will remove all versions of
  3379. the named file from the archive. The @samp{--delete} operation can run
  3380. very slowly.
  3381. Unlike other operations, @samp{--delete} has no short form.
  3382. @cindex Tapes, using @code{--delete} and
  3383. @cindex Deleting from tape archives
  3384. This operation will rewrite the archive. You can only use
  3385. @samp{--delete} on an archive if the archive device allows you to
  3386. write to any point on the media, such as a disk; because of this, it
  3387. does not work on magnetic tapes. Do not try to delete an archive member
  3388. from a magnetic tape; the action will not succeed, and you will be
  3389. likely to scramble the archive and damage your tape. There is no safe
  3390. way (except by completely re-writing the archive) to delete files from
  3391. most kinds of magnetic tape. @xref{Media}.
  3392. To delete all versions of the file @file{blues} from the archive
  3393. @file{collection.tar} in the @file{practice} directory, make sure you
  3394. are in that directory, and then,
  3395. @smallexample
  3396. $ @kbd{tar --list --file=collection.tar}
  3397. blues
  3398. folk
  3399. jazz
  3400. rock
  3401. practice/blues
  3402. practice/folk
  3403. practice/jazz
  3404. practice/rock
  3405. practice/blues
  3406. $ @kbd{tar --delete --file=collection.tar blues}
  3407. $ @kbd{tar --list --file=collection.tar}
  3408. folk
  3409. jazz
  3410. rock
  3411. $
  3412. @end smallexample
  3413. @FIXME{I changed the order of these nodes around and haven't had a chance
  3414. to fix the above example's results, yet. I have to play with this and
  3415. follow it and see what it actually does!}
  3416. The @value{op-delete} option has been reported to work properly when
  3417. @command{tar} acts as a filter from @code{stdin} to @code{stdout}.
  3418. @node compare
  3419. @subsection Comparing Archive Members with the File System
  3420. @cindex Verifying the currency of an archive
  3421. @UNREVISED
  3422. The @samp{--compare} (@samp{-d}), or @samp{--diff} operation compares
  3423. specified archive members against files with the same names, and then
  3424. reports differences in file size, mode, owner, modification date and
  3425. contents. You should @emph{only} specify archive member names, not file
  3426. names. If you do not name any members, then @command{tar} will compare the
  3427. entire archive. If a file is represented in the archive but does not
  3428. exist in the file system, @command{tar} reports a difference.
  3429. You have to specify the record size of the archive when modifying an
  3430. archive with a non-default record size.
  3431. @command{tar} ignores files in the file system that do not have
  3432. corresponding members in the archive.
  3433. The following example compares the archive members @file{rock},
  3434. @file{blues} and @file{funk} in the archive @file{bluesrock.tar} with
  3435. files of the same name in the file system. (Note that there is no file,
  3436. @file{funk}; @command{tar} will report an error message.)
  3437. @smallexample
  3438. $ @kbd{tar --compare --file=bluesrock.tar rock blues funk}
  3439. rock
  3440. blues
  3441. tar: funk not found in archive
  3442. @end smallexample
  3443. @noindent
  3444. @FIXME{what does this actually depend on? i'm making a guess,
  3445. here.}Depending on the system where you are running @command{tar} and the
  3446. version you are running, @command{tar} may have a different error message,
  3447. such as:
  3448. @smallexample
  3449. funk: does not exist
  3450. @end smallexample
  3451. @FIXME-xref{somewhere, for more information about format parameters.
  3452. Melissa says: such as "format variations"? But why? Clearly I don't
  3453. get it yet; I'll deal when I get to that section.}
  3454. The spirit behind the @value{op-compare} option is to check whether the
  3455. archive represents the current state of files on disk, more than validating
  3456. the integrity of the archive media. For this later goal, @xref{verify}.
  3457. @node create options
  3458. @section Options Used by @code{--create}
  3459. The previous chapter described the basics of how to use
  3460. @value{op-create} to create an archive from a set of files.
  3461. @xref{create}. This section described advanced options to be used with
  3462. @samp{--create}.
  3463. @menu
  3464. * Ignore Failed Read::
  3465. @end menu
  3466. @node Ignore Failed Read
  3467. @subsection Ignore Fail Read
  3468. @table @kbd
  3469. @item --ignore-failed-read
  3470. Do not exit with nonzero on unreadable files or directories.
  3471. @end table
  3472. @node extract options
  3473. @section Options Used by @code{--extract}
  3474. @UNREVISED
  3475. @FIXME{i need to get dan to go over these options with me and see if
  3476. there's a better way of organizing them.}
  3477. The previous chapter showed how to use @value{op-extract} to extract
  3478. an archive into the filesystem. Various options cause @command{tar} to
  3479. extract more information than just file contents, such as the owner,
  3480. the permissions, the modification date, and so forth. This section
  3481. presents options to be used with @samp{--extract} when certain special
  3482. considerations arise. You may review the information presented in
  3483. @ref{extract} for more basic information about the
  3484. @samp{--extract} operation.
  3485. @menu
  3486. * Reading:: Options to Help Read Archives
  3487. * Writing:: Changing How @command{tar} Writes Files
  3488. * Scarce:: Coping with Scarce Resources
  3489. @end menu
  3490. @node Reading
  3491. @subsection Options to Help Read Archives
  3492. @cindex Options when reading archives
  3493. @cindex Reading incomplete records
  3494. @cindex Records, incomplete
  3495. @cindex End-of-archive entries, ignoring
  3496. @cindex Ignoring end-of-archive entries
  3497. @cindex Large lists of file names on small machines
  3498. @cindex Small memory
  3499. @cindex Running out of space
  3500. @UNREVISED
  3501. Normally, @command{tar} will request data in full record increments from
  3502. an archive storage device. If the device cannot return a full record,
  3503. @command{tar} will report an error. However, some devices do not always
  3504. return full records, or do not require the last record of an archive to
  3505. be padded out to the next record boundary. To keep reading until you
  3506. obtain a full record, or to accept an incomplete record if it contains
  3507. an end-of-archive marker, specify the @value{op-read-full-records} option
  3508. in conjunction with the @value{op-extract} or @value{op-list} operations.
  3509. @value{xref-read-full-records}.
  3510. The @value{op-read-full-records} option is turned on by default when
  3511. @command{tar} reads an archive from standard input, or from a remote
  3512. machine. This is because on BSD Unix systems, attempting to read a
  3513. pipe returns however much happens to be in the pipe, even if it is
  3514. less than was requested. If this option were not enabled, @command{tar}
  3515. would fail as soon as it read an incomplete record from the pipe.
  3516. If you're not sure of the blocking factor of an archive, you can
  3517. read the archive by specifying @value{op-read-full-records} and
  3518. @value{op-blocking-factor}, using a blocking factor larger than what the
  3519. archive uses. This lets you avoid having to determine the blocking factor
  3520. of an archive. @value{xref-blocking-factor}.
  3521. @menu
  3522. * read full records::
  3523. * Ignore Zeros::
  3524. @end menu
  3525. @node read full records
  3526. @unnumberedsubsubsec Reading Full Records
  3527. @FIXME{need sentence or so of intro here}
  3528. @table @kbd
  3529. @item --read-full-records
  3530. @item -B
  3531. Use in conjunction with @value{op-extract} to read an archive which
  3532. contains incomplete records, or one which has a blocking factor less
  3533. than the one specified.
  3534. @end table
  3535. @node Ignore Zeros
  3536. @unnumberedsubsubsec Ignoring Blocks of Zeros
  3537. Normally, @command{tar} stops reading when it encounters a block of zeros
  3538. between file entries (which usually indicates the end of the archive).
  3539. @value{op-ignore-zeros} allows @command{tar} to completely read an archive
  3540. which contains a block of zeros before the end (i.e.@: a damaged
  3541. archive, or one which was created by concatenating several archives
  3542. together).
  3543. The @value{op-ignore-zeros} option is turned off by default because many
  3544. versions of @command{tar} write garbage after the end-of-archive entry,
  3545. since that part of the media is never supposed to be read. @GNUTAR{}
  3546. does not write after the end of an archive, but seeks to
  3547. maintain compatiblity among archiving utilities.
  3548. @table @kbd
  3549. @item --ignore-zeros
  3550. @itemx -i
  3551. To ignore blocks of zeros (ie.@: end-of-archive entries) which may be
  3552. encountered while reading an archive. Use in conjunction with
  3553. @value{op-extract} or @value{op-list}.
  3554. @end table
  3555. @node Writing
  3556. @subsection Changing How @command{tar} Writes Files
  3557. @cindex Overwriting old files, prevention
  3558. @cindex Protecting old files
  3559. @cindex Modification times of extracted files
  3560. @cindex Permissions of extracted files
  3561. @cindex Modes of extracted files
  3562. @cindex Writing extracted files to standard output
  3563. @cindex Standard output, writing extracted files to
  3564. @UNREVISED
  3565. @FIXME{need to mention the brand new option, --backup}
  3566. @menu
  3567. * Dealing with Old Files::
  3568. * Overwrite Old Files::
  3569. * Keep Old Files::
  3570. * Keep Newer Files::
  3571. * Unlink First::
  3572. * Recursive Unlink::
  3573. * Modification Times::
  3574. * Setting Access Permissions::
  3575. * Writing to Standard Output::
  3576. * remove files::
  3577. @end menu
  3578. @node Dealing with Old Files
  3579. @unnumberedsubsubsec Options Controlling the Overwriting of Existing Files
  3580. When extracting files, if @command{tar} discovers that the extracted
  3581. file already exists, it normally replaces the file by removing it before
  3582. extracting it, to prevent confusion in the presence of hard or symbolic
  3583. links. (If the existing file is a symbolic link, it is removed, not
  3584. followed.) However, if a directory cannot be removed because it is
  3585. nonempty, @command{tar} normally overwrites its metadata (ownership,
  3586. permission, etc.). The @option{--overwrite-dir} option enables this
  3587. default behavior. To be more cautious and preserve the metadata of
  3588. such a directory, use the @option{--no-overwrite-dir} option.
  3589. To be even more cautious and prevent existing files from being replaced, use
  3590. the @value{op-keep-old-files} option. It causes @command{tar} to refuse
  3591. to replace or update a file that already exists, i.e., a file with the
  3592. same name as an archive member prevents extraction of that archive
  3593. member. Instead, it reports an error.
  3594. To be more aggressive about altering existing files, use the
  3595. @value{op-overwrite} option. It causes @command{tar} to overwrite
  3596. existing files and to follow existing symbolic links when extracting.
  3597. Some people argue that @GNUTAR{} should not hesitate
  3598. to overwrite files with other files when extracting. When extracting
  3599. a @command{tar} archive, they expect to see a faithful copy of the
  3600. state of the filesystem when the archive was created. It is debatable
  3601. that this would always be a proper behavior. For example, suppose one
  3602. has an archive in which @file{usr/local} is a link to
  3603. @file{usr/local2}. Since then, maybe the site removed the link and
  3604. renamed the whole hierarchy from @file{/usr/local2} to
  3605. @file{/usr/local}. Such things happen all the time. I guess it would
  3606. not be welcome at all that @GNUTAR{} removes the
  3607. whole hierarchy just to make room for the link to be reinstated
  3608. (unless it @emph{also} simultaneously restores the full
  3609. @file{/usr/local2}, of course!) @GNUTAR{} is indeed
  3610. able to remove a whole hierarchy to reestablish a symbolic link, for
  3611. example, but @emph{only if} @value{op-recursive-unlink} is specified
  3612. to allow this behavior. In any case, single files are silently
  3613. removed.
  3614. Finally, the @value{op-unlink-first} option can improve performance in
  3615. some cases by causing @command{tar} to remove files unconditionally
  3616. before extracting them.
  3617. @node Overwrite Old Files
  3618. @unnumberedsubsubsec Overwrite Old Files
  3619. @table @kbd
  3620. @item --overwrite
  3621. Overwrite existing files and directory metadata when extracting files
  3622. from an archive.
  3623. This
  3624. causes @command{tar} to write extracted files into the file system without
  3625. regard to the files already on the system; i.e., files with the same
  3626. names as archive members are overwritten when the archive is extracted.
  3627. It also causes @command{tar} to extract the ownership, permissions,
  3628. and time stamps onto any preexisting files or directories.
  3629. If the name of a corresponding file name is a symbolic link, the file
  3630. pointed to by the symbolic link will be overwritten instead of the
  3631. symbolic link itself (if this is possible). Moreover, special devices,
  3632. empty directories and even symbolic links are automatically removed if
  3633. they are in the way of extraction.
  3634. Be careful when using the @value{op-overwrite} option, particularly when
  3635. combined with the @value{op-absolute-names} option, as this combination
  3636. can change the contents, ownership or permissions of any file on your
  3637. system. Also, many systems do not take kindly to overwriting files that
  3638. are currently being executed.
  3639. @item --overwrite-dir
  3640. Overwrite the metadata of directories when extracting files from an
  3641. archive, but remove other files before extracting.
  3642. @end table
  3643. @node Keep Old Files
  3644. @unnumberedsubsubsec Keep Old Files
  3645. @table @kbd
  3646. @item --keep-old-files
  3647. @itemx -k
  3648. Do not replace existing files from archive. The
  3649. @value{op-keep-old-files} option prevents @command{tar} from replacing
  3650. existing files with files with the same name from the archive.
  3651. The @value{op-keep-old-files} option is meaningless with @value{op-list}.
  3652. Prevents @command{tar} from replacing files in the file system during
  3653. extraction.
  3654. @end table
  3655. @node Keep Newer Files
  3656. @unnumberedsubsubsec Keep Newer Files
  3657. @table @kbd
  3658. @item --keep-newer-files
  3659. Do not replace existing files that are newer than their archive
  3660. copies. This option is meaningless with @value{op-list}.
  3661. @end table
  3662. @node Unlink First
  3663. @unnumberedsubsubsec Unlink First
  3664. @table @kbd
  3665. @item --unlink-first
  3666. @itemx -U
  3667. Remove files before extracting over them.
  3668. This can make @command{tar} run a bit faster if you know in advance
  3669. that the extracted files all need to be removed. Normally this option
  3670. slows @command{tar} down slightly, so it is disabled by default.
  3671. @end table
  3672. @node Recursive Unlink
  3673. @unnumberedsubsubsec Recursive Unlink
  3674. @table @kbd
  3675. @item --recursive-unlink
  3676. When this option is specified, try removing files and directory hierarchies
  3677. before extracting over them. @emph{This is a dangerous option!}
  3678. @end table
  3679. If you specify the @value{op-recursive-unlink} option,
  3680. @command{tar} removes @emph{anything} that keeps you from extracting a file
  3681. as far as current permissions will allow it. This could include removal
  3682. of the contents of a full directory hierarchy.
  3683. @node Modification Times
  3684. @unnumberedsubsubsec Setting Modification Times
  3685. Normally, @command{tar} sets the modification times of extracted files to
  3686. the modification times recorded for the files in the archive, but
  3687. limits the permissions of extracted files by the current @code{umask}
  3688. setting.
  3689. To set the modification times of extracted files to the time when
  3690. the files were extracted, use the @value{op-touch} option in
  3691. conjunction with @value{op-extract}.
  3692. @table @kbd
  3693. @item --touch
  3694. @itemx -m
  3695. Sets the modification time of extracted archive members to the time
  3696. they were extracted, not the time recorded for them in the archive.
  3697. Use in conjunction with @value{op-extract}.
  3698. @end table
  3699. @node Setting Access Permissions
  3700. @unnumberedsubsubsec Setting Access Permissions
  3701. To set the modes (access permissions) of extracted files to those
  3702. recorded for those files in the archive, use @samp{--same-permissions}
  3703. in conjunction with the @value{op-extract} operation. @FIXME{Should be
  3704. aliased to ignore-umask.}
  3705. @table @kbd
  3706. @item --preserve-permission
  3707. @itemx --same-permission
  3708. @itemx --ignore-umask
  3709. @itemx -p
  3710. Set modes of extracted archive members to those recorded in the
  3711. archive, instead of current umask settings. Use in conjunction with
  3712. @value{op-extract}.
  3713. @end table
  3714. @FIXME{Following paragraph needs to be rewritten: why doesn't this cat
  3715. files together, why is this useful. is it really useful with
  3716. more than one file?}
  3717. @node Writing to Standard Output
  3718. @unnumberedsubsubsec Writing to Standard Output
  3719. To write the extracted files to the standard output, instead of
  3720. creating the files on the file system, use @value{op-to-stdout} in
  3721. conjunction with @value{op-extract}. This option is useful if you are
  3722. extracting files to send them through a pipe, and do not need to
  3723. preserve them in the file system. If you extract multiple members,
  3724. they appear on standard output concatenated, in the order they are
  3725. found in the archive.
  3726. @table @kbd
  3727. @item --to-stdout
  3728. @itemx -O
  3729. Writes files to the standard output. Used in conjunction with
  3730. @value{op-extract}. Extract files to standard output. When this option
  3731. is used, instead of creating the files specified, @command{tar} writes
  3732. the contents of the files extracted to its standard output. This may
  3733. be useful if you are only extracting the files in order to send them
  3734. through a pipe. This option is meaningless with @value{op-list}.
  3735. @end table
  3736. This can be useful, for example, if you have a tar archive containing
  3737. a big file and don't want to store the file on disk before processing
  3738. it. You can use a command like this:
  3739. @smallexample
  3740. tar -xOzf foo.tgz bigfile | process
  3741. @end smallexample
  3742. or even like this if you want to process the concatenation of the files:
  3743. @smallexample
  3744. tar -xOzf foo.tgz bigfile1 bigfile2 | process
  3745. @end smallexample
  3746. @node remove files
  3747. @unnumberedsubsubsec Removing Files
  3748. @FIXME{the various macros in the front of the manual think that this
  3749. option goes in this section. i have no idea; i only know it's nowhere
  3750. else in the book...}
  3751. @table @kbd
  3752. @item --remove-files
  3753. Remove files after adding them to the archive.
  3754. @end table
  3755. @node Scarce
  3756. @subsection Coping with Scarce Resources
  3757. @cindex Middle of the archive, starting in the
  3758. @cindex Running out of space during extraction
  3759. @cindex Disk space, running out of
  3760. @cindex Space on the disk, recovering from lack of
  3761. @UNREVISED
  3762. @menu
  3763. * Starting File::
  3764. * Same Order::
  3765. @end menu
  3766. @node Starting File
  3767. @unnumberedsubsubsec Starting File
  3768. @table @kbd
  3769. @item --starting-file=@var{name}
  3770. @itemx -K @var{name}
  3771. Starts an operation in the middle of an archive. Use in conjunction
  3772. with @value{op-extract} or @value{op-list}.
  3773. @end table
  3774. If a previous attempt to extract files failed due to lack of disk
  3775. space, you can use @value{op-starting-file} to start extracting only
  3776. after member @var{name} of the archive. This assumes, of course, that
  3777. there is now free space, or that you are now extracting into a
  3778. different file system. (You could also choose to suspend @command{tar},
  3779. remove unnecessary files from the file system, and then restart the
  3780. same @command{tar} operation. In this case, @value{op-starting-file} is
  3781. not necessary. @value{xref-incremental}, @value{xref-interactive},
  3782. and @value{ref-exclude}.)
  3783. @node Same Order
  3784. @unnumberedsubsubsec Same Order
  3785. @table @kbd
  3786. @item --same-order
  3787. @itemx --preserve-order
  3788. @itemx -s
  3789. To process large lists of file names on machines with small amounts of
  3790. memory. Use in conjunction with @value{op-compare},
  3791. @value{op-list}
  3792. or @value{op-extract}.
  3793. @end table
  3794. @FIXME{we don't need/want --preserve to exist any more (from melissa:
  3795. ie, don't want that *version* of the option to exist, or don't want
  3796. the option to exist in either version?}
  3797. @FIXME{i think this explanation is lacking.}
  3798. The @value{op-same-order} option tells @command{tar} that the list of file
  3799. names to be listed or extracted is sorted in the same order as the
  3800. files in the archive. This allows a large list of names to be used,
  3801. even on a small machine that would not otherwise be able to hold all
  3802. the names in memory at the same time. Such a sorted list can easily be
  3803. created by running @samp{tar -t} on the archive and editing its output.
  3804. This option is probably never needed on modern computer systems.
  3805. @node backup
  3806. @section Backup options
  3807. @cindex backup options
  3808. @GNUTAR{} offers options for making backups of files
  3809. before writing new versions. These options control the details of
  3810. these backups. They may apply to the archive itself before it is
  3811. created or rewritten, as well as individual extracted members. Other
  3812. @acronym{GNU} programs (@command{cp}, @command{install}, @command{ln},
  3813. and @command{mv}, for example) offer similar options.
  3814. Backup options may prove unexpectedly useful when extracting archives
  3815. containing many members having identical name, or when extracting archives
  3816. on systems having file name limitations, making different members appear
  3817. has having similar names through the side-effect of name truncation.
  3818. (This is true only if we have a good scheme for truncated backup names,
  3819. which I'm not sure at all: I suspect work is needed in this area.)
  3820. When any existing file is backed up before being overwritten by extraction,
  3821. then clashing files are automatically be renamed to be unique, and the
  3822. true name is kept for only the last file of a series of clashing files.
  3823. By using verbose mode, users may track exactly what happens.
  3824. At the detail level, some decisions are still experimental, and may
  3825. change in the future, we are waiting comments from our users. So, please
  3826. do not learn to depend blindly on the details of the backup features.
  3827. For example, currently, directories themselves are never renamed through
  3828. using these options, so, extracting a file over a directory still has
  3829. good chances to fail. Also, backup options apply to created archives,
  3830. not only to extracted members. For created archives, backups will not
  3831. be attempted when the archive is a block or character device, or when it
  3832. refers to a remote file.
  3833. For the sake of simplicity and efficiency, backups are made by renaming old
  3834. files prior to creation or extraction, and not by copying. The original
  3835. name is restored if the file creation fails. If a failure occurs after a
  3836. partial extraction of a file, both the backup and the partially extracted
  3837. file are kept.
  3838. @table @samp
  3839. @item --backup[=@var{method}]
  3840. @opindex --backup
  3841. @vindex VERSION_CONTROL
  3842. @cindex backups
  3843. Back up files that are about to be overwritten or removed.
  3844. Without this option, the original versions are destroyed.
  3845. Use @var{method} to determine the type of backups made.
  3846. If @var{method} is not specified, use the value of the @env{VERSION_CONTROL}
  3847. environment variable. And if @env{VERSION_CONTROL} is not set,
  3848. use the @samp{existing} method.
  3849. @vindex version-control @r{Emacs variable}
  3850. This option corresponds to the Emacs variable @samp{version-control};
  3851. the same values for @var{method} are accepted as in Emacs. This option
  3852. also allows more descriptive names. The valid @var{method}s are:
  3853. @table @samp
  3854. @item t
  3855. @itemx numbered
  3856. @opindex numbered @r{backup method}
  3857. Always make numbered backups.
  3858. @item nil
  3859. @itemx existing
  3860. @opindex existing @r{backup method}
  3861. Make numbered backups of files that already have them, simple backups
  3862. of the others.
  3863. @item never
  3864. @itemx simple
  3865. @opindex simple @r{backup method}
  3866. Always make simple backups.
  3867. @end table
  3868. @item --suffix=@var{suffix}
  3869. @opindex --suffix
  3870. @cindex backup suffix
  3871. @vindex SIMPLE_BACKUP_SUFFIX
  3872. Append @var{suffix} to each backup file made with @samp{--backup}. If this
  3873. option is not specified, the value of the @env{SIMPLE_BACKUP_SUFFIX}
  3874. environment variable is used. And if @env{SIMPLE_BACKUP_SUFFIX} is not
  3875. set, the default is @samp{~}, just as in Emacs.
  3876. @end table
  3877. Some people express the desire to @emph{always} use the @value{op-backup}
  3878. option, by defining some kind of alias or script. This is not as easy
  3879. as one may think, due to the fact that old style options should appear first
  3880. and consume arguments a bit unpredictably for an alias or script. But,
  3881. if you are ready to give up using old style options, you may resort to
  3882. using something like (a Bourne shell function here):
  3883. @smallexample
  3884. tar () @{ /usr/local/bin/tar --backup $*; @}
  3885. @end smallexample
  3886. @node Applications
  3887. @section Notable @command{tar} Usages
  3888. @UNREVISED
  3889. @FIXME{Using Unix file linking capability to recreate directory
  3890. structures---linking files into one subdirectory and then
  3891. @command{tar}ring that directory.}
  3892. @FIXME{Nice hairy example using absolute-names, newer, etc.}
  3893. @findex uuencode
  3894. You can easily use archive files to transport a group of files from
  3895. one system to another: put all relevant files into an archive on one
  3896. computer system, transfer the archive to another system, and extract
  3897. the contents there. The basic transfer medium might be magnetic tape,
  3898. Internet FTP, or even electronic mail (though you must encode the
  3899. archive with @command{uuencode} in order to transport it properly by
  3900. mail). Both machines do not have to use the same operating system, as
  3901. long as they both support the @command{tar} program.
  3902. For example, here is how you might copy a directory's contents from
  3903. one disk to another, while preserving the dates, modes, owners and
  3904. link-structure of all the files therein. In this case, the transfer
  3905. medium is a @dfn{pipe}, which is one a Unix redirection mechanism:
  3906. @smallexample
  3907. $ @kbd{cd sourcedir; tar -cf - . | (cd targetdir; tar -xf -)}
  3908. @end smallexample
  3909. @noindent
  3910. The command also works using short option forms:
  3911. @smallexample
  3912. $ @w{@kbd{cd sourcedir; tar --create --file=- . | (cd targetdir; tar --extract --file=-)}}
  3913. @end smallexample
  3914. @noindent
  3915. This is one of the easiest methods to transfer a @command{tar} archive.
  3916. @node looking ahead
  3917. @section Looking Ahead: The Rest of this Manual
  3918. You have now seen how to use all eight of the operations available to
  3919. @command{tar}, and a number of the possible options. The next chapter
  3920. explains how to choose and change file and archive names, how to use
  3921. files to store names of other files which you can then call as
  3922. arguments to @command{tar} (this can help you save time if you expect to
  3923. archive the same list of files a number of times), and so forth.
  3924. @FIXME{in case it's not obvious, i'm making this up in some sense
  3925. based on my limited memory of what the next chapter *really* does. i
  3926. just wanted to flesh out this final section a little bit so i'd
  3927. remember to stick it in here. :-)}
  3928. If there are too many files to conveniently list on the command line,
  3929. you can list the names in a file, and @command{tar} will read that file.
  3930. @value{xref-files-from}.
  3931. There are various ways of causing @command{tar} to skip over some files,
  3932. and not archive them. @xref{Choosing}.
  3933. @node Backups
  3934. @chapter Performing Backups and Restoring Files
  3935. @UNREVISED
  3936. @GNUTAR{} is distributed along with the scripts
  3937. which the Free Software Foundation uses for performing backups. There
  3938. is no corresponding scripts available yet for doing restoration of
  3939. files. Even if there is a good chance those scripts may be satisfying
  3940. to you, they are not the only scripts or methods available for doing
  3941. backups and restore. You may well create your own, or use more
  3942. sophisticated packages dedicated to that purpose.
  3943. Some users are enthusiastic about @code{Amanda} (The Advanced Maryland
  3944. Automatic Network Disk Archiver), a backup system developed by James
  3945. da Silva @file{jds@@cs.umd.edu} and available on many Unix systems.
  3946. This is free software, and it is available at these places:
  3947. @smallexample
  3948. http://www.cs.umd.edu/projects/amanda/amanda.html
  3949. ftp://ftp.cs.umd.edu/pub/amanda
  3950. @end smallexample
  3951. @ifclear PUBLISH
  3952. Here is a possible plan for a future documentation about the backuping
  3953. scripts which are provided within the @GNUTAR{}
  3954. distribution.
  3955. @smallexample
  3956. .* dumps
  3957. . + what are dumps
  3958. . + different levels of dumps
  3959. . - full dump = dump everything
  3960. . - level 1, level 2 dumps etc, -
  3961. A level n dump dumps everything changed since the last level
  3962. n-1 dump (?)
  3963. . + how to use scripts for dumps (ie, the concept)
  3964. . - scripts to run after editing backup specs (details)
  3965. . + Backup Specs, what is it.
  3966. . - how to customize
  3967. . - actual text of script [/sp/dump/backup-specs]
  3968. . + Problems
  3969. . - rsh doesn't work
  3970. . - rtape isn't installed
  3971. . - (others?)
  3972. . + the --incremental option of tar
  3973. . + tapes
  3974. . - write protection
  3975. . - types of media
  3976. . : different sizes and types, useful for different things
  3977. . - files and tape marks
  3978. one tape mark between files, two at end.
  3979. . - positioning the tape
  3980. MT writes two at end of write,
  3981. backspaces over one when writing again.
  3982. @end smallexample
  3983. @end ifclear
  3984. This chapter documents both the provided shell scripts and @command{tar}
  3985. options which are more specific to usage as a backup tool.
  3986. To @dfn{back up} a file system means to create archives that contain
  3987. all the files in that file system. Those archives can then be used to
  3988. restore any or all of those files (for instance if a disk crashes or a
  3989. file is accidentally deleted). File system @dfn{backups} are also
  3990. called @dfn{dumps}.
  3991. @menu
  3992. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  3993. * Inc Dumps:: Using @command{tar} to Perform Incremental Dumps
  3994. * incremental and listed-incremental:: The Incremental Options
  3995. * Backup Levels:: Levels of Backups
  3996. * Backup Parameters:: Setting Parameters for Backups and Restoration
  3997. * Scripted Backups:: Using the Backup Scripts
  3998. * Scripted Restoration:: Using the Restore Script
  3999. @end menu
  4000. @node Full Dumps
  4001. @section Using @command{tar} to Perform Full Dumps
  4002. @UNREVISED
  4003. @cindex full dumps
  4004. @cindex dumps, full
  4005. @cindex corrupted archives
  4006. Full dumps should only be made when no other people or programs
  4007. are modifying files in the filesystem. If files are modified while
  4008. @command{tar} is making the backup, they may not be stored properly in
  4009. the archive, in which case you won't be able to restore them if you
  4010. have to. (Files not being modified are written with no trouble, and do
  4011. not corrupt the entire archive.)
  4012. You will want to use the @value{op-label} option to give the archive a
  4013. volume label, so you can tell what this archive is even if the label
  4014. falls off the tape, or anything like that.
  4015. Unless the filesystem you are dumping is guaranteed to fit on
  4016. one volume, you will need to use the @value{op-multi-volume} option.
  4017. Make sure you have enough tapes on hand to complete the backup.
  4018. If you want to dump each filesystem separately you will need to use
  4019. the @value{op-one-file-system} option to prevent @command{tar} from crossing
  4020. filesystem boundaries when storing (sub)directories.
  4021. The @value{op-incremental} option is not needed, since this is a complete
  4022. copy of everything in the filesystem, and a full restore from this
  4023. backup would only be done onto a completely empty disk.
  4024. Unless you are in a hurry, and trust the @command{tar} program (and your
  4025. tapes), it is a good idea to use the @value{op-verify} option, to make
  4026. sure your files really made it onto the dump properly. This will
  4027. also detect cases where the file was modified while (or just after)
  4028. it was being archived. Not all media (notably cartridge tapes) are
  4029. capable of being verified, unfortunately.
  4030. @value{op-listed-incremental} take a file name argument always. If the
  4031. file doesn't exist, run a level zero dump, creating the file. If the
  4032. file exists, uses that file to see what has changed.
  4033. @value{op-incremental} @FIXME{look it up}
  4034. @value{op-incremental} handle old @acronym{GNU}-format incremental backup.
  4035. This option should only be used when creating an incremental backup of
  4036. a filesystem. When the @value{op-incremental} option is used, @command{tar}
  4037. writes, at the beginning of the archive, an entry for each of the
  4038. directories that will be operated on. The entry for a directory
  4039. includes a list of all the files in the directory at the time the
  4040. dump was done, and a flag for each file indicating whether the file
  4041. is going to be put in the archive. This information is used when
  4042. doing a complete incremental restore.
  4043. Note that this option causes @command{tar} to create a non-standard
  4044. archive that may not be readable by non-@acronym{GNU} versions of the
  4045. @command{tar} program.
  4046. The @value{op-incremental} option means the archive is an incremental
  4047. backup. Its meaning depends on the command that it modifies.
  4048. If the @value{op-incremental} option is used with @value{op-list},
  4049. @command{tar} will list, for each directory in the archive, the list
  4050. of files in that directory at the time the archive was created. This
  4051. information is put out in a format that is not easy for humans to
  4052. read, but which is unambiguous for a program: each file name is
  4053. preceded by either a @samp{Y} if the file is present in the archive,
  4054. an @samp{N} if the file is not included in the archive, or a @samp{D}
  4055. if the file is a directory (and is included in the archive). Each
  4056. file name is terminated by a null character. The last file is
  4057. followed by an additional null and a newline to indicate the end of
  4058. the data.
  4059. If the @value{op-incremental} option is used with @value{op-extract}, then
  4060. when the entry for a directory is found, all files that currently
  4061. exist in that directory but are not listed in the archive @emph{are
  4062. deleted from the directory}.
  4063. This behavior is convenient when you are restoring a damaged file
  4064. system from a succession of incremental backups: it restores the
  4065. entire state of the file system to that which obtained when the backup
  4066. was made. If you don't use @value{op-incremental}, the file system will
  4067. probably fill up with files that shouldn't exist any more.
  4068. @value{op-listed-incremental} handle new @acronym{GNU}-format
  4069. incremental backup. This option handles new @acronym{GNU}-format
  4070. incremental backup. It has much the same effect as
  4071. @value{op-incremental}, but also the time when the dump is done and
  4072. the list of directories dumped is written to the given
  4073. @var{file}. When restoring, only files newer than the saved time are
  4074. restored, and the directory list is used to speed up operations.
  4075. @value{op-listed-incremental} acts like @value{op-incremental}, but when
  4076. used in conjunction with @value{op-create} will also cause @command{tar} to
  4077. use the file @var{file}, which contains information about the state
  4078. of the filesystem at the time of the last backup, to decide which
  4079. files to include in the archive being created. That file will then
  4080. be updated by @command{tar}. If the file @var{file} does not exist when
  4081. this option is specified, @command{tar} will create it, and include all
  4082. appropriate files in the archive.
  4083. The file, which is archive independent, contains the date it was last
  4084. modified and a list of devices, inode numbers and directory names.
  4085. @command{tar} will archive files with newer mod dates or inode change
  4086. times, and directories with an unchanged inode number and device but
  4087. a changed directory name. The file is updated after the files to
  4088. be archived are determined, but before the new archive is actually
  4089. created.
  4090. @node Inc Dumps
  4091. @section Using @command{tar} to Perform Incremental Dumps
  4092. @UNREVISED
  4093. @cindex incremental dumps
  4094. @cindex dumps, incremental
  4095. Performing incremental dumps is similar to performing full dumps,
  4096. although a few more options will usually be needed.
  4097. A standard scheme is to do a @emph{monthly} (full) dump once a month,
  4098. a @emph{weekly} dump once a week of everything since the last monthly
  4099. and a @emph{daily} every day of everything since the last (weekly or
  4100. monthly) dump.
  4101. Here is a sample script to dump the directory hierarchies @samp{/usr}
  4102. and @samp{/var}.
  4103. @smallexample
  4104. #! /bin/sh
  4105. tar --create \
  4106. --blocking-factor=126 \
  4107. --file=/dev/rmt/0 \
  4108. --label="`hostname` /usr /var `date +%Y-%m-%d`" \
  4109. --listed-incremental=/var/log/usr-var.snar \
  4110. --verbose \
  4111. /usr /var
  4112. @end smallexample
  4113. This script uses the file @file{/var/log/usr-var.snar} as a snapshot to
  4114. store information about the previous tar dump.
  4115. The blocking factor 126 is an attempt to make the tape drive stream.
  4116. Some tape devices cannot handle 64 kB blocks or larger, and require the
  4117. block size to be a multiple of 1 kB; for these devices, 126 is the
  4118. largest blocking factor that can be used.
  4119. @node incremental and listed-incremental
  4120. @section The Incremental Options
  4121. @UNREVISED
  4122. @value{op-incremental} is used in conjunction with @value{op-create},
  4123. @value{op-extract} or @value{op-list} when backing up and restoring file
  4124. systems. An archive cannot be extracted or listed with the
  4125. @value{op-incremental} option specified unless it was created with the
  4126. option specified. This option should only be used by a script, not by
  4127. the user, and is usually disregarded in favor of
  4128. @value{op-listed-incremental}, which is described below.
  4129. @value{op-incremental} in conjunction with @value{op-create} causes
  4130. @command{tar} to write, at the beginning of the archive, an entry for
  4131. each of the directories that will be archived. The entry for a
  4132. directory includes a list of all the files in the directory at the
  4133. time the archive was created and a flag for each file indicating
  4134. whether or not the file is going to be put in the archive.
  4135. Note that this option causes @command{tar} to create a non-standard
  4136. archive that may not be readable by non-@acronym{GNU} versions of the
  4137. @command{tar} program.
  4138. @value{op-incremental} in conjunction with @value{op-extract} causes
  4139. @command{tar} to read the lists of directory contents previously stored
  4140. in the archive, @emph{delete} files in the file system that did not
  4141. exist in their directories when the archive was created, and then
  4142. extract the files in the archive.
  4143. This behavior is convenient when restoring a damaged file system from
  4144. a succession of incremental backups: it restores the entire state of
  4145. the file system to that which obtained when the backup was made. If
  4146. @value{op-incremental} isn't specified, the file system will probably
  4147. fill up with files that shouldn't exist any more.
  4148. @value{op-incremental} in conjunction with @value{op-list} causes
  4149. @command{tar} to print, for each directory in the archive, the list of
  4150. files in that directory at the time the archive was created. This
  4151. information is put out in a format that is not easy for humans to
  4152. read, but which is unambiguous for a program: each file name is
  4153. preceded by either a @samp{Y} if the file is present in the archive,
  4154. an @samp{N} if the file is not included in the archive, or a @samp{D}
  4155. if the file is a directory (and is included in the archive). Each
  4156. file name is terminated by a null character. The last file is followed
  4157. by an additional null and a newline to indicate the end of the data.
  4158. @value{op-listed-incremental} acts like @value{op-incremental}, but when
  4159. used in conjunction with @value{op-create} will also cause @command{tar}
  4160. to use the file @var{snapshot-file}, which contains information about
  4161. the state of the file system at the time of the last backup, to decide
  4162. which files to include in the archive being created. That file will
  4163. then be updated by @command{tar}. If the file @var{file} does not exist
  4164. when this option is specified, @command{tar} will create it, and include
  4165. all appropriate files in the archive.
  4166. The file @var{file}, which is archive independent, contains the date
  4167. it was last modified and a list of devices, inode numbers and
  4168. directory names. @command{tar} will archive files with newer mod dates
  4169. or inode change times, and directories with an unchanged inode number
  4170. and device but a changed directory name. The file is updated after
  4171. the files to be archived are determined, but before the new archive is
  4172. actually created.
  4173. Incremental dumps depend crucially on time stamps, so the results are
  4174. unreliable if you modify a file's time stamps during dumping (e.g.@:
  4175. with the @samp{--atime-preserve} option), or if you set the clock
  4176. backwards.
  4177. Despite it should be obvious that a device has a non-volatile value, NFS
  4178. devices have non-dependable values when an automounter gets in the picture.
  4179. This led to a great deal of spurious redumping in incremental dumps,
  4180. so it is somewhat useless to compare two NFS devices numbers over time.
  4181. So @command{tar} now considers all NFS devices as being equal when it comes
  4182. to comparing directories; this is fairly gross, but there does not seem
  4183. to be a better way to go.
  4184. @command{tar} doesn't access @var{snapshot-file} when
  4185. @value{op-extract} or @value{op-list} are specified, but the
  4186. @value{op-listed-incremental} option must still be given. A
  4187. placeholder @var{snapshot-file} can be specified, e.g.,
  4188. @file{/dev/null}.
  4189. @FIXME{this section needs to be written}
  4190. @node Backup Levels
  4191. @section Levels of Backups
  4192. An archive containing all the files in the file system is called a
  4193. @dfn{full backup} or @dfn{full dump}. You could insure your data by
  4194. creating a full dump every day. This strategy, however, would waste a
  4195. substantial amount of archive media and user time, as unchanged files
  4196. are daily re-archived.
  4197. It is more efficient to do a full dump only occasionally. To back up
  4198. files between full dumps, you can use @dfn{incremental dumps}. A @dfn{level
  4199. one} dump archives all the files that have changed since the last full
  4200. dump.
  4201. A typical dump strategy would be to perform a full dump once a week,
  4202. and a level one dump once a day. This means some versions of files
  4203. will in fact be archived more than once, but this dump strategy makes
  4204. it possible to restore a file system to within one day of accuracy by
  4205. only extracting two archives---the last weekly (full) dump and the
  4206. last daily (level one) dump. The only information lost would be in
  4207. files changed or created since the last daily backup. (Doing dumps
  4208. more than once a day is usually not worth the trouble).
  4209. @GNUTAR{} comes with scripts you can use to do full
  4210. and level-one (actually, even level-two and so on) dumps. Using
  4211. scripts (shell programs) to perform backups and restoration is a
  4212. convenient and reliable alternative to typing out file name lists
  4213. and @command{tar} commands by hand.
  4214. Before you use these scripts, you need to edit the file
  4215. @file{backup-specs}, which specifies parameters used by the backup
  4216. scripts and by the restore script. This file is usually located
  4217. in @file{/etc/backup} directory. @FIXME-xref{Script Syntax} Once the
  4218. backup parameters are set, you can perform backups or restoration by
  4219. running the appropriate script.
  4220. The name of the backup script is @code{backup}. The name of the
  4221. restore script is @code{restore}. The following sections describe
  4222. their use in detail.
  4223. @emph{Please Note:} The backup and restoration scripts are
  4224. designed to be used together. While it is possible to restore files by
  4225. hand from an archive which was created using a backup script, and to create
  4226. an archive by hand which could then be extracted using the restore script,
  4227. it is easier to use the scripts. @value{xref-incremental}, and
  4228. @value{xref-listed-incremental}, before making such an attempt.
  4229. @node Backup Parameters
  4230. @section Setting Parameters for Backups and Restoration
  4231. The file @file{backup-specs} specifies backup parameters for the
  4232. backup and restoration scripts provided with @command{tar}. You must
  4233. edit @file{backup-specs} to fit your system configuration and schedule
  4234. before using these scripts.
  4235. Syntactically, @file{backup-specs} is a shell script, containing
  4236. mainly variable assignments. However, any valid shell construct
  4237. is allowed in this file. Particularly, you may wish to define
  4238. functions within that script (e.g. see @code{RESTORE_BEGIN} below).
  4239. For more information about shell script syntax, please refer to
  4240. @url{http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#ta
  4241. g_02, the definition of the Shell Command Language}. See also
  4242. @ref{Top,,Bash Features,bashref,Bash Reference Manual}.
  4243. The shell variables controlling behavior of @code{backup} and
  4244. @code{restore} are described in the following subsections.
  4245. @menu
  4246. * General-Purpose Variables::
  4247. * Magnetic Tape Control::
  4248. * User Hooks::
  4249. * backup-specs example:: An Example Text of @file{Backup-specs}
  4250. @end menu
  4251. @node General-Purpose Variables
  4252. @subsection General-Purpose Variables
  4253. @defvr {Backup variable} ADMINISTRATOR
  4254. The user name of the backup administrator. @code{Backup} scripts
  4255. sends a backup report to this address.
  4256. @end defvr
  4257. @defvr {Backup variable} BACKUP_HOUR
  4258. The hour at which the backups are done. This can be a number from 0
  4259. to 23, or the time specification in form @var{hours}:@var{minutes},
  4260. or the string @samp{now}.
  4261. This variable is used by @code{backup}. Its value may be overridden
  4262. using @option{--time} option (@pxref{Scripted Backups}).
  4263. @end defvr
  4264. @defvr {Backup variable} TAPE_FILE
  4265. The device @command{tar} writes the archive to. This device should be
  4266. attached to the host on which the dump scripts are run.
  4267. @end defvr
  4268. @defvr {Backup variable} BLOCKING
  4269. The blocking factor @command{tar} will use when writing the dump archive.
  4270. @value{xref-blocking-factor}.
  4271. @end defvr
  4272. @defvr {Backup variable} BACKUP_DIRS
  4273. A list of file systems to be dumped (for @code{backup}), or restored
  4274. (for @code{restore}). You can include any directory
  4275. name in the list --- subdirectories on that file system will be
  4276. included, regardless of how they may look to other networked machines.
  4277. Subdirectories on other file systems will be ignored.
  4278. The host name specifies which host to run @command{tar} on, and should
  4279. normally be the host that actually contains the file system. However,
  4280. the host machine must have @GNUTAR{} installed, and
  4281. must be able to access the directory containing the backup scripts and
  4282. their support files using the same file name that is used on the
  4283. machine where the scripts are run (ie. what @command{pwd} will print
  4284. when in that directory on that machine). If the host that contains
  4285. the file system does not have this capability, you can specify another
  4286. host as long as it can access the file system through NFS.
  4287. If the list of file systems is very long you may wish to put it
  4288. in a separate file. This file is usually named
  4289. @file{/etc/backup/dirs}, but this name may be overridden in
  4290. @file{backup-specs} using @code{DIRLIST} variable.
  4291. @end defvr
  4292. @defvr {Backup variable} DIRLIST
  4293. A path to the file containing the list of the filesystems to backup
  4294. or restore. By default it is @file{/etc/backup/dirs}.
  4295. @end defvr
  4296. @defvr {Backup variable} BACKUP_FILES
  4297. A list of individual files to be dumped (for @code{backup}), or restored
  4298. (for @code{restore}). These should be accessible from the machine on
  4299. which the backup script is run.
  4300. If the list of file systems is very long you may wish to store it
  4301. in a separate file. This file is usually named
  4302. @file{/etc/backup/files}, but this name may be overridden in
  4303. @file{backup-specs} using @code{FILELIST} variable.
  4304. @end defvr
  4305. @defvr {Backup variable} FILELIST
  4306. A path to the file containing the list of the individual files to backup
  4307. or restore. By default it is @file{/etc/backup/files}.
  4308. @end defvr
  4309. @defvr {Backup variable} RSH
  4310. Path to @code{rsh} binary or its equivalent. You may wish to
  4311. set it to @code{ssh}, to improve security. In this case you will have
  4312. to use public key authentication.
  4313. @end defvr
  4314. @defvr {Backup variable} RSH_COMMAND
  4315. Path to rsh binary on remote mashines. This will be passed via
  4316. @option{--rsh-command} option to the remote invocation of @GNUTAR{}.
  4317. @end defvr
  4318. @defvr {Backup variable} VOLNO_FILE
  4319. Name of temporary file to hold volume numbers. This needs to be accessible
  4320. by all the machines which have filesystems to be dumped.
  4321. @end defvr
  4322. @defvr {Backup variable} XLIST
  4323. Name of @dfn{exclude file list}. An @dfn{exclude file list} is a file
  4324. located on the remote machine and containing the list of files to
  4325. be excluded from the backup. Exclude file lists are searched in
  4326. /etc/tar-backup directory. A common use for exclude file lists
  4327. is to exclude files containing security-sensitive information
  4328. (e.g. @file{/etc/shadow} from backups).
  4329. This variable affects only @code{backup}.
  4330. @end defvr
  4331. @defvr {Backup variable} SLEEP_TIME
  4332. Time to sleep between dumps of any two successive filesystems
  4333. This variable affects only @code{backup}.
  4334. @end defvr
  4335. @defvr {Backup variable} DUMP_REMIND_SCRIPT
  4336. Script to be run when it's time to insert a new tape in for the next
  4337. volume. Administrators may want to tailor this script for their site.
  4338. If this variable isn't set, @GNUTAR{} will display its built-in prompt
  4339. @FIXME-xref{describe it somewhere!}, and will expect confirmation from
  4340. the console.
  4341. @end defvr
  4342. @defvr {Backup variable} SLEEP_MESSAGE
  4343. Message to display on the terminal while waiting for dump time. Usually
  4344. this will just be some literal text.
  4345. @end defvr
  4346. @defvr {Backup variable} TAR
  4347. Pathname of the @GNUTAR{} executable. If this is not set, backup
  4348. scripts will search @command{tar} in the current shell path.
  4349. @end defvr
  4350. @node Magnetic Tape Control
  4351. @subsection Magnetic Tape Control
  4352. Backup scripts access tape device using special @dfn{hook functions}.
  4353. These functions take a single argument -- the name of the tape
  4354. device. Their names are kept in the following variables:
  4355. @defvr {Backup variable} MT_BEGIN
  4356. The name of @dfn{begin} function. This function is called before
  4357. accessing the drive. By default it retensions the tape:
  4358. @smallexample
  4359. MT_BEGIN=mt_begin
  4360. mt_begin() @{
  4361. mt -f "$1" retension
  4362. @}
  4363. @end smallexample
  4364. @end defvr
  4365. @defvr {Backup variable} MT_REWIND
  4366. The name of @dfn{rewind} function. The default definition is as
  4367. follows:
  4368. @smallexample
  4369. MT_REWIND=mt_rewind
  4370. mt_rewind() @{
  4371. mt -f "$1" rewind
  4372. @}
  4373. @end smallexample
  4374. @end defvr
  4375. @defvr {Backup variable} MT_OFFLINE
  4376. The name of the function switching the tape off line. By default
  4377. it is defined as follows:
  4378. @smallexample
  4379. MT_OFFLINE=mt_offline
  4380. mt_offline() @{
  4381. mt -f "$1" offl
  4382. @}
  4383. @end smallexample
  4384. @end defvr
  4385. @defvr {Backup variable} MT_STATUS
  4386. The name of the function used to obtain the status of the archive device,
  4387. including error count. Default definition:
  4388. @smallexample
  4389. MT_STATUS=mt_status
  4390. mt_status() @{
  4391. mt -f "$1" status
  4392. @}
  4393. @end smallexample
  4394. @end defvr
  4395. @node User Hooks
  4396. @subsection User Hooks
  4397. @dfn{User hooks} are shell functions executed before and after
  4398. each @command{tar} invocation. Thus, there are @dfn{backup
  4399. hooks}, which are executed before and after dumping each file
  4400. system, and @dfn{restore hooks}, executed before and
  4401. after restoring a file system. Each user hook is a shell function
  4402. taking four arguments:
  4403. @deffn {User Hook Function} hook @var{level} @var{host} @var{fs} @var{fsname}
  4404. Its arguments are:
  4405. @table @var
  4406. @item level
  4407. Current backup or restore level.
  4408. @item host
  4409. Name or IP address of the host machine being dumped or restored.
  4410. @item fs
  4411. Full path name to the filesystem being dumped or restored.
  4412. @item fsname
  4413. Filesystem name with directory separators replaced with colons. This
  4414. is useful e.g. for creating unique files.
  4415. @end table
  4416. @end deffn
  4417. Following variables keep the names of user hook functions
  4418. @defvr {Backup variable} DUMP_BEGIN
  4419. Dump begin function. It is executed before dumping the filesystem.
  4420. @end defvr
  4421. @defvr {Backup variable} DUMP_END
  4422. Executed after dumping the filesystem.
  4423. @end defvr
  4424. @defvr {Backup variable} RESTORE_BEGIN
  4425. Executed before restoring the filesystem.
  4426. @end defvr
  4427. @defvr {Backup variable} RESTORE_END
  4428. Executed after restoring the filesystem.
  4429. @end defvr
  4430. @node backup-specs example
  4431. @subsection An Example Text of @file{Backup-specs}
  4432. The following is an example of @file{backup-specs}:
  4433. @smallexample
  4434. # site-specific parameters for file system backup.
  4435. ADMINISTRATOR=friedman
  4436. BACKUP_HOUR=1
  4437. TAPE_FILE=/dev/nrsmt0
  4438. # Use @code{ssh} instead of the less secure @code{rsh}
  4439. RSH=/usr/bin/ssh
  4440. RSH_COMMAND=/usr/bin/ssh
  4441. # Override MT_STATUS function:
  4442. my_status() @{
  4443. mts -t $TAPE_FILE
  4444. @}
  4445. MT_STATUS=my_status
  4446. # Disable MT_OFFLINE function
  4447. MT_OFFLINE=:
  4448. BLOCKING=124
  4449. BACKUP_DIRS="
  4450. albert:/fs/fsf
  4451. apple-gunkies:/gd
  4452. albert:/fs/gd2
  4453. albert:/fs/gp
  4454. geech:/usr/jla
  4455. churchy:/usr/roland
  4456. albert:/
  4457. albert:/usr
  4458. apple-gunkies:/
  4459. apple-gunkies:/usr
  4460. gnu:/hack
  4461. gnu:/u
  4462. apple-gunkies:/com/mailer/gnu
  4463. apple-gunkies:/com/archive/gnu"
  4464. BACKUP_FILES="/com/mailer/aliases /com/mailer/league*[a-z]"
  4465. @end smallexample
  4466. @node Scripted Backups
  4467. @section Using the Backup Scripts
  4468. The syntax for running a backup script is:
  4469. @smallexample
  4470. backup --level=@var{level} --time=@var{time}
  4471. @end smallexample
  4472. The @option{level} option requests the dump level. Thus, to produce
  4473. a full dump, specify @code{--level=0} (this is the default, so
  4474. @option{--level} may be omitted if its value is @code{0}).
  4475. @footnote{For backward compatibility, the @code{backup} will also
  4476. try to deduce the requested dump level from the name of the
  4477. script itself. If the name consists of a string @samp{level-}
  4478. followed by a single decimal digit, that digit is taken as
  4479. the dump level number. Thus, you may create a link from @code{backup}
  4480. to @code{level-1} and then run @code{level-1} whenever you need to
  4481. create a level one dump.}
  4482. The @option{--time} option determines when should the backup be
  4483. run. @var{Time} may take three forms:
  4484. @table @asis
  4485. @item @var{hh}:@var{mm}
  4486. The dump must be run at @var{hh} hours @var{mm} minutes.
  4487. @item @var{hh}
  4488. The dump must be run at @var{hh} hours
  4489. @item now
  4490. The dump must be run immediately.
  4491. @end table
  4492. You should start a script with a tape or disk mounted. Once you
  4493. start a script, it prompts you for new tapes or disks as it
  4494. needs them. Media volumes don't have to correspond to archive
  4495. files --- a multi-volume archive can be started in the middle of a
  4496. tape that already contains the end of another multi-volume archive.
  4497. The @code{restore} script prompts for media by its archive volume,
  4498. so to avoid an error message you should keep track of which tape
  4499. (or disk) contains which volume of the archive (@pxref{Scripted
  4500. Restoration}).
  4501. The backup scripts write two files on the file system. The first is a
  4502. record file in @file{/etc/tar-backup/}, which is used by the scripts
  4503. to store and retrieve information about which files were dumped. This
  4504. file is not meant to be read by humans, and should not be deleted by
  4505. them. @FIXME-xref{incremental and listed-incremental, for a more
  4506. detailed explanation of this file.}
  4507. The second file is a log file containing the names of the file systems
  4508. and files dumped, what time the backup was made, and any error
  4509. messages that were generated, as well as how much space was left in
  4510. the media volume after the last volume of the archive was written.
  4511. You should check this log file after every backup. The file name is
  4512. @file{log-@var{mm-dd-yyyy}-level-@var{n}}, where @var{mm-dd-yyyy}
  4513. represents current date, and @var{n} represents current dump level number.
  4514. The script also prints the name of each system being dumped to the
  4515. standard output.
  4516. Following is the full list of options accepted by @code{backup}
  4517. script:
  4518. @table @option
  4519. @item -l @var{level}
  4520. @itemx --level=@var{level}
  4521. Do backup level @var{level} (default 0).
  4522. @item -f
  4523. @itemx --force
  4524. Force backup even if today's log file already exists.
  4525. @item -v[@var{level}]
  4526. @itemx --verbose[=@var{level}]
  4527. Set verbosity level. The higher the level is, the more debugging
  4528. information will be output during execution. Devault @var{level}
  4529. is 100, which means the highest debugging level.
  4530. @item -t @var{start-time}
  4531. @itemx --time=@var{start-time}
  4532. Wait till @var{time}, then do backup.
  4533. @item -h
  4534. @itemx --help
  4535. Display short help message and exit.
  4536. @item -L
  4537. @itemx --license
  4538. Display program license and exit.
  4539. @item -V
  4540. @itemx --version
  4541. Display program version and exit.
  4542. @end table
  4543. @node Scripted Restoration
  4544. @section Using the Restore Script
  4545. To restore files that were archived using a scripted backup, use the
  4546. @code{restore} script. Its usage is quite straightforward. In the
  4547. simplest form, invoke @code{restore --all}, it will
  4548. then restore all the filesystems and files specified in
  4549. @file{backup-specs} (@pxref{General-Purpose Variables,BACKUP_DIRS}).
  4550. You may select the filesystems (and/or files) to restore by
  4551. giving @code{restore} list of @dfn{patterns} in its command
  4552. line. For example, running
  4553. @smallexample
  4554. restore 'albert:*'
  4555. @end smallexample
  4556. @noindent
  4557. will restore all filesystems on the machine @samp{albert}. A more
  4558. complicated example:
  4559. @smallexample
  4560. restore 'albert:*' '*:/var'
  4561. @end smallexample
  4562. @noindent
  4563. This command will restore all filesystems on the machine @samp{albert}
  4564. as well as @file{/var} filesystem on all machines.
  4565. By default @code{restore} will start restoring files from the lowest
  4566. available dump level (usually zero) and will continue through
  4567. all available dump levels. There may be situations where such a
  4568. thorough restore is not necessary. For example, you may wish to
  4569. restore only files from the recent level one backup. To do so,
  4570. use @option{--level} option, as shown in the example below:
  4571. @smallexample
  4572. restore --level=1
  4573. @end smallexample
  4574. The full list of options accepted by @code{restore} follows:
  4575. @table @option
  4576. @item -a
  4577. @itemx --all
  4578. Restore all filesystems and files specified in @file{backup-specs}
  4579. @item -l @var{level}
  4580. @itemx --level=@var{level}
  4581. Start restoring from the given backup level, instead of the default 0.
  4582. @item -v[@var{level}]
  4583. @itemx --verbose[=@var{level}]
  4584. Set verbosity level. The higher the level is, the more debugging
  4585. information will be output during execution. Devault @var{level}
  4586. is 100, which means the highest debugging level.
  4587. @item -h
  4588. @itemx --help
  4589. Display short help message and exit.
  4590. @item -L
  4591. @itemx --license
  4592. Display program license and exit.
  4593. @item -V
  4594. @itemx --version
  4595. Display program version and exit.
  4596. @end table
  4597. You should start the restore script with the media containing the
  4598. first volume of the archive mounted. The script will prompt for other
  4599. volumes as they are needed. If the archive is on tape, you don't need
  4600. to rewind the tape to to its beginning---if the tape head is
  4601. positioned past the beginning of the archive, the script will rewind
  4602. the tape as needed. @FIXME-xref{Media, for a discussion of tape
  4603. positioning.}
  4604. @quotation
  4605. @strong{Warning:} The script will delete files from the active file
  4606. system if they were not in the file system when the archive was made.
  4607. @end quotation
  4608. @value{xref-incremental}, and @value{ref-listed-incremental},
  4609. for an explanation of how the script makes that determination.
  4610. @node Choosing
  4611. @chapter Choosing Files and Names for @command{tar}
  4612. @UNREVISED
  4613. @FIXME{Melissa (still) Doesn't Really Like This ``Intro'' Paragraph!!!}
  4614. Certain options to @command{tar} enable you to specify a name for your
  4615. archive. Other options let you decide which files to include or exclude
  4616. from the archive, based on when or whether files were modified, whether
  4617. the file names do or don't match specified patterns, or whether files
  4618. are in specified directories.
  4619. @menu
  4620. * file:: Choosing the Archive's Name
  4621. * Selecting Archive Members::
  4622. * files:: Reading Names from a File
  4623. * exclude:: Excluding Some Files
  4624. * Wildcards::
  4625. * after:: Operating Only on New Files
  4626. * recurse:: Descending into Directories
  4627. * one:: Crossing Filesystem Boundaries
  4628. @end menu
  4629. @node file
  4630. @section Choosing and Naming Archive Files
  4631. @cindex Naming an archive
  4632. @cindex Archive Name
  4633. @cindex Directing output
  4634. @cindex Choosing an archive file
  4635. @cindex Where is the archive?
  4636. @UNREVISED
  4637. @FIXME{should the title of this section actually be, "naming an
  4638. archive"?}
  4639. By default, @command{tar} uses an archive file name that was compiled when
  4640. it was built on the system; usually this name refers to some physical
  4641. tape drive on the machine. However, the person who installed @command{tar}
  4642. on the system may not set the default to a meaningful value as far as
  4643. most users are concerned. As a result, you will usually want to tell
  4644. @command{tar} where to find (or create) the archive. The @value{op-file}
  4645. option allows you to either specify or name a file to use as the archive
  4646. instead of the default archive file location.
  4647. @table @kbd
  4648. @item --file=@var{archive-name}
  4649. @itemx -f @var{archive-name}
  4650. Name the archive to create or operate on. Use in conjunction with
  4651. any operation.
  4652. @end table
  4653. For example, in this @command{tar} command,
  4654. @smallexample
  4655. $ @kbd{tar -cvf collection.tar blues folk jazz}
  4656. @end smallexample
  4657. @noindent
  4658. @file{collection.tar} is the name of the archive. It must directly
  4659. follow the @samp{-f} option, since whatever directly follows @samp{-f}
  4660. @emph{will} end up naming the archive. If you neglect to specify an
  4661. archive name, you may end up overwriting a file in the working directory
  4662. with the archive you create since @command{tar} will use this file's name
  4663. for the archive name.
  4664. An archive can be saved as a file in the file system, sent through a
  4665. pipe or over a network, or written to an I/O device such as a tape,
  4666. floppy disk, or CD write drive.
  4667. @cindex Writing new archives
  4668. @cindex Archive creation
  4669. If you do not name the archive, @command{tar} uses the value of the
  4670. environment variable @env{TAPE} as the file name for the archive. If
  4671. that is not available, @command{tar} uses a default, compiled-in archive
  4672. name, usually that for tape unit zero (ie. @file{/dev/tu00}).
  4673. @command{tar} always needs an archive name.
  4674. If you use @file{-} as an @var{archive-name}, @command{tar} reads the
  4675. archive from standard input (when listing or extracting files), or
  4676. writes it to standard output (when creating an archive). If you use
  4677. @file{-} as an @var{archive-name} when modifying an archive,
  4678. @command{tar} reads the original archive from its standard input and
  4679. writes the entire new archive to its standard output.
  4680. @FIXME{might want a different example here; this is already used in
  4681. "notable tar usages".}
  4682. @smallexample
  4683. $ @kbd{cd sourcedir; tar -cf - . | (cd targetdir; tar -xf -)}
  4684. @end smallexample
  4685. @FIXME{help!}
  4686. @cindex Standard input and output
  4687. @cindex tar to standard input and output
  4688. To specify an archive file on a device attached to a remote machine,
  4689. use the following:
  4690. @smallexample
  4691. @kbd{--file=@var{hostname}:/@var{dev}/@var{file name}}
  4692. @end smallexample
  4693. @noindent
  4694. @command{tar} will complete the remote connection, if possible, and
  4695. prompt you for a username and password. If you use
  4696. @samp{--file=@@@var{hostname}:/@var{dev}/@var{file name}}, @command{tar}
  4697. will complete the remote connection, if possible, using your username
  4698. as the username on the remote machine.
  4699. If the archive file name includes a colon (@samp{:}), then it is assumed
  4700. to be a file on another machine. If the archive file is
  4701. @samp{@var{user}@@@var{host}:@var{file}}, then @var{file} is used on the
  4702. host @var{host}. The remote host is accessed using the @command{rsh}
  4703. program, with a username of @var{user}. If the username is omitted
  4704. (along with the @samp{@@} sign), then your user name will be used.
  4705. (This is the normal @command{rsh} behavior.) It is necessary for the
  4706. remote machine, in addition to permitting your @command{rsh} access, to
  4707. have the @file{rmt} program installed (This command is included in
  4708. the @GNUTAR{} distribution and by default is installed under
  4709. @file{@var{prefix}/libexec/rmt}, were @var{prefix} means your
  4710. installation prefix). If you need to use a file whose name includes a
  4711. colon, then the remote tape drive behavior
  4712. can be inhibited by using the @value{op-force-local} option.
  4713. @FIXME{i know we went over this yesterday, but bob (and now i do again,
  4714. too) thinks it's out of the middle of nowhere. it doesn't seem to tie
  4715. into what came before it well enough <<i moved it now, is it better
  4716. here?>>. bob also comments that if Amanda isn't free software, we
  4717. shouldn't mention it..}
  4718. When the archive is being created to @file{/dev/null}, @GNUTAR{}
  4719. tries to minimize input and output operations. The
  4720. Amanda backup system, when used with @GNUTAR{}, has
  4721. an initial sizing pass which uses this feature.
  4722. @node Selecting Archive Members
  4723. @section Selecting Archive Members
  4724. @cindex Specifying files to act on
  4725. @cindex Specifying archive members
  4726. @dfn{File Name arguments} specify which files in the file system
  4727. @command{tar} operates on, when creating or adding to an archive, or which
  4728. archive members @command{tar} operates on, when reading or deleting from
  4729. an archive. @xref{Operations}.
  4730. To specify file names, you can include them as the last arguments on
  4731. the command line, as follows:
  4732. @smallexample
  4733. @kbd{tar} @var{operation} [@var{option1} @var{option2} @dots{}] [@var{file name-1} @var{file name-2} @dots{}]
  4734. @end smallexample
  4735. If you specify a directory name as a file name argument, all the files
  4736. in that directory are operated on by @command{tar}.
  4737. If you do not specify files when @command{tar} is invoked with
  4738. @value{op-create}, @command{tar} operates on all the non-directory files in
  4739. the working directory. If you specify either @value{op-list} or
  4740. @value{op-extract}, @command{tar} operates on all the archive members in the
  4741. archive. If you specify any operation other than one of these three,
  4742. @command{tar} does nothing.
  4743. By default, @command{tar} takes file names from the command line. However,
  4744. there are other ways to specify file or member names, or to modify the
  4745. manner in which @command{tar} selects the files or members upon which to
  4746. operate. @FIXME{add xref here}In general, these methods work both for
  4747. specifying the names of files and archive members.
  4748. @node files
  4749. @section Reading Names from a File
  4750. @UNREVISED
  4751. @cindex Reading file names from a file
  4752. @cindex Lists of file names
  4753. @cindex File Name arguments, alternatives
  4754. Instead of giving the names of files or archive members on the command
  4755. line, you can put the names into a file, and then use the
  4756. @value{op-files-from} option to @command{tar}. Give the name of the file
  4757. which contains the list of files to include as the argument to
  4758. @samp{--files-from}. In the list, the file names should be separated by
  4759. newlines. You will frequently use this option when you have generated
  4760. the list of files to archive with the @command{find} utility.
  4761. @table @kbd
  4762. @item --files-from=@var{file name}
  4763. @itemx -T @var{file name}
  4764. Get names to extract or create from file @var{file name}.
  4765. @end table
  4766. If you give a single dash as a file name for @samp{--files-from}, (i.e.,
  4767. you specify either @samp{--files-from=-} or @samp{-T -}), then the file
  4768. names are read from standard input.
  4769. Unless you are running @command{tar} with @samp{--create}, you can not use
  4770. both @samp{--files-from=-} and @samp{--file=-} (@samp{-f -}) in the same
  4771. command.
  4772. @FIXME{add bob's example, from his message on 2-10-97}
  4773. The following example shows how to use @command{find} to generate a list of
  4774. files smaller than 400K in length and put that list into a file
  4775. called @file{small-files}. You can then use the @samp{-T} option to
  4776. @command{tar} to specify the files from that file, @file{small-files}, to
  4777. create the archive @file{little.tgz}. (The @samp{-z} option to
  4778. @command{tar} compresses the archive with @command{gzip}; @pxref{gzip} for
  4779. more information.)
  4780. @smallexample
  4781. $ @kbd{find . -size -400 -print > small-files}
  4782. $ @kbd{tar -c -v -z -T small-files -f little.tgz}
  4783. @end smallexample
  4784. @noindent
  4785. @FIXME{say more here to conclude the example/section?}
  4786. @menu
  4787. * nul::
  4788. @end menu
  4789. @node nul
  4790. @subsection @kbd{NUL} Terminated File Names
  4791. @cindex File names, terminated by @kbd{NUL}
  4792. @cindex @kbd{NUL} terminated file names
  4793. The @value{op-null} option causes @value{op-files-from} to read file
  4794. names terminated by a @code{NUL} instead of a newline, so files whose
  4795. names contain newlines can be archived using @samp{--files-from}.
  4796. @table @kbd
  4797. @item --null
  4798. Only consider @kbd{NUL} terminated file names, instead of files that
  4799. terminate in a newline.
  4800. @end table
  4801. The @samp{--null} option is just like the one in @acronym{GNU}
  4802. @command{xargs} and @command{cpio}, and is useful with the
  4803. @samp{-print0} predicate of @acronym{GNU} @command{find}. In
  4804. @command{tar}, @samp{--null} also causes @value{op-directory} options
  4805. to be treated as file names to archive, in case there are any files
  4806. out there called @file{-C}.
  4807. This example shows how to use @command{find} to generate a list of files
  4808. larger than 800K in length and put that list into a file called
  4809. @file{long-files}. The @samp{-print0} option to @command{find} just just
  4810. like @samp{-print}, except that it separates files with a @kbd{NUL}
  4811. rather than with a newline. You can then run @command{tar} with both the
  4812. @samp{--null} and @samp{-T} options to specify that @command{tar} get the
  4813. files from that file, @file{long-files}, to create the archive
  4814. @file{big.tgz}. The @samp{--null} option to @command{tar} will cause
  4815. @command{tar} to recognize the @kbd{NUL} separator between files.
  4816. @smallexample
  4817. $ @kbd{find . -size +800 -print0 > long-files}
  4818. $ @kbd{tar -c -v --null --files-from=long-files --file=big.tar}
  4819. @end smallexample
  4820. @FIXME{say anything else here to conclude the section?}
  4821. @node exclude
  4822. @section Excluding Some Files
  4823. @cindex File names, excluding files by
  4824. @cindex Excluding files by name and pattern
  4825. @cindex Excluding files by file system
  4826. @UNREVISED
  4827. To avoid operating on files whose names match a particular pattern,
  4828. use the @value{op-exclude} or @value{op-exclude-from} options.
  4829. @table @kbd
  4830. @item --exclude=@var{pattern}
  4831. Causes @command{tar} to ignore files that match the @var{pattern}.
  4832. @end table
  4833. @findex exclude
  4834. The @value{op-exclude} option prevents any file or member whose name
  4835. matches the shell wildcard (@var{pattern}) from being operated on.
  4836. For example, to create an archive with all the contents of the directory
  4837. @file{src} except for files whose names end in @file{.o}, use the
  4838. command @samp{tar -cf src.tar --exclude='*.o' src}.
  4839. You may give multiple @samp{--exclude} options.
  4840. @table @kbd
  4841. @item --exclude-from=@var{file}
  4842. @itemx -X @var{file}
  4843. Causes @command{tar} to ignore files that match the patterns listed in
  4844. @var{file}.
  4845. @end table
  4846. @findex exclude-from
  4847. Use the @samp{--exclude-from=@var{file-of-patterns}} option to read a
  4848. list of patterns, one per line, from @var{file}; @command{tar} will
  4849. ignore files matching those patterns. Thus if @command{tar} is
  4850. called as @w{@samp{tar -c -X foo .}} and the file @file{foo} contains a
  4851. single line @file{*.o}, no files whose names end in @file{.o} will be
  4852. added to the archive.
  4853. @FIXME{do the exclude options files need to have stuff separated by
  4854. newlines the same as the files-from option does?}
  4855. @menu
  4856. * controlling pattern-patching with exclude::
  4857. * problems with exclude::
  4858. @end menu
  4859. @node controlling pattern-patching with exclude
  4860. @unnumberedsubsec Controlling Pattern-Matching with the @code{exclude} Options
  4861. Normally, a pattern matches a name if an initial subsequence of the
  4862. name's components matches the pattern, where @samp{*}, @samp{?}, and
  4863. @samp{[...]} are the usual shell wildcards, @samp{\} escapes wildcards,
  4864. and wildcards can match @samp{/}.
  4865. Other than optionally stripping leading @samp{/} from names
  4866. (@pxref{absolute}), patterns and names are used as-is. For
  4867. example, trailing @samp{/} is not trimmed from a user-specified name
  4868. before deciding whether to exclude it.
  4869. However, this matching procedure can be altered by the options listed
  4870. below. These options accumulate. For example:
  4871. @smallexample
  4872. --ignore-case --exclude='makefile' --no-ignore-case ---exclude='readme'
  4873. @end smallexample
  4874. ignores case when excluding @samp{makefile}, but not when excluding
  4875. @samp{readme}.
  4876. @table @option
  4877. @item --anchored
  4878. @itemx --no-anchored
  4879. If anchored, a pattern must match an initial subsequence
  4880. of the name's components. Otherwise, the pattern can match any
  4881. subsequence. Default is @option{--no-anchored}.
  4882. @item --ignore-case
  4883. @itemx --no-ignore-case
  4884. When ignoring case, upper-case patterns match lower-case names and vice versa.
  4885. When not ignoring case (the default), matching is case-sensitive.
  4886. @item --wildcards
  4887. @itemx --no-wildcards
  4888. When using wildcards (the default), @samp{*}, @samp{?}, and @samp{[...]}
  4889. are the usual shell wildcards, and @samp{\} escapes wildcards.
  4890. Otherwise, none of these characters are special, and patterns must match
  4891. names literally.
  4892. @item --wildcards-match-slash
  4893. @itemx --no-wildcards-match-slash
  4894. When wildcards match slash (the default), a wildcard like @samp{*} in
  4895. the pattern can match a @samp{/} in the name. Otherwise, @samp{/} is
  4896. matched only by @samp{/}.
  4897. @end table
  4898. The @option{--recursion} and @option{--no-recursion} options
  4899. (@pxref{recurse}) also affect how exclude patterns are interpreted. If
  4900. recursion is in effect, a pattern excludes a name if it matches any of
  4901. the name's parent directories.
  4902. @node problems with exclude
  4903. @unnumberedsubsec Problems with Using the @code{exclude} Options
  4904. Some users find @samp{exclude} options confusing. Here are some common
  4905. pitfalls:
  4906. @itemize @bullet
  4907. @item
  4908. The main operating mode of @command{tar} does not act on a path name
  4909. explicitly listed on the command line if one of its file name
  4910. components is excluded. In the example above, if
  4911. you create an archive and exclude files that end with @samp{*.o}, but
  4912. explicitly name the file @samp{dir.o/foo} after all the options have been
  4913. listed, @samp{dir.o/foo} will be excluded from the archive.
  4914. @item
  4915. You can sometimes confuse the meanings of @value{op-exclude} and
  4916. @value{op-exclude-from}. Be careful: use @value{op-exclude} when files
  4917. to be excluded are given as a pattern on the command line. Use
  4918. @samp{--exclude-from=@var{file-of-patterns}} to introduce the name of a
  4919. file which contains a list of patterns, one per line; each of these
  4920. patterns can exclude zero, one, or many files.
  4921. @item
  4922. When you use @value{op-exclude}, be sure to quote the @var{pattern}
  4923. parameter, so @GNUTAR{} sees wildcard characters
  4924. like @samp{*}. If you do not do this, the shell might expand the
  4925. @samp{*} itself using files at hand, so @command{tar} might receive a
  4926. list of files instead of one pattern, or none at all, making the
  4927. command somewhat illegal. This might not correspond to what you want.
  4928. For example, write:
  4929. @smallexample
  4930. $ @kbd{tar -c -f @var{archive.tar} --exclude '*.o' @var{directory}}
  4931. @end smallexample
  4932. @noindent
  4933. rather than:
  4934. @smallexample
  4935. $ @kbd{tar -c -f @var{archive.tar} --exclude *.o @var{directory}}
  4936. @end smallexample
  4937. @item
  4938. You must use use shell syntax, or globbing, rather than @code{regexp}
  4939. syntax, when using exclude options in @command{tar}. If you try to use
  4940. @code{regexp} syntax to describe files to be excluded, your command
  4941. might fail.
  4942. @item
  4943. In earlier versions of @command{tar}, what is now the
  4944. @samp{--exclude-from=@var{file-of-patterns}} option was called
  4945. @samp{--exclude=@var{pattern}} instead. Now,
  4946. @samp{--exclude=@var{pattern}} applies to patterns listed on the command
  4947. line and @samp{--exclude-from=@var{file-of-patterns}} applies to
  4948. patterns listed in a file.
  4949. @end itemize
  4950. @node Wildcards
  4951. @section Wildcards Patterns and Matching
  4952. @dfn{Globbing} is the operation by which @dfn{wildcard} characters,
  4953. @samp{*} or @samp{?} for example, are replaced and expanded into all
  4954. existing files matching the given pattern. However, @command{tar} often
  4955. uses wildcard patterns for matching (or globbing) archive members instead
  4956. of actual files in the filesystem. Wildcard patterns are also used for
  4957. verifying volume labels of @command{tar} archives. This section has the
  4958. purpose of explaining wildcard syntax for @command{tar}.
  4959. @FIXME{the next few paragraphs need work.}
  4960. A @var{pattern} should be written according to shell syntax, using wildcard
  4961. characters to effect globbing. Most characters in the pattern stand
  4962. for themselves in the matched string, and case is significant: @samp{a}
  4963. will match only @samp{a}, and not @samp{A}. The character @samp{?} in the
  4964. pattern matches any single character in the matched string. The character
  4965. @samp{*} in the pattern matches zero, one, or more single characters in
  4966. the matched string. The character @samp{\} says to take the following
  4967. character of the pattern @emph{literally}; it is useful when one needs to
  4968. match the @samp{?}, @samp{*}, @samp{[} or @samp{\} characters, themselves.
  4969. The character @samp{[}, up to the matching @samp{]}, introduces a character
  4970. class. A @dfn{character class} is a list of acceptable characters
  4971. for the next single character of the matched string. For example,
  4972. @samp{[abcde]} would match any of the first five letters of the alphabet.
  4973. Note that within a character class, all of the ``special characters''
  4974. listed above other than @samp{\} lose their special meaning; for example,
  4975. @samp{[-\\[*?]]} would match any of the characters, @samp{-}, @samp{\},
  4976. @samp{[}, @samp{*}, @samp{?}, or @samp{]}. (Due to parsing constraints,
  4977. the characters @samp{-} and @samp{]} must either come @emph{first} or
  4978. @emph{last} in a character class.)
  4979. @cindex Excluding characters from a character class
  4980. @cindex Character class, excluding characters from
  4981. If the first character of the class after the opening @samp{[}
  4982. is @samp{!} or @samp{^}, then the meaning of the class is reversed.
  4983. Rather than listing character to match, it lists those characters which
  4984. are @emph{forbidden} as the next single character of the matched string.
  4985. Other characters of the class stand for themselves. The special
  4986. construction @samp{[@var{a}-@var{e}]}, using an hyphen between two
  4987. letters, is meant to represent all characters between @var{a} and
  4988. @var{e}, inclusive.
  4989. @FIXME{need to add a sentence or so here to make this clear for those
  4990. who don't have dan around.}
  4991. Periods (@samp{.}) or forward slashes (@samp{/}) are not considered
  4992. special for wildcard matches. However, if a pattern completely matches
  4993. a directory prefix of a matched string, then it matches the full matched
  4994. string: excluding a directory also excludes all the files beneath it.
  4995. @node after
  4996. @section Operating Only on New Files
  4997. @cindex Excluding file by age
  4998. @cindex Modification time, excluding files by
  4999. @cindex Age, excluding files by
  5000. @UNREVISED
  5001. The @value{op-after-date} option causes @command{tar} to only work on files
  5002. whose modification or inode-changed times are newer than the @var{date}
  5003. given. If @var{date} starts with @samp{/} or @samp{.}, it is taken to
  5004. be a file name; the last-modified time of that file is used as the date.
  5005. If you use this option when creating or appending to an archive,
  5006. the archive will only include new files. If you use @samp{--after-date}
  5007. when extracting an archive, @command{tar} will only extract files newer
  5008. than the @var{date} you specify.
  5009. If you only want @command{tar} to make the date comparison based on
  5010. modification of the actual contents of the file (rather than inode
  5011. changes), then use the @value{op-newer-mtime} option.
  5012. You may use these options with any operation. Note that these options
  5013. differ from the @value{op-update} operation in that they allow you to
  5014. specify a particular date against which @command{tar} can compare when
  5015. deciding whether or not to archive the files.
  5016. @table @kbd
  5017. @item --after-date=@var{date}
  5018. @itemx --newer=@var{date}
  5019. @itemx -N @var{date}
  5020. Only store files newer than @var{date}.
  5021. Acts on files only if their modification or inode-changed times are
  5022. later than @var{date}. Use in conjunction with any operation.
  5023. If @var{date} starts with @samp{/} or @samp{.}, it is taken to be a file
  5024. name; the last-modified time of that file is used as the date.
  5025. @item --newer-mtime=@var{date}
  5026. Acts like @value{op-after-date}, but only looks at modification times.
  5027. @end table
  5028. These options limit @command{tar} to only operating on files which have
  5029. been modified after the date specified. A file is considered to have
  5030. changed if the contents have been modified, or if the owner,
  5031. permissions, and so forth, have been changed. (For more information on
  5032. how to specify a date, see @ref{Date input formats}; remember that the
  5033. entire date argument must be quoted if it contains any spaces.)
  5034. Gurus would say that @value{op-after-date} tests both the @code{mtime}
  5035. (time the contents of the file were last modified) and @code{ctime}
  5036. (time the file's status was last changed: owner, permissions, etc)
  5037. fields, while @value{op-newer-mtime} tests only @code{mtime} field.
  5038. To be precise, @value{op-after-date} checks @emph{both} @code{mtime} and
  5039. @code{ctime} and processes the file if either one is more recent than
  5040. @var{date}, while @value{op-newer-mtime} only checks @code{mtime} and
  5041. disregards @code{ctime}. Neither uses @code{atime} (the last time the
  5042. contents of the file were looked at).
  5043. Date specifiers can have embedded spaces. Because of this, you may need
  5044. to quote date arguments to keep the shell from parsing them as separate
  5045. arguments.
  5046. @FIXME{Need example of --newer-mtime with quoted argument.}
  5047. @quotation
  5048. @strong{Please Note:} @value{op-after-date} and @value{op-newer-mtime}
  5049. should not be used for incremental backups. Some files (such as those
  5050. in renamed directories) are not selected properly by these options.
  5051. @xref{incremental and listed-incremental}.
  5052. @end quotation
  5053. @noindent
  5054. @FIXME{which tells -- need to fill this in!}
  5055. @node recurse
  5056. @section Descending into Directories
  5057. @cindex Avoiding recursion in directories
  5058. @cindex Descending directories, avoiding
  5059. @cindex Directories, avoiding recursion
  5060. @cindex Recursion in directories, avoiding
  5061. @UNREVISED
  5062. @FIXME{arrggh! this is still somewhat confusing to me. :-< }
  5063. @FIXME{show dan bob's comments, from 2-10-97}
  5064. Usually, @command{tar} will recursively explore all directories (either
  5065. those given on the command line or through the @value{op-files-from}
  5066. option) for the various files they contain. However, you may not always
  5067. want @command{tar} to act this way.
  5068. The @value{op-no-recursion} option inhibits @command{tar}'s recursive descent
  5069. into specified directories. If you specify @samp{--no-recursion}, you can
  5070. use the @command{find} utility for hunting through levels of directories to
  5071. construct a list of file names which you could then pass to @command{tar}.
  5072. @command{find} allows you to be more selective when choosing which files to
  5073. archive; see @ref{files} for more information on using @command{find} with
  5074. @command{tar}, or look.
  5075. @table @kbd
  5076. @item --no-recursion
  5077. Prevents @command{tar} from recursively descending directories.
  5078. @item --recursion
  5079. Requires @command{tar} to recursively descend directories.
  5080. This is the default.
  5081. @end table
  5082. When you use @samp{--no-recursion}, @GNUTAR{} grabs
  5083. directory entries themselves, but does not descend on them
  5084. recursively. Many people use @command{find} for locating files they
  5085. want to back up, and since @command{tar} @emph{usually} recursively
  5086. descends on directories, they have to use the @samp{@w{! -d}} option
  5087. to @command{find} @FIXME{needs more explanation or a cite to another
  5088. info file}as they usually do not want all the files in a directory.
  5089. They then use the @value{op-files-from} option to archive the files
  5090. located via @command{find}.
  5091. The problem when restoring files archived in this manner is that the
  5092. directories themselves are not in the archive; so the
  5093. @value{op-same-permissions} option does not affect them---while users
  5094. might really like it to. Specifying @value{op-no-recursion} is a way to
  5095. tell @command{tar} to grab only the directory entries given to it, adding
  5096. no new files on its own.
  5097. The @value{op-no-recursion} option also applies when extracting: it
  5098. causes @command{tar} to extract only the matched directory entries, not
  5099. the files under those directories.
  5100. The @value{op-no-recursion} option also affects how exclude patterns
  5101. are interpreted (@pxref{controlling pattern-patching with exclude}).
  5102. The @option{--no-recursion} and @option{--recursion} options apply to
  5103. later options and operands, and can be overridden by later occurrences
  5104. of @option{--no-recursion} and @option{--recursion}. For example:
  5105. @smallexample
  5106. $ @kbd{tar -cf jams.tar --norecursion grape --recursion grape/concord}
  5107. @end smallexample
  5108. @noindent
  5109. creates an archive with one entry for @file{grape}, and the recursive
  5110. contents of @file{grape/concord}, but no entries under @file{grape}
  5111. other than @file{grape/concord}.
  5112. @node one
  5113. @section Crossing Filesystem Boundaries
  5114. @cindex File system boundaries, not crossing
  5115. @UNREVISED
  5116. @command{tar} will normally automatically cross file system boundaries in
  5117. order to archive files which are part of a directory tree. You can
  5118. change this behavior by running @command{tar} and specifying
  5119. @value{op-one-file-system}. This option only affects files that are
  5120. archived because they are in a directory that is being archived;
  5121. @command{tar} will still archive files explicitly named on the command line
  5122. or through @value{op-files-from}, regardless of where they reside.
  5123. @table @kbd
  5124. @item --one-file-system
  5125. @itemx -l
  5126. Prevents @command{tar} from crossing file system boundaries when
  5127. archiving. Use in conjunction with any write operation.
  5128. @end table
  5129. The @samp{--one-file-system} option causes @command{tar} to modify its
  5130. normal behavior in archiving the contents of directories. If a file in
  5131. a directory is not on the same filesystem as the directory itself, then
  5132. @command{tar} will not archive that file. If the file is a directory
  5133. itself, @command{tar} will not archive anything beneath it; in other words,
  5134. @command{tar} will not cross mount points.
  5135. It is reported that using this option, the mount point is is archived,
  5136. but nothing under it.
  5137. This option is useful for making full or incremental archival backups of
  5138. a file system. If this option is used in conjunction with
  5139. @value{op-verbose}, files that are excluded are mentioned by name on the
  5140. standard error.
  5141. @menu
  5142. * directory:: Changing Directory
  5143. * absolute:: Absolute File Names
  5144. @end menu
  5145. @node directory
  5146. @subsection Changing the Working Directory
  5147. @FIXME{need to read over this node now for continuity; i've switched
  5148. things around some.}
  5149. @cindex Changing directory mid-stream
  5150. @cindex Directory, changing mid-stream
  5151. @cindex Working directory, specifying
  5152. @UNREVISED
  5153. To change the working directory in the middle of a list of file names,
  5154. either on the command line or in a file specified using
  5155. @value{op-files-from}, use @value{op-directory}. This will change the
  5156. working directory to the directory @var{directory} after that point in
  5157. the list.
  5158. @table @kbd
  5159. @item --directory=@var{directory}
  5160. @itemx -C @var{directory}
  5161. Changes the working directory in the middle of a command line.
  5162. @end table
  5163. For example,
  5164. @smallexample
  5165. $ @kbd{tar -c -f jams.tar grape prune -C food cherry}
  5166. @end smallexample
  5167. @noindent
  5168. will place the files @file{grape} and @file{prune} from the current
  5169. directory into the archive @file{jams.tar}, followed by the file
  5170. @file{cherry} from the directory @file{food}. This option is especially
  5171. useful when you have several widely separated files that you want to
  5172. store in the same archive.
  5173. Note that the file @file{cherry} is recorded in the archive under the
  5174. precise name @file{cherry}, @emph{not} @file{food/cherry}. Thus, the
  5175. archive will contain three files that all appear to have come from the
  5176. same directory; if the archive is extracted with plain @samp{tar
  5177. --extract}, all three files will be written in the current directory.
  5178. Contrast this with the command,
  5179. @smallexample
  5180. $ @kbd{tar -c -f jams.tar grape prune -C food red/cherry}
  5181. @end smallexample
  5182. @noindent
  5183. which records the third file in the archive under the name
  5184. @file{red/cherry} so that, if the archive is extracted using
  5185. @samp{tar --extract}, the third file will be written in a subdirectory
  5186. named @file{orange-colored}.
  5187. You can use the @samp{--directory} option to make the archive
  5188. independent of the original name of the directory holding the files.
  5189. The following command places the files @file{/etc/passwd},
  5190. @file{/etc/hosts}, and @file{/lib/libc.a} into the archive
  5191. @file{foo.tar}:
  5192. @smallexample
  5193. $ @kbd{tar -c -f foo.tar -C /etc passwd hosts -C /lib libc.a}
  5194. @end smallexample
  5195. @noindent
  5196. However, the names of the archive members will be exactly what they were
  5197. on the command line: @file{passwd}, @file{hosts}, and @file{libc.a}.
  5198. They will not appear to be related by file name to the original
  5199. directories where those files were located.
  5200. Note that @samp{--directory} options are interpreted consecutively. If
  5201. @samp{--directory} specifies a relative file name, it is interpreted
  5202. relative to the then current directory, which might not be the same as
  5203. the original current working directory of @command{tar}, due to a previous
  5204. @samp{--directory} option.
  5205. When using @samp{--files-from} (@pxref{files}), you can put @samp{-C}
  5206. options in the file list. Notice, however, that in this case the
  5207. option and its argument must occupy two consecutive lines. For
  5208. instance, the file list for the above example will be:
  5209. @smallexample
  5210. @group
  5211. -C
  5212. /etc
  5213. passwd
  5214. hosts
  5215. -C
  5216. /lib
  5217. libc.a
  5218. @end group
  5219. @end smallexample
  5220. @noindent
  5221. To use it, you would invoke @command{tar} as follows:
  5222. @smallexample
  5223. $ @kbd{tar -c -f foo.tar --files-from list}
  5224. @end smallexample
  5225. Notice also that you can only use the short option variant in the file
  5226. list, i.e. always use @option{-C}, not @option{--directory}.
  5227. The interpretation of @value{op-directory} is disabled by
  5228. @value{op-null} option.
  5229. @node absolute
  5230. @subsection Absolute File Names
  5231. @UNREVISED
  5232. @table @kbd
  5233. @item -P
  5234. @itemx --absolute-names
  5235. Do not strip leading slashes from file names, and permit file names
  5236. containing a @file{..} file name component.
  5237. @end table
  5238. By default, @GNUTAR{} drops a leading @samp{/} on
  5239. input or output, and complains about file names containing a @file{..}
  5240. component. This option turns off this behavior.
  5241. When @command{tar} extracts archive members from an archive, it strips any
  5242. leading slashes (@samp{/}) from the member name. This causes absolute
  5243. member names in the archive to be treated as relative file names. This
  5244. allows you to have such members extracted wherever you want, instead of
  5245. being restricted to extracting the member in the exact directory named
  5246. in the archive. For example, if the archive member has the name
  5247. @file{/etc/passwd}, @command{tar} will extract it as if the name were
  5248. really @file{etc/passwd}.
  5249. File names containing @file{..} can cause problems when extracting, so
  5250. @command{tar} normally warns you about such files when creating an
  5251. archive, and rejects attempts to extracts such files.
  5252. Other @command{tar} programs do not do this. As a result, if you
  5253. create an archive whose member names start with a slash, they will be
  5254. difficult for other people with a non-@GNUTAR{}
  5255. program to use. Therefore, @GNUTAR{} also strips
  5256. leading slashes from member names when putting members into the
  5257. archive. For example, if you ask @command{tar} to add the file
  5258. @file{/bin/ls} to an archive, it will do so, but the member name will
  5259. be @file{bin/ls}.
  5260. If you use the @value{op-absolute-names} option, @command{tar} will do
  5261. none of these transformations.
  5262. To archive or extract files relative to the root directory, specify
  5263. the @value{op-absolute-names} option.
  5264. Normally, @command{tar} acts on files relative to the working
  5265. directory---ignoring superior directory names when archiving, and
  5266. ignoring leading slashes when extracting.
  5267. When you specify @value{op-absolute-names}, @command{tar} stores file names
  5268. including all superior directory names, and preserves leading slashes.
  5269. If you only invoked @command{tar} from the root directory you would never
  5270. need the @value{op-absolute-names} option, but using this option may be
  5271. more convenient than switching to root.
  5272. @FIXME{Should be an example in the tutorial/wizardry section using this
  5273. to transfer files between systems.}
  5274. @FIXME{Is write access an issue?}
  5275. @table @kbd
  5276. @item --absolute-names
  5277. Preserves full file names (including superior directory names) when
  5278. archiving files. Preserves leading slash when extracting files.
  5279. @end table
  5280. @FIXME{this is still horrible; need to talk with dan on monday.}
  5281. @command{tar} prints out a message about removing the @samp{/} from
  5282. file names. This message appears once per @GNUTAR{}
  5283. invocation. It represents something which ought to be told; ignoring
  5284. what it means can cause very serious surprises, later.
  5285. Some people, nevertheless, do not want to see this message. Wanting to
  5286. play really dangerously, one may of course redirect @command{tar} standard
  5287. error to the sink. For example, under @command{sh}:
  5288. @smallexample
  5289. $ @kbd{tar -c -f archive.tar /home 2> /dev/null}
  5290. @end smallexample
  5291. @noindent
  5292. Another solution, both nicer and simpler, would be to change to
  5293. the @file{/} directory first, and then avoid absolute notation.
  5294. For example:
  5295. @smallexample
  5296. $ @kbd{(cd / && tar -c -f archive.tar home)}
  5297. $ @kbd{tar -c -f archive.tar -C / home}
  5298. @end smallexample
  5299. @include getdate.texi
  5300. @node Formats
  5301. @chapter Controlling the Archive Format
  5302. Due to historical reasons, there are several formats of tar archives.
  5303. All of them are based on the same principles, but have some subtle
  5304. differences that often make them incompatible with each other.
  5305. GNU tar is able to create and handle archives in a variety of formats.
  5306. The most frequently used formats are (in alphabetical order):
  5307. @table @asis
  5308. @item gnu
  5309. Format used by @GNUTAR{} versions up to 1.13.25. This format derived
  5310. from an early @acronym{POSIX} standard, adding some improvements such as
  5311. sparse file handling and incremental archives. Unfortunately these
  5312. features were implemented in a way incompatible with other archive
  5313. formats.
  5314. Archives in @samp{gnu} format are able to hold pathnames of unlimited
  5315. length.
  5316. @item oldgnu
  5317. Format used by @GNUTAR{} of versions prior to 1.12.
  5318. @item v7
  5319. Archive format, compatible with the V7 implementation of tar. This
  5320. format imposes a number of limitations. The most important of them
  5321. are:
  5322. @enumerate
  5323. @item The maximum length of a file name is limited to 99 characters.
  5324. @item The maximum length of a symbolic link is limited to 99 characters.
  5325. @item It is impossible to store special files (block and character
  5326. devices, fifos etc.)
  5327. @item Maximum value of user or group ID is limited to 2097151 (7777777
  5328. octal)
  5329. @item V7 archives do not contain symbolic ownership information (user
  5330. and group name of the file owner).
  5331. @end enumerate
  5332. This format has traditionally been used by Automake when producing
  5333. Makefiles. This practice will change in the future, in the meantime,
  5334. however this means that projects containing filenames more than 99
  5335. characters long will not be able to use @GNUTAR{} @value{VERSION} and
  5336. Automake prior to 1.9.
  5337. @item ustar
  5338. Archive format defined by @acronym{POSIX.1-1988} specification. It stores
  5339. symbolic ownership information. It is also able to store
  5340. special files. However, it imposes several restrictions as well:
  5341. @enumerate
  5342. @item The maximum length of a file name is limited to 256 characters,
  5343. provided that the filename can be split at directory separator in
  5344. two parts, first of them being at most 155 bytes long. So, in most
  5345. cases the maximum file name length will be shorter than 256
  5346. characters.
  5347. @item The maximum length of a symbolic link name is limited to
  5348. 100 characters.
  5349. @item Maximum size of a file the archive is able to accomodate
  5350. is 8GB
  5351. @item Maximum value of UID/GID is 2097151.
  5352. @item Maximum number of bits in device major and minor numbers is 21.
  5353. @end enumerate
  5354. @item star
  5355. Format used by J@"org Schilling @command{star}
  5356. implementation. @GNUTAR{} is able to read @samp{star} archives but
  5357. currently does not produce them.
  5358. @item posix
  5359. Archive format defined by @acronym{POSIX.1-2001} specification. This is the
  5360. most flexible and feature-rich format. It does not impose any
  5361. restrictions on file sizes or filename lengths. This format is quite
  5362. recent, so not all tar implementations are able to handle it properly.
  5363. However, this format is designed in such a way that any tar
  5364. implementation able to read @samp{ustar} archives will be able to read
  5365. most @samp{posix} archives as well, with the only exception that any
  5366. additional information (such as long file names etc.) will in such
  5367. case be extracted as plain text files along with the files it refers to.
  5368. This archive format will be the default format for future versions
  5369. of @GNUTAR{}.
  5370. @end table
  5371. The following table summarizes the limitations of each of these
  5372. formats:
  5373. @multitable @columnfractions .10 .20 .20 .20 .20
  5374. @item Format @tab UID @tab File Size @tab Path Name @tab Devn
  5375. @item gnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
  5376. @item oldgnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
  5377. @item v7 @tab 2097151 @tab 8GB @tab 99 @tab n/a
  5378. @item ustar @tab 2097151 @tab 8GB @tab 256 @tab 21
  5379. @item posix @tab Unlimited @tab Unlimited @tab Unlimited @tab Unlimited
  5380. @end multitable
  5381. The default format for @GNUTAR{} is defined at compilation
  5382. time. You may check it by running @command{tar --help}, and examining
  5383. the last lines of its output. Usually, @GNUTAR{} is configured
  5384. to create archives in @samp{gnu} format, however, future version will
  5385. switch to @samp{posix}.
  5386. @menu
  5387. * Portability:: Making @command{tar} Archives More Portable
  5388. * Compression:: Using Less Space through Compression
  5389. * Attributes:: Handling File Attributes
  5390. * Standard:: The Standard Format
  5391. * Extensions:: @acronym{GNU} Extensions to the Archive Format
  5392. * cpio:: Comparison of @command{tar} and @command{cpio}
  5393. @end menu
  5394. @node Portability
  5395. @section Making @command{tar} Archives More Portable
  5396. Creating a @command{tar} archive on a particular system that is meant to be
  5397. useful later on many other machines and with other versions of @command{tar}
  5398. is more challenging than you might think. @command{tar} archive formats
  5399. have been evolving since the first versions of Unix. Many such formats
  5400. are around, and are not always compatible with each other. This section
  5401. discusses a few problems, and gives some advice about making @command{tar}
  5402. archives more portable.
  5403. One golden rule is simplicity. For example, limit your @command{tar}
  5404. archives to contain only regular files and directories, avoiding
  5405. other kind of special files. Do not attempt to save sparse files or
  5406. contiguous files as such. Let's discuss a few more problems, in turn.
  5407. @menu
  5408. * Portable Names:: Portable Names
  5409. * dereference:: Symbolic Links
  5410. * old:: Old V7 Archives
  5411. * ustar:: Ustar Archives
  5412. * gnu:: GNU and old GNU format archives.
  5413. * posix:: @acronym{POSIX} archives
  5414. * Checksumming:: Checksumming Problems
  5415. * Large or Negative Values:: Large files, negative time stamps, etc.
  5416. @end menu
  5417. @node Portable Names
  5418. @subsection Portable Names
  5419. Use portable file and member names. A name is portable if it contains
  5420. only ASCII letters and digits, @samp{/}, @samp{.}, @samp{_}, and
  5421. @samp{-}; it cannot be empty, start with @samp{-} or @samp{//}, or
  5422. contain @samp{/-}. Avoid deep directory nesting. For portability to
  5423. old Unix hosts, limit your file name components to 14 characters or
  5424. less.
  5425. If you intend to have your @command{tar} archives to be read under
  5426. MSDOS, you should not rely on case distinction for file names, and you
  5427. might use the @acronym{GNU} @command{doschk} program for helping you
  5428. further diagnosing illegal MSDOS names, which are even more limited
  5429. than System V's.
  5430. @node dereference
  5431. @subsection Symbolic Links
  5432. @cindex File names, using symbolic links
  5433. @cindex Symbolic link as file name
  5434. Normally, when @command{tar} archives a symbolic link, it writes a
  5435. block to the archive naming the target of the link. In that way, the
  5436. @command{tar} archive is a faithful record of the filesystem contents.
  5437. @value{op-dereference} is used with @value{op-create}, and causes
  5438. @command{tar} to archive the files symbolic links point to, instead of
  5439. the links themselves. When this option is used, when @command{tar}
  5440. encounters a symbolic link, it will archive the linked-to file,
  5441. instead of simply recording the presence of a symbolic link.
  5442. The name under which the file is stored in the file system is not
  5443. recorded in the archive. To record both the symbolic link name and
  5444. the file name in the system, archive the file under both names. If
  5445. all links were recorded automatically by @command{tar}, an extracted file
  5446. might be linked to a file name that no longer exists in the file
  5447. system.
  5448. If a linked-to file is encountered again by @command{tar} while creating
  5449. the same archive, an entire second copy of it will be stored. (This
  5450. @emph{might} be considered a bug.)
  5451. So, for portable archives, do not archive symbolic links as such,
  5452. and use @value{op-dereference}: many systems do not support
  5453. symbolic links, and moreover, your distribution might be unusable if
  5454. it contains unresolved symbolic links.
  5455. @node old
  5456. @subsection Old V7 Archives
  5457. @cindex Format, old style
  5458. @cindex Old style format
  5459. @cindex Old style archives
  5460. Certain old versions of @command{tar} cannot handle additional
  5461. information recorded by newer @command{tar} programs. To create an
  5462. archive in V7 format (not ANSI), which can be read by these old
  5463. versions, specify the @value{op-format-v7} option in
  5464. conjunction with the @value{op-create} (@command{tar} also
  5465. accepts @samp{--portability} or @samp{op-old-archive} for this
  5466. option). When you specify it,
  5467. @command{tar} leaves out information about directories, pipes, fifos,
  5468. contiguous files, and device files, and specifies file ownership by
  5469. group and user IDs instead of group and user names.
  5470. When updating an archive, do not use @value{op-format-v7}
  5471. unless the archive was created using this option.
  5472. In most cases, a @emph{new} format archive can be read by an @emph{old}
  5473. @command{tar} program without serious trouble, so this option should
  5474. seldom be needed. On the other hand, most modern @command{tar}s are
  5475. able to read old format archives, so it might be safer for you to
  5476. always use @value{op-format-v7} for your distributions.
  5477. @node ustar
  5478. @subsection Ustar Archive Format
  5479. Archive format defined by @acronym{POSIX}.1-1988 specification is called
  5480. @code{ustar}. Although it is more flexible than the V7 format, it
  5481. still has many restrictions (@xref{Formats,ustar}, for the detailed
  5482. description of @code{ustar} format). Along with V7 format,
  5483. @code{ustar} format is a good choice for archives intended to be read
  5484. with other implementations of @command{tar}.
  5485. To create archive in @code{ustar} format, use @value{op-format-ustar}
  5486. option in conjunction with the @value{op-create}.
  5487. @node gnu
  5488. @subsection @acronym{GNU} and old @GNUTAR{} format
  5489. @GNUTAR{} was based on an early draft of the
  5490. @acronym{POSIX} 1003.1 @code{ustar} standard. @acronym{GNU} extensions to
  5491. @command{tar}, such as the support for file names longer than 100
  5492. characters, use portions of the @command{tar} header record which were
  5493. specified in that @acronym{POSIX} draft as unused. Subsequent changes in
  5494. @acronym{POSIX} have allocated the same parts of the header record for
  5495. other purposes. As a result, @GNUTAR{} format is
  5496. incompatible with the current @acronym{POSIX} specification, and with
  5497. @command{tar} programs that follow it.
  5498. In the majority of cases, @command{tar} will be configured to create
  5499. this format by default. This will change in the future releases, since
  5500. we plan to make @samp{posix} format the default.
  5501. To force creation a @GNUTAR{} archive, use option
  5502. @value{op-format-gnu}.
  5503. Some @command{tar} options are currently basing on @GNUTAR{}
  5504. format, and can therefore be used only with @samp{gnu}
  5505. or @samp{oldgnu} archive formats. The list of such options follows:
  5506. @itemize @bullet
  5507. @item @value{op-label}, when used with @value{op-create}.
  5508. @item @value{op-incremental}
  5509. @item @value{op-multi-volume}
  5510. @end itemize
  5511. These options will be re-implemented for the @samp{posix} archive
  5512. format in the future.
  5513. @node posix
  5514. @subsection @GNUTAR{} and @acronym{POSIX} @command{tar}
  5515. The version @value{VERSION} of @GNUTAR{} is able
  5516. to read and create archives conforming to @acronym{POSIX.1-2001} standard.
  5517. A @acronym{POSIX} conformant archive will be created if @command{tar}
  5518. was given @value{op-format-posix} option.
  5519. Notice, that currently @acronym{GNU} extensions are not
  5520. allowed with this format. Following is the list of options that
  5521. cannot be used with @value{op-format-posix}:
  5522. @itemize @bullet
  5523. @item @value{op-label}, when used with @value{op-create}.
  5524. @item @value{op-incremental}
  5525. @item @value{op-multi-volume}
  5526. @end itemize
  5527. This restriction will disappear in the future versions.
  5528. @node Checksumming
  5529. @subsection Checksumming Problems
  5530. SunOS and HP-UX @command{tar} fail to accept archives created using
  5531. @GNUTAR{} and containing non-ASCII file names, that
  5532. is, file names having characters with the eight bit set, because they
  5533. use signed checksums, while @GNUTAR{} uses unsigned
  5534. checksums while creating archives, as per @acronym{POSIX} standards. On
  5535. reading, @GNUTAR{} computes both checksums and
  5536. accept any. It is somewhat worrying that a lot of people may go
  5537. around doing backup of their files using faulty (or at least
  5538. non-standard) software, not learning about it until it's time to
  5539. restore their missing files with an incompatible file extractor, or
  5540. vice versa.
  5541. @GNUTAR{} compute checksums both ways, and accept
  5542. any on read, so @acronym{GNU} tar can read Sun tapes even with their
  5543. wrong checksums. @GNUTAR{} produces the standard
  5544. checksum, however, raising incompatibilities with Sun. That is to
  5545. say, @GNUTAR{} has not been modified to
  5546. @emph{produce} incorrect archives to be read by buggy @command{tar}'s.
  5547. I've been told that more recent Sun @command{tar} now read standard
  5548. archives, so maybe Sun did a similar patch, after all?
  5549. The story seems to be that when Sun first imported @command{tar}
  5550. sources on their system, they recompiled it without realizing that
  5551. the checksums were computed differently, because of a change in
  5552. the default signing of @code{char}'s in their compiler. So they
  5553. started computing checksums wrongly. When they later realized their
  5554. mistake, they merely decided to stay compatible with it, and with
  5555. themselves afterwards. Presumably, but I do not really know, HP-UX
  5556. has chosen that their @command{tar} archives to be compatible with Sun's.
  5557. The current standards do not favor Sun @command{tar} format. In any
  5558. case, it now falls on the shoulders of SunOS and HP-UX users to get
  5559. a @command{tar} able to read the good archives they receive.
  5560. @node Large or Negative Values
  5561. @subsection Large or Negative Values
  5562. @cindex large values
  5563. @cindex future time stamps
  5564. @cindex negative time stamps
  5565. @acronym{POSIX} @command{tar} format uses fixed-sized unsigned octal strings
  5566. to represent numeric values. User and group IDs and device major and
  5567. minor numbers have unsigned 21-bit representations, and file sizes and
  5568. times have unsigned 33-bit representations. @GNUTAR{}
  5569. generates @acronym{POSIX} representations when possible, but for values
  5570. outside the @acronym{POSIX} range it generates two's-complement base-256
  5571. strings: uids, gids, and device numbers have signed 57-bit
  5572. representations, and file sizes and times have signed 89-bit
  5573. representations. These representations are an extension to @acronym{POSIX}
  5574. @command{tar} format, so they are not universally portable.
  5575. The most common portability problems with out-of-range numeric values
  5576. are large files and future or negative time stamps.
  5577. Portable archives should avoid members of 8 GB or larger, as @acronym{POSIX}
  5578. @command{tar} format cannot represent them.
  5579. Portable archives should avoid time stamps from the future. @acronym{POSIX}
  5580. @command{tar} format can represent time stamps in the range 1970-01-01
  5581. 00:00:00 through 2242-03-16 12:56:31 @sc{utc}. However, many current
  5582. hosts use a signed 32-bit @code{time_t}, or internal time stamp format,
  5583. and cannot represent time stamps after 2038-01-19 03:14:07 @sc{utc}; so
  5584. portable archives must avoid these time stamps for many years to come.
  5585. Portable archives should also avoid time stamps before 1970. These time
  5586. stamps are a common @acronym{POSIX} extension but their @code{time_t}
  5587. representations are negative. Many traditional @command{tar}
  5588. implementations generate a two's complement representation for negative
  5589. time stamps that assumes a signed 32-bit @code{time_t}; hence they
  5590. generate archives that are not portable to hosts with differing
  5591. @code{time_t} representations. @GNUTAR{} recognizes this
  5592. situation when it is run on host with a signed 32-bit @code{time_t}, but
  5593. it issues a warning, as these time stamps are nonstandard and unportable.
  5594. @node Compression
  5595. @section Using Less Space through Compression
  5596. @menu
  5597. * gzip:: Creating and Reading Compressed Archives
  5598. * sparse:: Archiving Sparse Files
  5599. @end menu
  5600. @node gzip
  5601. @subsection Creating and Reading Compressed Archives
  5602. @cindex Compressed archives
  5603. @cindex Storing archives in compressed format
  5604. @UNREVISED
  5605. @table @kbd
  5606. @item -z
  5607. @itemx --gzip
  5608. @itemx --ungzip
  5609. Filter the archive through @command{gzip}.
  5610. @end table
  5611. @FIXME{ach; these two bits orig from "compare" (?). where to put?} Some
  5612. format parameters must be taken into consideration when modifying an
  5613. archive.@FIXME{???} Compressed archives cannot be modified.
  5614. You can use @samp{--gzip} and @samp{--gunzip} on physical devices
  5615. (tape drives, etc.) and remote files as well as on normal files; data
  5616. to or from such devices or remote files is reblocked by another copy
  5617. of the @command{tar} program to enforce the specified (or default) record
  5618. size. The default compression parameters are used; if you need to
  5619. override them, avoid the @value{op-gzip} option and run @command{gzip}
  5620. explicitly. (Or set the @env{GZIP} environment variable.)
  5621. The @value{op-gzip} option does not work with the @value{op-multi-volume}
  5622. option, or with the @value{op-update}, @value{op-append},
  5623. @value{op-concatenate}, or @value{op-delete} operations.
  5624. It is not exact to say that @GNUTAR{} is to work in concert
  5625. with @command{gzip} in a way similar to @command{zip}, say. Surely, it is
  5626. possible that @command{tar} and @command{gzip} be done with a single call,
  5627. like in:
  5628. @smallexample
  5629. $ @kbd{tar cfz archive.tar.gz subdir}
  5630. @end smallexample
  5631. @noindent
  5632. to save all of @samp{subdir} into a @code{gzip}'ed archive. Later you
  5633. can do:
  5634. @smallexample
  5635. $ @kbd{tar xfz archive.tar.gz}
  5636. @end smallexample
  5637. @noindent
  5638. to explode and unpack.
  5639. The difference is that the whole archive is compressed. With
  5640. @command{zip}, archive members are archived individually. @command{tar}'s
  5641. method yields better compression. On the other hand, one can view the
  5642. contents of a @command{zip} archive without having to decompress it. As
  5643. for the @command{tar} and @command{gzip} tandem, you need to decompress the
  5644. archive to see its contents. However, this may be done without needing
  5645. disk space, by using pipes internally:
  5646. @smallexample
  5647. $ @kbd{tar tfz archive.tar.gz}
  5648. @end smallexample
  5649. @cindex corrupted archives
  5650. About corrupted compressed archives: @command{gzip}'ed files have no
  5651. redundancy, for maximum compression. The adaptive nature of the
  5652. compression scheme means that the compression tables are implicitly
  5653. spread all over the archive. If you lose a few blocks, the dynamic
  5654. construction of the compression tables becomes unsynchronized, and there
  5655. is little chance that you could recover later in the archive.
  5656. There are pending suggestions for having a per-volume or per-file
  5657. compression in @GNUTAR{}. This would allow for viewing the
  5658. contents without decompression, and for resynchronizing decompression at
  5659. every volume or file, in case of corrupted archives. Doing so, we might
  5660. lose some compressibility. But this would have make recovering easier.
  5661. So, there are pros and cons. We'll see!
  5662. @table @kbd
  5663. @item -j
  5664. @itemx --bzip2
  5665. Filter the archive through @code{bzip2}. Otherwise like @value{op-gzip}.
  5666. @item -Z
  5667. @itemx --compress
  5668. @itemx --uncompress
  5669. Filter the archive through @command{compress}. Otherwise like
  5670. @value{op-gzip}.
  5671. @item --use-compress-program=@var{prog}
  5672. Filter through @var{prog} (must accept @samp{-d}).
  5673. @end table
  5674. @value{op-compress} stores an archive in compressed format. This
  5675. option is useful in saving time over networks and space in pipes, and
  5676. when storage space is at a premium. @value{op-compress} causes
  5677. @command{tar} to compress when writing the archive, or to uncompress when
  5678. reading the archive.
  5679. To perform compression and uncompression on the archive, @command{tar}
  5680. runs the @command{compress} utility. @command{tar} uses the default
  5681. compression parameters; if you need to override them, avoid the
  5682. @value{op-compress} option and run the @command{compress} utility
  5683. explicitly. It is useful to be able to call the @command{compress}
  5684. utility from within @command{tar} because the @command{compress} utility by
  5685. itself cannot access remote tape drives.
  5686. The @value{op-compress} option will not work in conjunction with the
  5687. @value{op-multi-volume} option or the @value{op-append}, @value{op-update}
  5688. and @value{op-delete} operations. @xref{Operations}, for
  5689. more information on these operations.
  5690. If there is no compress utility available, @command{tar} will report an error.
  5691. @strong{Please note} that the @command{compress} program may be covered by
  5692. a patent, and therefore we recommend you stop using it.
  5693. @value{op-bzip2} acts like @value{op-compress}, except that it uses
  5694. the @code{bzip2} utility.
  5695. @table @kbd
  5696. @item --compress
  5697. @itemx --uncompress
  5698. @itemx -z
  5699. @itemx -Z
  5700. When this option is specified, @command{tar} will compress (when
  5701. writing an archive), or uncompress (when reading an archive). Used in
  5702. conjunction with the @value{op-create}, @value{op-extract},
  5703. @value{op-list} and @value{op-compare} operations.
  5704. @end table
  5705. You can have archives be compressed by using the @value{op-gzip} option.
  5706. This will arrange for @command{tar} to use the @command{gzip} program to be
  5707. used to compress or uncompress the archive wren writing or reading it.
  5708. To use the older, obsolete, @command{compress} program, use the
  5709. @value{op-compress} option. The @acronym{GNU} Project recommends you not use
  5710. @command{compress}, because there is a patent covering the algorithm it
  5711. uses. You could be sued for patent infringement merely by running
  5712. @command{compress}.
  5713. @FIXME{I have one question, or maybe it's a suggestion if there isn't a way
  5714. to do it now. I would like to use @value{op-gzip}, but I'd also like
  5715. the output to be fed through a program like @acronym{GNU}
  5716. @command{ecc} (actually, right now that's @samp{exactly} what I'd like
  5717. to use :-)), basically adding ECC protection on top of compression.
  5718. It seems as if this should be quite easy to do, but I can't work out
  5719. exactly how to go about it. Of course, I can pipe the standard output
  5720. of @command{tar} through @command{ecc}, but then I lose (though I
  5721. haven't started using it yet, I confess) the ability to have
  5722. @command{tar} use @command{rmt} for it's I/O (I think).
  5723. I think the most straightforward thing would be to let me specify a
  5724. general set of filters outboard of compression (preferably ordered,
  5725. so the order can be automatically reversed on input operations, and
  5726. with the options they require specifiable), but beggars shouldn't be
  5727. choosers and anything you decide on would be fine with me.
  5728. By the way, I like @command{ecc} but if (as the comments say) it can't
  5729. deal with loss of block sync, I'm tempted to throw some time at adding
  5730. that capability. Supposing I were to actually do such a thing and
  5731. get it (apparently) working, do you accept contributed changes to
  5732. utilities like that? (Leigh Clayton @file{loc@@soliton.com}, May 1995).
  5733. Isn't that exactly the role of the @value{op-use-compress-prog} option?
  5734. I never tried it myself, but I suspect you may want to write a
  5735. @var{prog} script or program able to filter stdin to stdout to
  5736. way you want. It should recognize the @samp{-d} option, for when
  5737. extraction is needed rather than creation.
  5738. It has been reported that if one writes compressed data (through the
  5739. @value{op-gzip} or @value{op-compress} options) to a DLT and tries to use
  5740. the DLT compression mode, the data will actually get bigger and one will
  5741. end up with less space on the tape.}
  5742. @node sparse
  5743. @subsection Archiving Sparse Files
  5744. @cindex Sparse Files
  5745. @UNREVISED
  5746. @table @kbd
  5747. @item -S
  5748. @itemx --sparse
  5749. Handle sparse files efficiently.
  5750. @end table
  5751. This option causes all files to be put in the archive to be tested for
  5752. sparseness, and handled specially if they are. The @value{op-sparse}
  5753. option is useful when many @code{dbm} files, for example, are being
  5754. backed up. Using this option dramatically decreases the amount of
  5755. space needed to store such a file.
  5756. In later versions, this option may be removed, and the testing and
  5757. treatment of sparse files may be done automatically with any special
  5758. @acronym{GNU} options. For now, it is an option needing to be specified on
  5759. the command line with the creation or updating of an archive.
  5760. Files in the filesystem occasionally have ``holes.'' A hole in a file
  5761. is a section of the file's contents which was never written. The
  5762. contents of a hole read as all zeros. On many operating systems,
  5763. actual disk storage is not allocated for holes, but they are counted
  5764. in the length of the file. If you archive such a file, @command{tar}
  5765. could create an archive longer than the original. To have @command{tar}
  5766. attempt to recognize the holes in a file, use @value{op-sparse}. When
  5767. you use the @value{op-sparse} option, then, for any file using less
  5768. disk space than would be expected from its length, @command{tar} searches
  5769. the file for consecutive stretches of zeros. It then records in the
  5770. archive for the file where the consecutive stretches of zeros are, and
  5771. only archives the ``real contents'' of the file. On extraction (using
  5772. @value{op-sparse} is not needed on extraction) any such files have
  5773. holes created wherever the continuous stretches of zeros were found.
  5774. Thus, if you use @value{op-sparse}, @command{tar} archives won't take
  5775. more space than the original.
  5776. A file is sparse if it contains blocks of zeros whose existence is
  5777. recorded, but that have no space allocated on disk. When you specify
  5778. the @value{op-sparse} option in conjunction with the @value{op-create}
  5779. operation, @command{tar} tests all files for sparseness while archiving.
  5780. If @command{tar} finds a file to be sparse, it uses a sparse representation of
  5781. the file in the archive. @value{xref-create}, for more information
  5782. about creating archives.
  5783. @value{op-sparse} is useful when archiving files, such as dbm files,
  5784. likely to contain many nulls. This option dramatically
  5785. decreases the amount of space needed to store such an archive.
  5786. @quotation
  5787. @strong{Please Note:} Always use @value{op-sparse} when performing file
  5788. system backups, to avoid archiving the expanded forms of files stored
  5789. sparsely in the system.
  5790. Even if your system has no sparse files currently, some may be
  5791. created in the future. If you use @value{op-sparse} while making file
  5792. system backups as a matter of course, you can be assured the archive
  5793. will never take more space on the media than the files take on disk
  5794. (otherwise, archiving a disk filled with sparse files might take
  5795. hundreds of tapes). @FIXME-xref{incremental when node name is set.}
  5796. @end quotation
  5797. @command{tar} ignores the @value{op-sparse} option when reading an archive.
  5798. @table @kbd
  5799. @item --sparse
  5800. @itemx -S
  5801. Files stored sparsely in the file system are represented sparsely in
  5802. the archive. Use in conjunction with write operations.
  5803. @end table
  5804. However, users should be well aware that at archive creation time,
  5805. @GNUTAR{} still has to read whole disk file to
  5806. locate the @dfn{holes}, and so, even if sparse files use little space
  5807. on disk and in the archive, they may sometimes require inordinate
  5808. amount of time for reading and examining all-zero blocks of a file.
  5809. Although it works, it's painfully slow for a large (sparse) file, even
  5810. though the resulting tar archive may be small. (One user reports that
  5811. dumping a @file{core} file of over 400 megabytes, but with only about
  5812. 3 megabytes of actual data, took about 9 minutes on a Sun Sparcstation
  5813. ELC, with full CPU utilization.)
  5814. This reading is required in all cases and is not related to the fact
  5815. the @value{op-sparse} option is used or not, so by merely @emph{not}
  5816. using the option, you are not saving time@footnote{Well! We should say
  5817. the whole truth, here. When @value{op-sparse} is selected while creating
  5818. an archive, the current @command{tar} algorithm requires sparse files to be
  5819. read twice, not once. We hope to develop a new archive format for saving
  5820. sparse files in which one pass will be sufficient.}.
  5821. Programs like @command{dump} do not have to read the entire file; by
  5822. examining the file system directly, they can determine in advance
  5823. exactly where the holes are and thus avoid reading through them. The
  5824. only data it need read are the actual allocated data blocks.
  5825. @GNUTAR{} uses a more portable and straightforward
  5826. archiving approach, it would be fairly difficult that it does
  5827. otherwise. Elizabeth Zwicky writes to @file{comp.unix.internals}, on
  5828. 1990-12-10:
  5829. @quotation
  5830. What I did say is that you cannot tell the difference between a hole and an
  5831. equivalent number of nulls without reading raw blocks. @code{st_blocks} at
  5832. best tells you how many holes there are; it doesn't tell you @emph{where}.
  5833. Just as programs may, conceivably, care what @code{st_blocks} is (care
  5834. to name one that does?), they may also care where the holes are (I have
  5835. no examples of this one either, but it's equally imaginable).
  5836. I conclude from this that good archivers are not portable. One can
  5837. arguably conclude that if you want a portable program, you can in good
  5838. conscience restore files with as many holes as possible, since you can't
  5839. get it right.
  5840. @end quotation
  5841. @node Attributes
  5842. @section Handling File Attributes
  5843. @UNREVISED
  5844. When @command{tar} reads files, this causes them to have the access
  5845. times updated. To have @command{tar} attempt to set the access times
  5846. back to what they were before they were read, use the
  5847. @value{op-atime-preserve} option.
  5848. Handling of file attributes
  5849. @table @kbd
  5850. @item --atime-preserve
  5851. Preserve access times on files that are read.
  5852. This doesn't work for files that
  5853. you don't own, unless you're root, and it doesn't interact with
  5854. incremental dumps nicely (@pxref{Backups}), and it can set access or
  5855. modification times incorrectly if other programs access the file while
  5856. @command{tar} is running; but it is good enough for some purposes.
  5857. @item -m
  5858. @itemx --touch
  5859. Do not extract file modified time.
  5860. When this option is used, @command{tar} leaves the modification times
  5861. of the files it extracts as the time when the files were extracted,
  5862. instead of setting it to the time recorded in the archive.
  5863. This option is meaningless with @value{op-list}.
  5864. @item --same-owner
  5865. Create extracted files with the same ownership they have in the
  5866. archive.
  5867. This is the default behavior for the superuser,
  5868. so this option is meaningful only for non-root users, when @command{tar}
  5869. is executed on those systems able to give files away. This is
  5870. considered as a security flaw by many people, at least because it
  5871. makes quite difficult to correctly account users for the disk space
  5872. they occupy. Also, the @code{suid} or @code{sgid} attributes of
  5873. files are easily and silently lost when files are given away.
  5874. When writing an archive, @command{tar} writes the user id and user name
  5875. separately. If it can't find a user name (because the user id is not
  5876. in @file{/etc/passwd}), then it does not write one. When restoring,
  5877. and doing a @code{chmod} like when you use @value{op-same-permissions},
  5878. @FIXME{same-owner?}it tries to look the name (if one was written)
  5879. up in @file{/etc/passwd}. If it fails, then it uses the user id
  5880. stored in the archive instead.
  5881. @item --no-same-owner
  5882. @itemx -o
  5883. Do not attempt to restore ownership when extracting. This is the
  5884. default behavior for ordinary users, so this option has an effect
  5885. only for the superuser.
  5886. @item --numeric-owner
  5887. The @value{op-numeric-owner} option allows (ANSI) archives to be written
  5888. without user/group name information or such information to be ignored
  5889. when extracting. It effectively disables the generation and/or use
  5890. of user/group name information. This option forces extraction using
  5891. the numeric ids from the archive, ignoring the names.
  5892. This is useful in certain circumstances, when restoring a backup from
  5893. an emergency floppy with different passwd/group files for example.
  5894. It is otherwise impossible to extract files with the right ownerships
  5895. if the password file in use during the extraction does not match the
  5896. one belonging to the filesystem(s) being extracted. This occurs,
  5897. for example, if you are restoring your files after a major crash and
  5898. had booted from an emergency floppy with no password file or put your
  5899. disk into another machine to do the restore.
  5900. The numeric ids are @emph{always} saved into @command{tar} archives.
  5901. The identifying names are added at create time when provided by the
  5902. system, unless @value{op-old-archive} is used. Numeric ids could be
  5903. used when moving archives between a collection of machines using
  5904. a centralized management for attribution of numeric ids to users
  5905. and groups. This is often made through using the NIS capabilities.
  5906. When making a @command{tar} file for distribution to other sites, it
  5907. is sometimes cleaner to use a single owner for all files in the
  5908. distribution, and nicer to specify the write permission bits of the
  5909. files as stored in the archive independently of their actual value on
  5910. the file system. The way to prepare a clean distribution is usually
  5911. to have some Makefile rule creating a directory, copying all needed
  5912. files in that directory, then setting ownership and permissions as
  5913. wanted (there are a lot of possible schemes), and only then making a
  5914. @command{tar} archive out of this directory, before cleaning
  5915. everything out. Of course, we could add a lot of options to
  5916. @GNUTAR{} for fine tuning permissions and ownership.
  5917. This is not the good way, I think. @GNUTAR{} is
  5918. already crowded with options and moreover, the approach just explained
  5919. gives you a great deal of control already.
  5920. @item -p
  5921. @itemx --same-permissions
  5922. @itemx --preserve-permissions
  5923. Extract all protection information.
  5924. This option causes @command{tar} to set the modes (access permissions) of
  5925. extracted files exactly as recorded in the archive. If this option
  5926. is not used, the current @code{umask} setting limits the permissions
  5927. on extracted files.
  5928. This option is meaningless with @value{op-list}.
  5929. @item --preserve
  5930. Same as both @value{op-same-permissions} and @value{op-same-order}.
  5931. The @value{op-preserve} option has no equivalent short option name.
  5932. It is equivalent to @value{op-same-permissions} plus @value{op-same-order}.
  5933. @FIXME{I do not see the purpose of such an option. (Neither I. FP.)}
  5934. @end table
  5935. @node Standard
  5936. @section Basic Tar Format
  5937. @UNREVISED
  5938. While an archive may contain many files, the archive itself is a
  5939. single ordinary file. Like any other file, an archive file can be
  5940. written to a storage device such as a tape or disk, sent through a
  5941. pipe or over a network, saved on the active file system, or even
  5942. stored in another archive. An archive file is not easy to read or
  5943. manipulate without using the @command{tar} utility or Tar mode in
  5944. @acronym{GNU} Emacs.
  5945. Physically, an archive consists of a series of file entries terminated
  5946. by an end-of-archive entry, which consists of two 512 blocks of zero
  5947. bytes. A file
  5948. entry usually describes one of the files in the archive (an
  5949. @dfn{archive member}), and consists of a file header and the contents
  5950. of the file. File headers contain file names and statistics, checksum
  5951. information which @command{tar} uses to detect file corruption, and
  5952. information about file types.
  5953. Archives are permitted to have more than one member with the same
  5954. member name. One way this situation can occur is if more than one
  5955. version of a file has been stored in the archive. For information
  5956. about adding new versions of a file to an archive, see @ref{update}.
  5957. @FIXME-xref{To learn more about having more than one archive member with the
  5958. same name, see -backup node, when it's written.}
  5959. In addition to entries describing archive members, an archive may
  5960. contain entries which @command{tar} itself uses to store information.
  5961. @value{xref-label}, for an example of such an archive entry.
  5962. A @command{tar} archive file contains a series of blocks. Each block
  5963. contains @code{BLOCKSIZE} bytes. Although this format may be thought
  5964. of as being on magnetic tape, other media are often used.
  5965. Each file archived is represented by a header block which describes
  5966. the file, followed by zero or more blocks which give the contents
  5967. of the file. At the end of the archive file there are two 512-byte blocks
  5968. filled with binary zeros as an end-of-file marker. A reasonable system
  5969. should write such end-of-file marker at the end of an archive, but
  5970. must not assume that such a block exists when reading an archive. In
  5971. particular @GNUTAR{} always issues a warning if it does not encounter it.
  5972. The blocks may be @dfn{blocked} for physical I/O operations.
  5973. Each record of @var{n} blocks (where @var{n} is set by the
  5974. @value{op-blocking-factor} option to @command{tar}) is written with a single
  5975. @w{@samp{write ()}} operation. On magnetic tapes, the result of
  5976. such a write is a single record. When writing an archive,
  5977. the last record of blocks should be written at the full size, with
  5978. blocks after the zero block containing all zeros. When reading
  5979. an archive, a reasonable system should properly handle an archive
  5980. whose last record is shorter than the rest, or which contains garbage
  5981. records after a zero block.
  5982. The header block is defined in C as follows. In the @GNUTAR{}
  5983. distribution, this is part of file @file{src/tar.h}:
  5984. @smallexample
  5985. @include header.texi
  5986. @end smallexample
  5987. All characters in header blocks are represented by using 8-bit
  5988. characters in the local variant of ASCII. Each field within the
  5989. structure is contiguous; that is, there is no padding used within
  5990. the structure. Each character on the archive medium is stored
  5991. contiguously.
  5992. Bytes representing the contents of files (after the header block
  5993. of each file) are not translated in any way and are not constrained
  5994. to represent characters in any character set. The @command{tar} format
  5995. does not distinguish text files from binary files, and no translation
  5996. of file contents is performed.
  5997. The @code{name}, @code{linkname}, @code{magic}, @code{uname}, and
  5998. @code{gname} are null-terminated character strings. All other fields
  5999. are zero-filled octal numbers in ASCII. Each numeric field of width
  6000. @var{w} contains @var{w} minus 1 digits, and a null.
  6001. The @code{name} field is the file name of the file, with directory names
  6002. (if any) preceding the file name, separated by slashes.
  6003. @FIXME{how big a name before field overflows?}
  6004. The @code{mode} field provides nine bits specifying file permissions
  6005. and three bits to specify the Set UID, Set GID, and Save Text
  6006. (@dfn{sticky}) modes. Values for these bits are defined above.
  6007. When special permissions are required to create a file with a given
  6008. mode, and the user restoring files from the archive does not hold such
  6009. permissions, the mode bit(s) specifying those special permissions
  6010. are ignored. Modes which are not supported by the operating system
  6011. restoring files from the archive will be ignored. Unsupported modes
  6012. should be faked up when creating or updating an archive; e.g.@: the
  6013. group permission could be copied from the @emph{other} permission.
  6014. The @code{uid} and @code{gid} fields are the numeric user and group
  6015. ID of the file owners, respectively. If the operating system does
  6016. not support numeric user or group IDs, these fields should be ignored.
  6017. The @code{size} field is the size of the file in bytes; linked files
  6018. are archived with this field specified as zero. @FIXME-xref{Modifiers, in
  6019. particular the @value{op-incremental} option.}
  6020. The @code{mtime} field is the modification time of the file at the time
  6021. it was archived. It is the ASCII representation of the octal value of
  6022. the last time the file was modified, represented as an integer number of
  6023. seconds since January 1, 1970, 00:00 Coordinated Universal Time.
  6024. The @code{chksum} field is the ASCII representation of the octal value
  6025. of the simple sum of all bytes in the header block. Each 8-bit
  6026. byte in the header is added to an unsigned integer, initialized to
  6027. zero, the precision of which shall be no less than seventeen bits.
  6028. When calculating the checksum, the @code{chksum} field is treated as
  6029. if it were all blanks.
  6030. The @code{typeflag} field specifies the type of file archived. If a
  6031. particular implementation does not recognize or permit the specified
  6032. type, the file will be extracted as if it were a regular file. As this
  6033. action occurs, @command{tar} issues a warning to the standard error.
  6034. The @code{atime} and @code{ctime} fields are used in making incremental
  6035. backups; they store, respectively, the particular file's access time
  6036. and last inode-change time.
  6037. The @code{offset} is used by the @value{op-multi-volume} option, when
  6038. making a multi-volume archive. The offset is number of bytes into
  6039. the file that we need to restart at to continue the file on the next
  6040. tape, i.e., where we store the location that a continued file is
  6041. continued at.
  6042. The following fields were added to deal with sparse files. A file
  6043. is @dfn{sparse} if it takes in unallocated blocks which end up being
  6044. represented as zeros, i.e., no useful data. A test to see if a file
  6045. is sparse is to look at the number blocks allocated for it versus the
  6046. number of characters in the file; if there are fewer blocks allocated
  6047. for the file than would normally be allocated for a file of that
  6048. size, then the file is sparse. This is the method @command{tar} uses to
  6049. detect a sparse file, and once such a file is detected, it is treated
  6050. differently from non-sparse files.
  6051. Sparse files are often @code{dbm} files, or other database-type files
  6052. which have data at some points and emptiness in the greater part of
  6053. the file. Such files can appear to be very large when an @samp{ls
  6054. -l} is done on them, when in truth, there may be a very small amount
  6055. of important data contained in the file. It is thus undesirable
  6056. to have @command{tar} think that it must back up this entire file, as
  6057. great quantities of room are wasted on empty blocks, which can lead
  6058. to running out of room on a tape far earlier than is necessary.
  6059. Thus, sparse files are dealt with so that these empty blocks are
  6060. not written to the tape. Instead, what is written to the tape is a
  6061. description, of sorts, of the sparse file: where the holes are, how
  6062. big the holes are, and how much data is found at the end of the hole.
  6063. This way, the file takes up potentially far less room on the tape,
  6064. and when the file is extracted later on, it will look exactly the way
  6065. it looked beforehand. The following is a description of the fields
  6066. used to handle a sparse file:
  6067. The @code{sp} is an array of @code{struct sparse}. Each @code{struct
  6068. sparse} contains two 12-character strings which represent an offset
  6069. into the file and a number of bytes to be written at that offset.
  6070. The offset is absolute, and not relative to the offset in preceding
  6071. array element.
  6072. The header can hold four of these @code{struct sparse} at the moment;
  6073. if more are needed, they are not stored in the header.
  6074. The @code{isextended} flag is set when an @code{extended_header}
  6075. is needed to deal with a file. Note that this means that this flag
  6076. can only be set when dealing with a sparse file, and it is only set
  6077. in the event that the description of the file will not fit in the
  6078. allotted room for sparse structures in the header. In other words,
  6079. an extended_header is needed.
  6080. The @code{extended_header} structure is used for sparse files which
  6081. need more sparse structures than can fit in the header. The header can
  6082. fit 4 such structures; if more are needed, the flag @code{isextended}
  6083. gets set and the next block is an @code{extended_header}.
  6084. Each @code{extended_header} structure contains an array of 21
  6085. sparse structures, along with a similar @code{isextended} flag
  6086. that the header had. There can be an indeterminate number of such
  6087. @code{extended_header}s to describe a sparse file.
  6088. @table @asis
  6089. @item @code{REGTYPE}
  6090. @itemx @code{AREGTYPE}
  6091. These flags represent a regular file. In order to be compatible
  6092. with older versions of @command{tar}, a @code{typeflag} value of
  6093. @code{AREGTYPE} should be silently recognized as a regular file.
  6094. New archives should be created using @code{REGTYPE}. Also, for
  6095. backward compatibility, @command{tar} treats a regular file whose name
  6096. ends with a slash as a directory.
  6097. @item @code{LNKTYPE}
  6098. This flag represents a file linked to another file, of any type,
  6099. previously archived. Such files are identified in Unix by each
  6100. file having the same device and inode number. The linked-to name is
  6101. specified in the @code{linkname} field with a trailing null.
  6102. @item @code{SYMTYPE}
  6103. This represents a symbolic link to another file. The linked-to name
  6104. is specified in the @code{linkname} field with a trailing null.
  6105. @item @code{CHRTYPE}
  6106. @itemx @code{BLKTYPE}
  6107. These represent character special files and block special files
  6108. respectively. In this case the @code{devmajor} and @code{devminor}
  6109. fields will contain the major and minor device numbers respectively.
  6110. Operating systems may map the device specifications to their own
  6111. local specification, or may ignore the entry.
  6112. @item @code{DIRTYPE}
  6113. This flag specifies a directory or sub-directory. The directory
  6114. name in the @code{name} field should end with a slash. On systems where
  6115. disk allocation is performed on a directory basis, the @code{size} field
  6116. will contain the maximum number of bytes (which may be rounded to
  6117. the nearest disk block allocation unit) which the directory may
  6118. hold. A @code{size} field of zero indicates no such limiting. Systems
  6119. which do not support limiting in this manner should ignore the
  6120. @code{size} field.
  6121. @item @code{FIFOTYPE}
  6122. This specifies a FIFO special file. Note that the archiving of a
  6123. FIFO file archives the existence of this file and not its contents.
  6124. @item @code{CONTTYPE}
  6125. This specifies a contiguous file, which is the same as a normal
  6126. file except that, in operating systems which support it, all its
  6127. space is allocated contiguously on the disk. Operating systems
  6128. which do not allow contiguous allocation should silently treat this
  6129. type as a normal file.
  6130. @item @code{A} @dots{} @code{Z}
  6131. These are reserved for custom implementations. Some of these are
  6132. used in the @acronym{GNU} modified format, as described below.
  6133. @end table
  6134. Other values are reserved for specification in future revisions of
  6135. the P1003 standard, and should not be used by any @command{tar} program.
  6136. The @code{magic} field indicates that this archive was output in
  6137. the P1003 archive format. If this field contains @code{TMAGIC},
  6138. the @code{uname} and @code{gname} fields will contain the ASCII
  6139. representation of the owner and group of the file respectively.
  6140. If found, the user and group IDs are used rather than the values in
  6141. the @code{uid} and @code{gid} fields.
  6142. For references, see ISO/IEC 9945-1:1990 or IEEE Std 1003.1-1990, pages
  6143. 169-173 (section 10.1) for @cite{Archive/Interchange File Format}; and
  6144. IEEE Std 1003.2-1992, pages 380-388 (section 4.48) and pages 936-940
  6145. (section E.4.48) for @cite{pax - Portable archive interchange}.
  6146. @node Extensions
  6147. @section @acronym{GNU} Extensions to the Archive Format
  6148. @UNREVISED
  6149. The @acronym{GNU} format uses additional file types to describe new types of
  6150. files in an archive. These are listed below.
  6151. @table @code
  6152. @item GNUTYPE_DUMPDIR
  6153. @itemx 'D'
  6154. This represents a directory and a list of files created by the
  6155. @value{op-incremental} option. The @code{size} field gives the total
  6156. size of the associated list of files. Each file name is preceded by
  6157. either a @samp{Y} (the file should be in this archive) or an @samp{N}.
  6158. (The file is a directory, or is not stored in the archive.) Each file
  6159. name is terminated by a null. There is an additional null after the
  6160. last file name.
  6161. @item GNUTYPE_MULTIVOL
  6162. @itemx 'M'
  6163. This represents a file continued from another volume of a multi-volume
  6164. archive created with the @value{op-multi-volume} option. The original
  6165. type of the file is not given here. The @code{size} field gives the
  6166. maximum size of this piece of the file (assuming the volume does
  6167. not end before the file is written out). The @code{offset} field
  6168. gives the offset from the beginning of the file where this part of
  6169. the file begins. Thus @code{size} plus @code{offset} should equal
  6170. the original size of the file.
  6171. @item GNUTYPE_SPARSE
  6172. @itemx 'S'
  6173. This flag indicates that we are dealing with a sparse file. Note
  6174. that archiving a sparse file requires special operations to find
  6175. holes in the file, which mark the positions of these holes, along
  6176. with the number of bytes of data to be found after the hole.
  6177. @item GNUTYPE_VOLHDR
  6178. @itemx 'V'
  6179. This file type is used to mark the volume header that was given with
  6180. the @value{op-label} option when the archive was created. The @code{name}
  6181. field contains the @code{name} given after the @value{op-label} option.
  6182. The @code{size} field is zero. Only the first file in each volume
  6183. of an archive should have this type.
  6184. @end table
  6185. You may have trouble reading a @acronym{GNU} format archive on a
  6186. non-@acronym{GNU} system if the options @value{op-incremental},
  6187. @value{op-multi-volume}, @value{op-sparse}, or @value{op-label} were
  6188. used when writing the archive. In general, if @command{tar} does not
  6189. use the @acronym{GNU}-added fields of the header, other versions of
  6190. @command{tar} should be able to read the archive. Otherwise, the
  6191. @command{tar} program will give an error, the most likely one being a
  6192. checksum error.
  6193. @node cpio
  6194. @section Comparison of @command{tar} and @command{cpio}
  6195. @UNREVISED
  6196. @FIXME{Reorganize the following material}
  6197. The @command{cpio} archive formats, like @command{tar}, do have maximum
  6198. pathname lengths. The binary and old ASCII formats have a max path
  6199. length of 256, and the new ASCII and CRC ASCII formats have a max
  6200. path length of 1024. @acronym{GNU} @command{cpio} can read and write archives
  6201. with arbitrary pathname lengths, but other @command{cpio} implementations
  6202. may crash unexplainedly trying to read them.
  6203. @command{tar} handles symbolic links in the form in which it comes in BSD;
  6204. @command{cpio} doesn't handle symbolic links in the form in which it comes
  6205. in System V prior to SVR4, and some vendors may have added symlinks
  6206. to their system without enhancing @command{cpio} to know about them.
  6207. Others may have enhanced it in a way other than the way I did it
  6208. at Sun, and which was adopted by AT&T (and which is, I think, also
  6209. present in the @command{cpio} that Berkeley picked up from AT&T and put
  6210. into a later BSD release---I think I gave them my changes).
  6211. (SVR4 does some funny stuff with @command{tar}; basically, its @command{cpio}
  6212. can handle @command{tar} format input, and write it on output, and it
  6213. probably handles symbolic links. They may not have bothered doing
  6214. anything to enhance @command{tar} as a result.)
  6215. @command{cpio} handles special files; traditional @command{tar} doesn't.
  6216. @command{tar} comes with V7, System III, System V, and BSD source;
  6217. @command{cpio} comes only with System III, System V, and later BSD
  6218. (4.3-tahoe and later).
  6219. @command{tar}'s way of handling multiple hard links to a file can handle
  6220. file systems that support 32-bit inumbers (e.g., the BSD file system);
  6221. @command{cpio}s way requires you to play some games (in its "binary"
  6222. format, i-numbers are only 16 bits, and in its "portable ASCII" format,
  6223. they're 18 bits---it would have to play games with the "file system ID"
  6224. field of the header to make sure that the file system ID/i-number pairs
  6225. of different files were always different), and I don't know which
  6226. @command{cpio}s, if any, play those games. Those that don't might get
  6227. confused and think two files are the same file when they're not, and
  6228. make hard links between them.
  6229. @command{tar}s way of handling multiple hard links to a file places only
  6230. one copy of the link on the tape, but the name attached to that copy
  6231. is the @emph{only} one you can use to retrieve the file; @command{cpio}s
  6232. way puts one copy for every link, but you can retrieve it using any
  6233. of the names.
  6234. @quotation
  6235. What type of check sum (if any) is used, and how is this calculated.
  6236. @end quotation
  6237. See the attached manual pages for @command{tar} and @command{cpio} format.
  6238. @command{tar} uses a checksum which is the sum of all the bytes in the
  6239. @command{tar} header for a file; @command{cpio} uses no checksum.
  6240. @quotation
  6241. If anyone knows why @command{cpio} was made when @command{tar} was present
  6242. at the unix scene,
  6243. @end quotation
  6244. It wasn't. @command{cpio} first showed up in PWB/UNIX 1.0; no
  6245. generally-available version of UNIX had @command{tar} at the time. I don't
  6246. know whether any version that was generally available @emph{within AT&T}
  6247. had @command{tar}, or, if so, whether the people within AT&T who did
  6248. @command{cpio} knew about it.
  6249. On restore, if there is a corruption on a tape @command{tar} will stop at
  6250. that point, while @command{cpio} will skip over it and try to restore the
  6251. rest of the files.
  6252. The main difference is just in the command syntax and header format.
  6253. @command{tar} is a little more tape-oriented in that everything is blocked
  6254. to start on a record boundary.
  6255. @quotation
  6256. Is there any differences between the ability to recover crashed
  6257. archives between the two of them. (Is there any chance of recovering
  6258. crashed archives at all.)
  6259. @end quotation
  6260. Theoretically it should be easier under @command{tar} since the blocking
  6261. lets you find a header with some variation of @samp{dd skip=@var{nn}}.
  6262. However, modern @command{cpio}'s and variations have an option to just
  6263. search for the next file header after an error with a reasonable chance
  6264. of resyncing. However, lots of tape driver software won't allow you to
  6265. continue past a media error which should be the only reason for getting
  6266. out of sync unless a file changed sizes while you were writing the
  6267. archive.
  6268. @quotation
  6269. If anyone knows why @command{cpio} was made when @command{tar} was present
  6270. at the unix scene, please tell me about this too.
  6271. @end quotation
  6272. Probably because it is more media efficient (by not blocking everything
  6273. and using only the space needed for the headers where @command{tar}
  6274. always uses 512 bytes per file header) and it knows how to archive
  6275. special files.
  6276. You might want to look at the freely available alternatives. The
  6277. major ones are @command{afio}, @GNUTAR{}, and
  6278. @command{pax}, each of which have their own extensions with some
  6279. backwards compatibility.
  6280. Sparse files were @command{tar}red as sparse files (which you can
  6281. easily test, because the resulting archive gets smaller, and
  6282. @acronym{GNU} @command{cpio} can no longer read it).
  6283. @node Media
  6284. @chapter Tapes and Other Archive Media
  6285. @UNREVISED
  6286. A few special cases about tape handling warrant more detailed
  6287. description. These special cases are discussed below.
  6288. Many complexities surround the use of @command{tar} on tape drives. Since
  6289. the creation and manipulation of archives located on magnetic tape was
  6290. the original purpose of @command{tar}, it contains many features making
  6291. such manipulation easier.
  6292. Archives are usually written on dismountable media---tape cartridges,
  6293. mag tapes, or floppy disks.
  6294. The amount of data a tape or disk holds depends not only on its size,
  6295. but also on how it is formatted. A 2400 foot long reel of mag tape
  6296. holds 40 megabytes of data when formatted at 1600 bits per inch. The
  6297. physically smaller EXABYTE tape cartridge holds 2.3 gigabytes.
  6298. Magnetic media are re-usable---once the archive on a tape is no longer
  6299. needed, the archive can be erased and the tape or disk used over.
  6300. Media quality does deteriorate with use, however. Most tapes or disks
  6301. should be discarded when they begin to produce data errors. EXABYTE
  6302. tape cartridges should be discarded when they generate an @dfn{error
  6303. count} (number of non-usable bits) of more than 10k.
  6304. Magnetic media are written and erased using magnetic fields, and
  6305. should be protected from such fields to avoid damage to stored data.
  6306. Sticking a floppy disk to a filing cabinet using a magnet is probably
  6307. not a good idea.
  6308. @menu
  6309. * Device:: Device selection and switching
  6310. * Remote Tape Server::
  6311. * Common Problems and Solutions::
  6312. * Blocking:: Blocking
  6313. * Many:: Many archives on one tape
  6314. * Using Multiple Tapes:: Using Multiple Tapes
  6315. * label:: Including a Label in the Archive
  6316. * verify::
  6317. * Write Protection::
  6318. @end menu
  6319. @node Device
  6320. @section Device Selection and Switching
  6321. @UNREVISED
  6322. @table @kbd
  6323. @item -f [@var{hostname}:]@var{file}
  6324. @itemx --file=[@var{hostname}:]@var{file}
  6325. Use archive file or device @var{file} on @var{hostname}.
  6326. @end table
  6327. This option is used to specify the file name of the archive @command{tar}
  6328. works on.
  6329. If the file name is @samp{-}, @command{tar} reads the archive from standard
  6330. input (when listing or extracting), or writes it to standard output
  6331. (when creating). If the @samp{-} file name is given when updating an
  6332. archive, @command{tar} will read the original archive from its standard
  6333. input, and will write the entire new archive to its standard output.
  6334. If the file name contains a @samp{:}, it is interpreted as
  6335. @samp{hostname:file name}. If the @var{hostname} contains an @dfn{at}
  6336. sign (@kbd{@@}), it is treated as @samp{user@@hostname:file name}. In
  6337. either case, @command{tar} will invoke the command @command{rsh} (or
  6338. @command{remsh}) to start up an @command{/usr/libexec/rmt} on the remote
  6339. machine. If you give an alternate login name, it will be given to the
  6340. @command{rsh}.
  6341. Naturally, the remote machine must have an executable
  6342. @command{/usr/libexec/rmt}. This program is free software from the
  6343. University of California, and a copy of the source code can be found
  6344. with the sources for @command{tar}; it's compiled and installed by default.
  6345. The exact path to this utility is determined when configuring the package.
  6346. It is @file{@var{prefix}/libexec/rmt}, where @var{prefix} stands for
  6347. your installation prefix. This location may also be overridden at
  6348. runtime by using @value{op-rmt-command} option (@xref{Option Summary,
  6349. ---rmt-command}, for detailed description of this option. @xref{Remote
  6350. Tape Server}, for the description of @command{rmt} command).
  6351. If this option is not given, but the environment variable @env{TAPE}
  6352. is set, its value is used; otherwise, old versions of @command{tar}
  6353. used a default archive name (which was picked when @command{tar} was
  6354. compiled). The default is normally set up to be the @dfn{first} tape
  6355. drive or other transportable I/O medium on the system.
  6356. Starting with version 1.11.5, @GNUTAR{} uses
  6357. standard input and standard output as the default device, and I will
  6358. not try anymore supporting automatic device detection at installation
  6359. time. This was failing really in too many cases, it was hopeless.
  6360. This is now completely left to the installer to override standard
  6361. input and standard output for default device, if this seems
  6362. preferable. Further, I think @emph{most} actual usages of
  6363. @command{tar} are done with pipes or disks, not really tapes,
  6364. cartridges or diskettes.
  6365. Some users think that using standard input and output is running
  6366. after trouble. This could lead to a nasty surprise on your screen if
  6367. you forget to specify an output file name---especially if you are going
  6368. through a network or terminal server capable of buffering large amounts
  6369. of output. We had so many bug reports in that area of configuring
  6370. default tapes automatically, and so many contradicting requests, that
  6371. we finally consider the problem to be portably intractable. We could
  6372. of course use something like @samp{/dev/tape} as a default, but this
  6373. is @emph{also} running after various kind of trouble, going from hung
  6374. processes to accidental destruction of real tapes. After having seen
  6375. all this mess, using standard input and output as a default really
  6376. sounds like the only clean choice left, and a very useful one too.
  6377. @GNUTAR{} reads and writes archive in records, I
  6378. suspect this is the main reason why block devices are preferred over
  6379. character devices. Most probably, block devices are more efficient
  6380. too. The installer could also check for @samp{DEFTAPE} in
  6381. @file{<sys/mtio.h>}.
  6382. @table @kbd
  6383. @item --force-local
  6384. Archive file is local even if it contains a colon.
  6385. @item --rsh-command=@var{command}
  6386. Use remote @var{command} instead of @command{rsh}. This option exists
  6387. so that people who use something other than the standard @command{rsh}
  6388. (e.g., a Kerberized @command{rsh}) can access a remote device.
  6389. When this command is not used, the shell command found when
  6390. the @command{tar} program was installed is used instead. This is
  6391. the first found of @file{/usr/ucb/rsh}, @file{/usr/bin/remsh},
  6392. @file{/usr/bin/rsh}, @file{/usr/bsd/rsh} or @file{/usr/bin/nsh}.
  6393. The installer may have overridden this by defining the environment
  6394. variable @env{RSH} @emph{at installation time}.
  6395. @item -[0-7][lmh]
  6396. Specify drive and density.
  6397. @item -M
  6398. @itemx --multi-volume
  6399. Create/list/extract multi-volume archive.
  6400. This option causes @command{tar} to write a @dfn{multi-volume} archive---one
  6401. that may be larger than will fit on the medium used to hold it.
  6402. @xref{Multi-Volume Archives}.
  6403. @item -L @var{num}
  6404. @itemx --tape-length=@var{num}
  6405. Change tape after writing @var{num} x 1024 bytes.
  6406. This option might be useful when your tape drivers do not properly
  6407. detect end of physical tapes. By being slightly conservative on the
  6408. maximum tape length, you might avoid the problem entirely.
  6409. @item -F @var{file}
  6410. @itemx --info-script=@var{file}
  6411. @itemx --new-volume-script=@var{file}
  6412. Execute @file{file} at end of each tape. If @file{file} exits with
  6413. nonzero status, exit. This implies @value{op-multi-volume}.
  6414. @end table
  6415. @node Remote Tape Server
  6416. @section The Remote Tape Server
  6417. @cindex remote tape drive
  6418. @pindex rmt
  6419. In order to access the tape drive on a remote machine, @command{tar}
  6420. uses the remote tape server written at the University of California at
  6421. Berkeley. The remote tape server must be installed as
  6422. @file{@var{prefix}/libexec/rmt} on any machine whose tape drive you
  6423. want to use. @command{tar} calls @command{rmt} by running an
  6424. @command{rsh} or @command{remsh} to the remote machine, optionally
  6425. using a different login name if one is supplied.
  6426. A copy of the source for the remote tape server is provided. It is
  6427. Copyright @copyright{} 1983 by the Regents of the University of
  6428. California, but can be freely distributed. It is compiled and
  6429. installed by default.
  6430. @cindex absolute file names
  6431. Unless you use the @value{op-absolute-names} option, @GNUTAR{}
  6432. will not allow you to create an archive that contains
  6433. absolute file names (a file name beginning with @samp{/}.) If you try,
  6434. @command{tar} will automatically remove the leading @samp{/} from the
  6435. file names it stores in the archive. It will also type a warning
  6436. message telling you what it is doing.
  6437. When reading an archive that was created with a different
  6438. @command{tar} program, @GNUTAR{} automatically
  6439. extracts entries in the archive which have absolute file names as if
  6440. the file names were not absolute. This is an important feature. A
  6441. visitor here once gave a @command{tar} tape to an operator to restore;
  6442. the operator used Sun @command{tar} instead of @GNUTAR{},
  6443. and the result was that it replaced large portions of
  6444. our @file{/bin} and friends with versions from the tape; needless to
  6445. say, we were unhappy about having to recover the file system from
  6446. backup tapes.
  6447. For example, if the archive contained a file @file{/usr/bin/computoy},
  6448. @GNUTAR{} would extract the file to @file{usr/bin/computoy},
  6449. relative to the current directory. If you want to extract the files in
  6450. an archive to the same absolute names that they had when the archive
  6451. was created, you should do a @samp{cd /} before extracting the files
  6452. from the archive, or you should either use the @value{op-absolute-names}
  6453. option, or use the command @samp{tar -C / @dots{}}.
  6454. @cindex Ultrix 3.1 and write failure
  6455. Some versions of Unix (Ultrix 3.1 is known to have this problem),
  6456. can claim that a short write near the end of a tape succeeded,
  6457. when it actually failed. This will result in the -M option not
  6458. working correctly. The best workaround at the moment is to use a
  6459. significantly larger blocking factor than the default 20.
  6460. In order to update an archive, @command{tar} must be able to backspace the
  6461. archive in order to reread or rewrite a record that was just read (or
  6462. written). This is currently possible only on two kinds of files: normal
  6463. disk files (or any other file that can be backspaced with @samp{lseek}),
  6464. and industry-standard 9-track magnetic tape (or any other kind of tape
  6465. that can be backspaced with the @code{MTIOCTOP} @code{ioctl}.
  6466. This means that the @value{op-append}, @value{op-update},
  6467. @value{op-concatenate}, and @value{op-delete} commands will not work on any
  6468. other kind of file. Some media simply cannot be backspaced, which
  6469. means these commands and options will never be able to work on them.
  6470. These non-backspacing media include pipes and cartridge tape drives.
  6471. Some other media can be backspaced, and @command{tar} will work on them
  6472. once @command{tar} is modified to do so.
  6473. Archives created with the @value{op-multi-volume}, @value{op-label}, and
  6474. @value{op-incremental} options may not be readable by other version
  6475. of @command{tar}. In particular, restoring a file that was split over
  6476. a volume boundary will require some careful work with @command{dd}, if
  6477. it can be done at all. Other versions of @command{tar} may also create
  6478. an empty file whose name is that of the volume header. Some versions
  6479. of @command{tar} may create normal files instead of directories archived
  6480. with the @value{op-incremental} option.
  6481. @node Common Problems and Solutions
  6482. @section Some Common Problems and their Solutions
  6483. @ifclear PUBLISH
  6484. @format
  6485. errors from system:
  6486. permission denied
  6487. no such file or directory
  6488. not owner
  6489. errors from @command{tar}:
  6490. directory checksum error
  6491. header format error
  6492. errors from media/system:
  6493. i/o error
  6494. device busy
  6495. @end format
  6496. @end ifclear
  6497. @node Blocking
  6498. @section Blocking
  6499. @UNREVISED
  6500. @dfn{Block} and @dfn{record} terminology is rather confused, and it
  6501. is also confusing to the expert reader. On the other hand, readers
  6502. who are new to the field have a fresh mind, and they may safely skip
  6503. the next two paragraphs, as the remainder of this manual uses those
  6504. two terms in a quite consistent way.
  6505. John Gilmore, the writer of the public domain @command{tar} from which
  6506. @GNUTAR{} was originally derived, wrote (June 1995):
  6507. @quotation
  6508. The nomenclature of tape drives comes from IBM, where I believe
  6509. they were invented for the IBM 650 or so. On IBM mainframes, what
  6510. is recorded on tape are tape blocks. The logical organization of
  6511. data is into records. There are various ways of putting records into
  6512. blocks, including @code{F} (fixed sized records), @code{V} (variable
  6513. sized records), @code{FB} (fixed blocked: fixed size records, @var{n}
  6514. to a block), @code{VB} (variable size records, @var{n} to a block),
  6515. @code{VSB} (variable spanned blocked: variable sized records that can
  6516. occupy more than one block), etc. The @code{JCL} @samp{DD RECFORM=}
  6517. parameter specified this to the operating system.
  6518. The Unix man page on @command{tar} was totally confused about this.
  6519. When I wrote @code{PD TAR}, I used the historically correct terminology
  6520. (@command{tar} writes data records, which are grouped into blocks).
  6521. It appears that the bogus terminology made it into @acronym{POSIX} (no surprise
  6522. here), and now Fran@,{c}ois has migrated that terminology back
  6523. into the source code too.
  6524. @end quotation
  6525. The term @dfn{physical block} means the basic transfer chunk from or
  6526. to a device, after which reading or writing may stop without anything
  6527. being lost. In this manual, the term @dfn{block} usually refers to
  6528. a disk physical block, @emph{assuming} that each disk block is 512
  6529. bytes in length. It is true that some disk devices have different
  6530. physical blocks, but @command{tar} ignore these differences in its own
  6531. format, which is meant to be portable, so a @command{tar} block is always
  6532. 512 bytes in length, and @dfn{block} always mean a @command{tar} block.
  6533. The term @dfn{logical block} often represents the basic chunk of
  6534. allocation of many disk blocks as a single entity, which the operating
  6535. system treats somewhat atomically; this concept is only barely used
  6536. in @GNUTAR{}.
  6537. The term @dfn{physical record} is another way to speak of a physical
  6538. block, those two terms are somewhat interchangeable. In this manual,
  6539. the term @dfn{record} usually refers to a tape physical block,
  6540. @emph{assuming} that the @command{tar} archive is kept on magnetic tape.
  6541. It is true that archives may be put on disk or used with pipes,
  6542. but nevertheless, @command{tar} tries to read and write the archive one
  6543. @dfn{record} at a time, whatever the medium in use. One record is made
  6544. up of an integral number of blocks, and this operation of putting many
  6545. disk blocks into a single tape block is called @dfn{reblocking}, or
  6546. more simply, @dfn{blocking}. The term @dfn{logical record} refers to
  6547. the logical organization of many characters into something meaningful
  6548. to the application. The term @dfn{unit record} describes a small set
  6549. of characters which are transmitted whole to or by the application,
  6550. and often refers to a line of text. Those two last terms are unrelated
  6551. to what we call a @dfn{record} in @GNUTAR{}.
  6552. When writing to tapes, @command{tar} writes the contents of the archive
  6553. in chunks known as @dfn{records}. To change the default blocking
  6554. factor, use the @value{op-blocking-factor} option. Each record will
  6555. then be composed of @var{512-size} blocks. (Each @command{tar} block is
  6556. 512 bytes. @xref{Standard}.) Each file written to the archive uses
  6557. at least one full record. As a result, using a larger record size
  6558. can result in more wasted space for small files. On the other hand, a
  6559. larger record size can often be read and written much more efficiently.
  6560. Further complicating the problem is that some tape drives ignore the
  6561. blocking entirely. For these, a larger record size can still improve
  6562. performance (because the software layers above the tape drive still
  6563. honor the blocking), but not as dramatically as on tape drives that
  6564. honor blocking.
  6565. When reading an archive, @command{tar} can usually figure out the
  6566. record size on itself. When this is the case, and a non-standard
  6567. record size was used when the archive was created, @command{tar} will
  6568. print a message about a non-standard blocking factor, and then operate
  6569. normally. On some tape devices, however, @command{tar} cannot figure
  6570. out the record size itself. On most of those, you can specify a
  6571. blocking factor (with @value{op-blocking-factor}) larger than the
  6572. actual blocking factor, and then use the @value{op-read-full-records}
  6573. option. (If you specify a blocking factor with
  6574. @value{op-blocking-factor} and don't use the
  6575. @value{op-read-full-records} option, then @command{tar} will not
  6576. attempt to figure out the recording size itself.) On some devices,
  6577. you must always specify the record size exactly with
  6578. @value{op-blocking-factor} when reading, because @command{tar} cannot
  6579. figure it out. In any case, use @value{op-list} before doing any
  6580. extractions to see whether @command{tar} is reading the archive
  6581. correctly.
  6582. @command{tar} blocks are all fixed size (512 bytes), and its scheme for
  6583. putting them into records is to put a whole number of them (one or
  6584. more) into each record. @command{tar} records are all the same size;
  6585. at the end of the file there's a block containing all zeros, which
  6586. is how you tell that the remainder of the last record(s) are garbage.
  6587. In a standard @command{tar} file (no options), the block size is 512
  6588. and the record size is 10240, for a blocking factor of 20. What the
  6589. @value{op-blocking-factor} option does is sets the blocking factor,
  6590. changing the record size while leaving the block size at 512 bytes.
  6591. 20 was fine for ancient 800 or 1600 bpi reel-to-reel tape drives;
  6592. most tape drives these days prefer much bigger records in order to
  6593. stream and not waste tape. When writing tapes for myself, some tend
  6594. to use a factor of the order of 2048, say, giving a record size of
  6595. around one megabyte.
  6596. If you use a blocking factor larger than 20, older @command{tar}
  6597. programs might not be able to read the archive, so we recommend this
  6598. as a limit to use in practice. @GNUTAR{}, however,
  6599. will support arbitrarily large record sizes, limited only by the
  6600. amount of virtual memory or the physical characteristics of the tape
  6601. device.
  6602. @menu
  6603. * Format Variations:: Format Variations
  6604. * Blocking Factor:: The Blocking Factor of an Archive
  6605. @end menu
  6606. @node Format Variations
  6607. @subsection Format Variations
  6608. @cindex Format Parameters
  6609. @cindex Format Options
  6610. @cindex Options, archive format specifying
  6611. @cindex Options, format specifying
  6612. @UNREVISED
  6613. Format parameters specify how an archive is written on the archive
  6614. media. The best choice of format parameters will vary depending on
  6615. the type and number of files being archived, and on the media used to
  6616. store the archive.
  6617. To specify format parameters when accessing or creating an archive,
  6618. you can use the options described in the following sections.
  6619. If you do not specify any format parameters, @command{tar} uses
  6620. default parameters. You cannot modify a compressed archive.
  6621. If you create an archive with the @value{op-blocking-factor} option
  6622. specified (@value{pxref-blocking-factor}), you must specify that
  6623. blocking-factor when operating on the archive. @xref{Formats}, for other
  6624. examples of format parameter considerations.
  6625. @node Blocking Factor
  6626. @subsection The Blocking Factor of an Archive
  6627. @cindex Blocking Factor
  6628. @cindex Record Size
  6629. @cindex Number of blocks per record
  6630. @cindex Number of bytes per record
  6631. @cindex Bytes per record
  6632. @cindex Blocks per record
  6633. @UNREVISED
  6634. The data in an archive is grouped into blocks, which are 512 bytes.
  6635. Blocks are read and written in whole number multiples called
  6636. @dfn{records}. The number of blocks in a record (ie. the size of a
  6637. record in units of 512 bytes) is called the @dfn{blocking factor}.
  6638. The @value{op-blocking-factor} option specifies the blocking factor of
  6639. an archive. The default blocking factor is typically 20 (ie.@:
  6640. 10240 bytes), but can be specified at installation. To find out
  6641. the blocking factor of an existing archive, use @samp{tar --list
  6642. --file=@var{archive-name}}. This may not work on some devices.
  6643. Records are separated by gaps, which waste space on the archive media.
  6644. If you are archiving on magnetic tape, using a larger blocking factor
  6645. (and therefore larger records) provides faster throughput and allows you
  6646. to fit more data on a tape (because there are fewer gaps). If you are
  6647. archiving on cartridge, a very large blocking factor (say 126 or more)
  6648. greatly increases performance. A smaller blocking factor, on the other
  6649. hand, may be useful when archiving small files, to avoid archiving lots
  6650. of nulls as @command{tar} fills out the archive to the end of the record.
  6651. In general, the ideal record size depends on the size of the
  6652. inter-record gaps on the tape you are using, and the average size of the
  6653. files you are archiving. @xref{create}, for information on
  6654. writing archives.
  6655. @FIXME{Need example of using a cartridge with blocking factor=126 or more.}
  6656. Archives with blocking factors larger than 20 cannot be read
  6657. by very old versions of @command{tar}, or by some newer versions
  6658. of @command{tar} running on old machines with small address spaces.
  6659. With @GNUTAR{}, the blocking factor of an archive is limited
  6660. only by the maximum record size of the device containing the archive,
  6661. or by the amount of available virtual memory.
  6662. Also, on some systems, not using adequate blocking factors, as sometimes
  6663. imposed by the device drivers, may yield unexpected diagnostics. For
  6664. example, this has been reported:
  6665. @smallexample
  6666. Cannot write to /dev/dlt: Invalid argument
  6667. @end smallexample
  6668. @noindent
  6669. In such cases, it sometimes happen that the @command{tar} bundled by
  6670. the system is aware of block size idiosyncrasies, while @GNUTAR{}
  6671. requires an explicit specification for the block size,
  6672. which it cannot guess. This yields some people to consider
  6673. @GNUTAR{} is misbehaving, because by comparison,
  6674. @cite{the bundle @command{tar} works OK}. Adding @w{@kbd{-b 256}},
  6675. for example, might resolve the problem.
  6676. If you use a non-default blocking factor when you create an archive, you
  6677. must specify the same blocking factor when you modify that archive. Some
  6678. archive devices will also require you to specify the blocking factor when
  6679. reading that archive, however this is not typically the case. Usually, you
  6680. can use @value{op-list} without specifying a blocking factor---@command{tar}
  6681. reports a non-default record size and then lists the archive members as
  6682. it would normally. To extract files from an archive with a non-standard
  6683. blocking factor (particularly if you're not sure what the blocking factor
  6684. is), you can usually use the @value{op-read-full-records} option while
  6685. specifying a blocking factor larger then the blocking factor of the archive
  6686. (ie. @samp{tar --extract --read-full-records --blocking-factor=300}.
  6687. @xref{list}, for more information on the @value{op-list}
  6688. operation. @xref{Reading}, for a more detailed explanation of that option.
  6689. @table @kbd
  6690. @item --blocking-factor=@var{number}
  6691. @itemx -b @var{number}
  6692. Specifies the blocking factor of an archive. Can be used with any
  6693. operation, but is usually not necessary with @value{op-list}.
  6694. @end table
  6695. Device blocking
  6696. @table @kbd
  6697. @item -b @var{blocks}
  6698. @itemx --blocking-factor=@var{blocks}
  6699. Set record size to @math{@var{blocks} * 512} bytes.
  6700. This option is used to specify a @dfn{blocking factor} for the archive.
  6701. When reading or writing the archive, @command{tar}, will do reads and writes
  6702. of the archive in records of @math{@var{block}*512} bytes. This is true
  6703. even when the archive is compressed. Some devices requires that all
  6704. write operations be a multiple of a certain size, and so, @command{tar}
  6705. pads the archive out to the next record boundary.
  6706. The default blocking factor is set when @command{tar} is compiled, and is
  6707. typically 20. Blocking factors larger than 20 cannot be read by very
  6708. old versions of @command{tar}, or by some newer versions of @command{tar}
  6709. running on old machines with small address spaces.
  6710. With a magnetic tape, larger records give faster throughput and fit
  6711. more data on a tape (because there are fewer inter-record gaps).
  6712. If the archive is in a disk file or a pipe, you may want to specify
  6713. a smaller blocking factor, since a large one will result in a large
  6714. number of null bytes at the end of the archive.
  6715. When writing cartridge or other streaming tapes, a much larger
  6716. blocking factor (say 126 or more) will greatly increase performance.
  6717. However, you must specify the same blocking factor when reading or
  6718. updating the archive.
  6719. Apparently, Exabyte drives have a physical block size of 8K bytes.
  6720. If we choose our blocksize as a multiple of 8k bytes, then the problem
  6721. seems to disappear. Id est, we are using block size of 112 right
  6722. now, and we haven't had the problem since we switched@dots{}
  6723. With @GNUTAR{} the blocking factor is limited only
  6724. by the maximum record size of the device containing the archive, or by
  6725. the amount of available virtual memory.
  6726. However, deblocking or reblocking is virtually avoided in a special
  6727. case which often occurs in practice, but which requires all the
  6728. following conditions to be simultaneously true:
  6729. @itemize @bullet
  6730. @item
  6731. the archive is subject to a compression option,
  6732. @item
  6733. the archive is not handled through standard input or output, nor
  6734. redirected nor piped,
  6735. @item
  6736. the archive is directly handled to a local disk, instead of any special
  6737. device,
  6738. @item
  6739. @value{op-blocking-factor} is not explicitly specified on the @command{tar}
  6740. invocation.
  6741. @end itemize
  6742. If the output goes directly to a local disk, and not through
  6743. stdout, then the last write is not extended to a full record size.
  6744. Otherwise, reblocking occurs. Here are a few other remarks on this
  6745. topic:
  6746. @itemize @bullet
  6747. @item
  6748. @command{gzip} will complain about trailing garbage if asked to
  6749. uncompress a compressed archive on tape, there is an option to turn
  6750. the message off, but it breaks the regularity of simply having to use
  6751. @samp{@var{prog} -d} for decompression. It would be nice if gzip was
  6752. silently ignoring any number of trailing zeros. I'll ask Jean-loup
  6753. Gailly, by sending a copy of this message to him.
  6754. @item
  6755. @command{compress} does not show this problem, but as Jean-loup pointed
  6756. out to Michael, @samp{compress -d} silently adds garbage after
  6757. the result of decompression, which tar ignores because it already
  6758. recognized its end-of-file indicator. So this bug may be safely
  6759. ignored.
  6760. @item
  6761. @samp{gzip -d -q} will be silent about the trailing zeros indeed,
  6762. but will still return an exit status of 2 which tar reports in turn.
  6763. @command{tar} might ignore the exit status returned, but I hate doing
  6764. that, as it weakens the protection @command{tar} offers users against
  6765. other possible problems at decompression time. If @command{gzip} was
  6766. silently skipping trailing zeros @emph{and} also avoiding setting the
  6767. exit status in this innocuous case, that would solve this situation.
  6768. @item
  6769. @command{tar} should become more solid at not stopping to read a pipe at
  6770. the first null block encountered. This inelegantly breaks the pipe.
  6771. @command{tar} should rather drain the pipe out before exiting itself.
  6772. @end itemize
  6773. @item -i
  6774. @itemx --ignore-zeros
  6775. Ignore blocks of zeros in archive (means EOF).
  6776. The @value{op-ignore-zeros} option causes @command{tar} to ignore blocks
  6777. of zeros in the archive. Normally a block of zeros indicates the
  6778. end of the archive, but when reading a damaged archive, or one which
  6779. was created by concatenating several archives together, this option
  6780. allows @command{tar} to read the entire archive. This option is not on
  6781. by default because many versions of @command{tar} write garbage after
  6782. the zeroed blocks.
  6783. Note that this option causes @command{tar} to read to the end of the
  6784. archive file, which may sometimes avoid problems when multiple files
  6785. are stored on a single physical tape.
  6786. @item -B
  6787. @itemx --read-full-records
  6788. Reblock as we read (for reading 4.2BSD pipes).
  6789. If @value{op-read-full-records} is used, @command{tar} will not panic if an
  6790. attempt to read a record from the archive does not return a full record.
  6791. Instead, @command{tar} will keep reading until it has obtained a full
  6792. record.
  6793. This option is turned on by default when @command{tar} is reading
  6794. an archive from standard input, or from a remote machine. This is
  6795. because on BSD Unix systems, a read of a pipe will return however
  6796. much happens to be in the pipe, even if it is less than @command{tar}
  6797. requested. If this option was not used, @command{tar} would fail as
  6798. soon as it read an incomplete record from the pipe.
  6799. This option is also useful with the commands for updating an archive.
  6800. @end table
  6801. Tape blocking
  6802. @FIXME{Appropriate options should be moved here from elsewhere.}
  6803. @cindex blocking factor
  6804. @cindex tape blocking
  6805. When handling various tapes or cartridges, you have to take care of
  6806. selecting a proper blocking, that is, the number of disk blocks you
  6807. put together as a single tape block on the tape, without intervening
  6808. tape gaps. A @dfn{tape gap} is a small landing area on the tape
  6809. with no information on it, used for decelerating the tape to a
  6810. full stop, and for later regaining the reading or writing speed.
  6811. When the tape driver starts reading a record, the record has to
  6812. be read whole without stopping, as a tape gap is needed to stop the
  6813. tape motion without loosing information.
  6814. @cindex Exabyte blocking
  6815. @cindex DAT blocking
  6816. Using higher blocking (putting more disk blocks per tape block) will use
  6817. the tape more efficiently as there will be less tape gaps. But reading
  6818. such tapes may be more difficult for the system, as more memory will be
  6819. required to receive at once the whole record. Further, if there is a
  6820. reading error on a huge record, this is less likely that the system will
  6821. succeed in recovering the information. So, blocking should not be too
  6822. low, nor it should be too high. @command{tar} uses by default a blocking of
  6823. 20 for historical reasons, and it does not really matter when reading or
  6824. writing to disk. Current tape technology would easily accommodate higher
  6825. blockings. Sun recommends a blocking of 126 for Exabytes and 96 for DATs.
  6826. We were told that for some DLT drives, the blocking should be a multiple
  6827. of 4Kb, preferably 64Kb (@w{@kbd{-b 128}}) or 256 for decent performance.
  6828. Other manufacturers may use different recommendations for the same tapes.
  6829. This might also depends of the buffering techniques used inside modern
  6830. tape controllers. Some imposes a minimum blocking, or a maximum blocking.
  6831. Others request blocking to be some exponent of two.
  6832. So, there is no fixed rule for blocking. But blocking at read time
  6833. should ideally be the same as blocking used at write time. At one place
  6834. I know, with a wide variety of equipment, they found it best to use a
  6835. blocking of 32 to guarantee that their tapes are fully interchangeable.
  6836. I was also told that, for recycled tapes, prior erasure (by the same
  6837. drive unit that will be used to create the archives) sometimes lowers
  6838. the error rates observed at rewriting time.
  6839. I might also use @samp{--number-blocks} instead of
  6840. @samp{--block-number}, so @samp{--block} will then expand to
  6841. @samp{--blocking-factor} unambiguously.
  6842. @node Many
  6843. @section Many Archives on One Tape
  6844. @FIXME{Appropriate options should be moved here from elsewhere.}
  6845. @findex ntape @r{device}
  6846. Most tape devices have two entries in the @file{/dev} directory, or
  6847. entries that come in pairs, which differ only in the minor number for
  6848. this device. Let's take for example @file{/dev/tape}, which often
  6849. points to the only or usual tape device of a given system. There might
  6850. be a corresponding @file{/dev/nrtape} or @file{/dev/ntape}. The simpler
  6851. name is the @emph{rewinding} version of the device, while the name
  6852. having @samp{nr} in it is the @emph{no rewinding} version of the same
  6853. device.
  6854. A rewinding tape device will bring back the tape to its beginning point
  6855. automatically when this device is opened or closed. Since @command{tar}
  6856. opens the archive file before using it and closes it afterwards, this
  6857. means that a simple:
  6858. @smallexample
  6859. $ @kbd{tar cf /dev/tape @var{directory}}
  6860. @end smallexample
  6861. @noindent
  6862. will reposition the tape to its beginning both prior and after saving
  6863. @var{directory} contents to it, thus erasing prior tape contents and
  6864. making it so that any subsequent write operation will destroy what has
  6865. just been saved.
  6866. @cindex tape positioning
  6867. So, a rewinding device is normally meant to hold one and only one file.
  6868. If you want to put more than one @command{tar} archive on a given tape, you
  6869. will need to avoid using the rewinding version of the tape device. You
  6870. will also have to pay special attention to tape positioning. Errors in
  6871. positioning may overwrite the valuable data already on your tape. Many
  6872. people, burnt by past experiences, will only use rewinding devices and
  6873. limit themselves to one file per tape, precisely to avoid the risk of
  6874. such errors. Be fully aware that writing at the wrong position on a
  6875. tape loses all information past this point and most probably until the
  6876. end of the tape, and this destroyed information @emph{cannot} be
  6877. recovered.
  6878. To save @var{directory-1} as a first archive at the beginning of a
  6879. tape, and leave that tape ready for a second archive, you should use:
  6880. @smallexample
  6881. $ @kbd{mt -f /dev/nrtape rewind}
  6882. $ @kbd{tar cf /dev/nrtape @var{directory-1}}
  6883. @end smallexample
  6884. @cindex tape marks
  6885. @dfn{Tape marks} are special magnetic patterns written on the tape
  6886. media, which are later recognizable by the reading hardware. These
  6887. marks are used after each file, when there are many on a single tape.
  6888. An empty file (that is to say, two tape marks in a row) signal the
  6889. logical end of the tape, after which no file exist. Usually,
  6890. non-rewinding tape device drivers will react to the close request issued
  6891. by @command{tar} by first writing two tape marks after your archive, and by
  6892. backspacing over one of these. So, if you remove the tape at that time
  6893. from the tape drive, it is properly terminated. But if you write
  6894. another file at the current position, the second tape mark will be
  6895. erased by the new information, leaving only one tape mark between files.
  6896. So, you may now save @var{directory-2} as a second archive after the
  6897. first on the same tape by issuing the command:
  6898. @smallexample
  6899. $ @kbd{tar cf /dev/nrtape @var{directory-2}}
  6900. @end smallexample
  6901. @noindent
  6902. and so on for all the archives you want to put on the same tape.
  6903. Another usual case is that you do not write all the archives the same
  6904. day, and you need to remove and store the tape between two archive
  6905. sessions. In general, you must remember how many files are already
  6906. saved on your tape. Suppose your tape already has 16 files on it, and
  6907. that you are ready to write the 17th. You have to take care of skipping
  6908. the first 16 tape marks before saving @var{directory-17}, say, by using
  6909. these commands:
  6910. @smallexample
  6911. $ @kbd{mt -f /dev/nrtape rewind}
  6912. $ @kbd{mt -f /dev/nrtape fsf 16}
  6913. $ @kbd{tar cf /dev/nrtape @var{directory-17}}
  6914. @end smallexample
  6915. In all the previous examples, we put aside blocking considerations, but
  6916. you should do the proper things for that as well. @xref{Blocking}.
  6917. @menu
  6918. * Tape Positioning:: Tape Positions and Tape Marks
  6919. * mt:: The @command{mt} Utility
  6920. @end menu
  6921. @node Tape Positioning
  6922. @subsection Tape Positions and Tape Marks
  6923. @UNREVISED
  6924. Just as archives can store more than one file from the file system,
  6925. tapes can store more than one archive file. To keep track of where
  6926. archive files (or any other type of file stored on tape) begin and
  6927. end, tape archive devices write magnetic @dfn{tape marks} on the
  6928. archive media. Tape drives write one tape mark between files,
  6929. two at the end of all the file entries.
  6930. If you think of data as a series of records "rrrr"'s, and tape marks as
  6931. "*"'s, a tape might look like the following:
  6932. @smallexample
  6933. rrrr*rrrrrr*rrrrr*rr*rrrrr**-------------------------
  6934. @end smallexample
  6935. Tape devices read and write tapes using a read/write @dfn{tape
  6936. head}---a physical part of the device which can only access one
  6937. point on the tape at a time. When you use @command{tar} to read or
  6938. write archive data from a tape device, the device will begin reading
  6939. or writing from wherever on the tape the tape head happens to be,
  6940. regardless of which archive or what part of the archive the tape
  6941. head is on. Before writing an archive, you should make sure that no
  6942. data on the tape will be overwritten (unless it is no longer needed).
  6943. Before reading an archive, you should make sure the tape head is at
  6944. the beginning of the archive you want to read. (The @code{restore}
  6945. script will find the archive automatically. @FIXME-xref{Scripted Restoration}@xref{mt}, for
  6946. an explanation of the tape moving utility.
  6947. If you want to add new archive file entries to a tape, you should
  6948. advance the tape to the end of the existing file entries, backspace
  6949. over the last tape mark, and write the new archive file. If you were
  6950. to add two archives to the example above, the tape might look like the
  6951. following:
  6952. @smallexample
  6953. rrrr*rrrrrr*rrrrr*rr*rrrrr*rrr*rrrr**----------------
  6954. @end smallexample
  6955. @node mt
  6956. @subsection The @command{mt} Utility
  6957. @UNREVISED
  6958. @FIXME{Is it true that this only works on non-block devices?
  6959. should explain the difference, (fixed or variable).}
  6960. @value{xref-blocking-factor}.
  6961. You can use the @command{mt} utility to advance or rewind a tape past a
  6962. specified number of archive files on the tape. This will allow you
  6963. to move to the beginning of an archive before extracting or reading
  6964. it, or to the end of all the archives before writing a new one.
  6965. @FIXME{Why isn't there an "advance 'til you find two tape marks
  6966. together"?}
  6967. The syntax of the @command{mt} command is:
  6968. @smallexample
  6969. @kbd{mt [-f @var{tapename}] @var{operation} [@var{number}]}
  6970. @end smallexample
  6971. where @var{tapename} is the name of the tape device, @var{number} is
  6972. the number of times an operation is performed (with a default of one),
  6973. and @var{operation} is one of the following:
  6974. @FIXME{is there any use for record operations?}
  6975. @table @kbd
  6976. @item eof
  6977. @itemx weof
  6978. Writes @var{number} tape marks at the current position on the tape.
  6979. @item fsf
  6980. Moves tape position forward @var{number} files.
  6981. @item bsf
  6982. Moves tape position back @var{number} files.
  6983. @item rewind
  6984. Rewinds the tape. (Ignores @var{number}).
  6985. @item offline
  6986. @itemx rewoff1
  6987. Rewinds the tape and takes the tape device off-line. (Ignores @var{number}).
  6988. @item status
  6989. Prints status information about the tape unit.
  6990. @end table
  6991. @FIXME{Is there a better way to frob the spacing on the list?}
  6992. If you don't specify a @var{tapename}, @command{mt} uses the environment
  6993. variable @env{TAPE}; if @env{TAPE} is not set, @command{mt} uses the device
  6994. @file{/dev/rmt12}.
  6995. @command{mt} returns a 0 exit status when the operation(s) were
  6996. successful, 1 if the command was unrecognized, and 2 if an operation
  6997. failed.
  6998. @FIXME{New node on how to find an archive?}
  6999. If you use @value{op-extract} with the @value{op-label} option specified,
  7000. @command{tar} will read an archive label (the tape head has to be positioned
  7001. on it) and print an error if the archive label doesn't match the
  7002. @var{archive-name} specified. @var{archive-name} can be any regular
  7003. expression. If the labels match, @command{tar} extracts the archive.
  7004. @value{xref-label}.
  7005. @FIXME-xref{Matching Format Parameters}@FIXME{fix cross
  7006. references}@samp{tar --list --label} will cause @command{tar} to print the
  7007. label.
  7008. @FIXME{Program to list all the labels on a tape?}
  7009. @node Using Multiple Tapes
  7010. @section Using Multiple Tapes
  7011. @UNREVISED
  7012. Often you might want to write a large archive, one larger than will fit
  7013. on the actual tape you are using. In such a case, you can run multiple
  7014. @command{tar} commands, but this can be inconvenient, particularly if you
  7015. are using options like @value{op-exclude} or dumping entire filesystems.
  7016. Therefore, @command{tar} supports multiple tapes automatically.
  7017. Use @value{op-multi-volume} on the command line, and then @command{tar} will,
  7018. when it reaches the end of the tape, prompt for another tape, and
  7019. continue the archive. Each tape will have an independent archive, and
  7020. can be read without needing the other. (As an exception to this, the
  7021. file that @command{tar} was archiving when it ran out of tape will usually
  7022. be split between the two archives; in this case you need to extract from
  7023. the first archive, using @value{op-multi-volume}, and then put in the
  7024. second tape when prompted, so @command{tar} can restore both halves of the
  7025. file.)
  7026. @GNUTAR{} multi-volume archives do not use a truly
  7027. portable format. You need @GNUTAR{} at both end to
  7028. process them properly.
  7029. When prompting for a new tape, @command{tar} accepts any of the following
  7030. responses:
  7031. @table @kbd
  7032. @item ?
  7033. Request @command{tar} to explain possible responses
  7034. @item q
  7035. Request @command{tar} to exit immediately.
  7036. @item n @var{file name}
  7037. Request @command{tar} to write the next volume on the file @var{file name}.
  7038. @item !
  7039. Request @command{tar} to run a subshell.
  7040. @item y
  7041. Request @command{tar} to begin writing the next volume.
  7042. @end table
  7043. (You should only type @samp{y} after you have changed the tape;
  7044. otherwise @command{tar} will write over the volume it just finished.)
  7045. If you want more elaborate behavior than this, give @command{tar} the
  7046. @value{op-info-script} option. The file @var{script-name} is expected
  7047. to be a program (or shell script) to be run instead of the normal
  7048. prompting procedure. If the program fails, @command{tar} exits;
  7049. otherwise, @command{tar} begins writing the next volume. The behavior
  7050. of the
  7051. @samp{n} response to the normal tape-change prompt is not available
  7052. if you use @value{op-info-script}.
  7053. The method @command{tar} uses to detect end of tape is not perfect, and
  7054. fails on some operating systems or on some devices. You can use the
  7055. @value{op-tape-length} option if @command{tar} can't detect the end of the
  7056. tape itself. This option selects @value{op-multi-volume} automatically.
  7057. The @var{size} argument should then be the usable size of the tape.
  7058. But for many devices, and floppy disks in particular, this option is
  7059. never required for real, as far as we know.
  7060. The volume number used by @command{tar} in its tape-change prompt
  7061. can be changed; if you give the @value{op-volno-file} option, then
  7062. @var{file-of-number} should be an unexisting file to be created, or else,
  7063. a file already containing a decimal number. That number will be used
  7064. as the volume number of the first volume written. When @command{tar} is
  7065. finished, it will rewrite the file with the now-current volume number.
  7066. (This does not change the volume number written on a tape label, as
  7067. per @value{ref-label}, it @emph{only} affects the number used in
  7068. the prompt.)
  7069. If you want @command{tar} to cycle through a series of tape drives, then
  7070. you can use the @samp{n} response to the tape-change prompt. This is
  7071. error prone, however, and doesn't work at all with @value{op-info-script}.
  7072. Therefore, if you give @command{tar} multiple @value{op-file} options, then
  7073. the specified files will be used, in sequence, as the successive volumes
  7074. of the archive. Only when the first one in the sequence needs to be
  7075. used again will @command{tar} prompt for a tape change (or run the info
  7076. script).
  7077. Multi-volume archives
  7078. With @value{op-multi-volume}, @command{tar} will not abort when it cannot
  7079. read or write any more data. Instead, it will ask you to prepare a new
  7080. volume. If the archive is on a magnetic tape, you should change tapes
  7081. now; if the archive is on a floppy disk, you should change disks, etc.
  7082. Each volume of a multi-volume archive is an independent @command{tar}
  7083. archive, complete in itself. For example, you can list or extract any
  7084. volume alone; just don't specify @value{op-multi-volume}. However, if one
  7085. file in the archive is split across volumes, the only way to extract
  7086. it successfully is with a multi-volume extract command @samp{--extract
  7087. --multi-volume} (@samp{-xM}) starting on or before the volume where
  7088. the file begins.
  7089. For example, let's presume someone has two tape drives on a system
  7090. named @file{/dev/tape0} and @file{/dev/tape1}. For having @GNUTAR{}
  7091. to switch to the second drive when it needs to write the
  7092. second tape, and then back to the first tape, etc., just do either of:
  7093. @smallexample
  7094. $ @kbd{tar --create --multi-volume --file=/dev/tape0 --file=/dev/tape1 @var{files}}
  7095. $ @kbd{tar cMff /dev/tape0 /dev/tape1 @var{files}}
  7096. @end smallexample
  7097. @menu
  7098. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  7099. * Tape Files:: Tape Files
  7100. @end menu
  7101. @node Multi-Volume Archives
  7102. @subsection Archives Longer than One Tape or Disk
  7103. @cindex Multi-volume archives
  7104. @UNREVISED
  7105. To create an archive that is larger than will fit on a single unit of
  7106. the media, use the @value{op-multi-volume} option in conjunction with
  7107. the @value{op-create} option (@pxref{create}). A
  7108. @dfn{multi-volume} archive can be manipulated like any other archive
  7109. (provided the @value{op-multi-volume} option is specified), but is
  7110. stored on more than one tape or disk.
  7111. When you specify @value{op-multi-volume}, @command{tar} does not report an
  7112. error when it comes to the end of an archive volume (when reading), or
  7113. the end of the media (when writing). Instead, it prompts you to load
  7114. a new storage volume. If the archive is on a magnetic tape, you
  7115. should change tapes when you see the prompt; if the archive is on a
  7116. floppy disk, you should change disks; etc.
  7117. You can read each individual volume of a multi-volume archive as if it
  7118. were an archive by itself. For example, to list the contents of one
  7119. volume, use @value{op-list}, without @value{op-multi-volume} specified.
  7120. To extract an archive member from one volume (assuming it is described
  7121. that volume), use @value{op-extract}, again without
  7122. @value{op-multi-volume}.
  7123. If an archive member is split across volumes (ie. its entry begins on
  7124. one volume of the media and ends on another), you need to specify
  7125. @value{op-multi-volume} to extract it successfully. In this case, you
  7126. should load the volume where the archive member starts, and use
  7127. @samp{tar --extract --multi-volume}---@command{tar} will prompt for later
  7128. volumes as it needs them. @xref{extracting archives}, for more
  7129. information about extracting archives.
  7130. @value{op-info-script} is like @value{op-multi-volume}, except that
  7131. @command{tar} does not prompt you directly to change media volumes when
  7132. a volume is full---instead, @command{tar} runs commands you have stored
  7133. in @var{script-name}. For example, this option can be used to eject
  7134. cassettes, or to broadcast messages such as @samp{Someone please come
  7135. change my tape} when performing unattended backups. When @var{script-name}
  7136. is done, @command{tar} will assume that the media has been changed.
  7137. Multi-volume archives can be modified like any other archive. To add
  7138. files to a multi-volume archive, you need to only mount the last
  7139. volume of the archive media (and new volumes, if needed). For all
  7140. other operations, you need to use the entire archive.
  7141. If a multi-volume archive was labeled using @value{op-label}
  7142. (@value{pxref-label}) when it was created, @command{tar} will not
  7143. automatically label volumes which are added later. To label subsequent
  7144. volumes, specify @value{op-label} again in conjunction with the
  7145. @value{op-append}, @value{op-update} or @value{op-concatenate} operation.
  7146. @cindex Labeling multi-volume archives
  7147. @FIXME{example}
  7148. @FIXME{There should be a sample program here, including an exit
  7149. before end. Is the exit status even checked in tar? :-(}
  7150. @table @kbd
  7151. @item --multi-volume
  7152. @itemx -M
  7153. Creates a multi-volume archive, when used in conjunction with
  7154. @value{op-create}. To perform any other operation on a multi-volume
  7155. archive, specify @value{op-multi-volume} in conjunction with that
  7156. operation.
  7157. @item --info-script=@var{program-file}
  7158. @itemx -F @var{program-file}
  7159. Creates a multi-volume archive via a script. Used in conjunction with
  7160. @value{op-create}.
  7161. @end table
  7162. Beware that there is @emph{no} real standard about the proper way, for
  7163. a @command{tar} archive, to span volume boundaries. If you have a
  7164. multi-volume created by some vendor's @command{tar}, there is almost
  7165. no chance you could read all the volumes with @GNUTAR{}.
  7166. The converse is also true: you may not expect
  7167. multi-volume archives created by @GNUTAR{} to be
  7168. fully recovered by vendor's @command{tar}. Since there is little
  7169. chance that, in mixed system configurations, some vendor's
  7170. @command{tar} will work on another vendor's machine, and there is a
  7171. great chance that @GNUTAR{} will work on most of
  7172. them, your best bet is to install @GNUTAR{} on all
  7173. machines between which you know exchange of files is possible.
  7174. @node Tape Files
  7175. @subsection Tape Files
  7176. @UNREVISED
  7177. To give the archive a name which will be recorded in it, use the
  7178. @value{op-label} option. This will write a special block identifying
  7179. @var{volume-label} as the name of the archive to the front of the archive
  7180. which will be displayed when the archive is listed with @value{op-list}.
  7181. If you are creating a multi-volume archive with
  7182. @value{op-multi-volume}@FIXME-pxref{Using Multiple Tapes}, then the
  7183. volume label will have
  7184. @samp{Volume @var{nnn}} appended to the name you give, where @var{nnn} is
  7185. the number of the volume of the archive. (If you use the @value{op-label}
  7186. option when reading an archive, it checks to make sure the label on the
  7187. tape matches the one you give. @value{xref-label}.
  7188. When @command{tar} writes an archive to tape, it creates a single
  7189. tape file. If multiple archives are written to the same tape, one
  7190. after the other, they each get written as separate tape files. When
  7191. extracting, it is necessary to position the tape at the right place
  7192. before running @command{tar}. To do this, use the @command{mt} command.
  7193. For more information on the @command{mt} command and on the organization
  7194. of tapes into a sequence of tape files, see @ref{mt}.
  7195. People seem to often do:
  7196. @smallexample
  7197. @kbd{--label="@var{some-prefix} `date +@var{some-format}`"}
  7198. @end smallexample
  7199. or such, for pushing a common date in all volumes or an archive set.
  7200. @node label
  7201. @section Including a Label in the Archive
  7202. @cindex Labeling an archive
  7203. @cindex Labels on the archive media
  7204. @UNREVISED
  7205. @table @kbd
  7206. @item -V @var{name}
  7207. @itemx --label=@var{name}
  7208. Create archive with volume name @var{name}.
  7209. @end table
  7210. This option causes @command{tar} to write out a @dfn{volume header} at
  7211. the beginning of the archive. If @value{op-multi-volume} is used, each
  7212. volume of the archive will have a volume header of @samp{@var{name}
  7213. Volume @var{n}}, where @var{n} is 1 for the first volume, 2 for the
  7214. next, and so on.
  7215. @FIXME{Should the arg to --label be a quoted string?? No.}
  7216. To avoid problems caused by misplaced paper labels on the archive
  7217. media, you can include a @dfn{label} entry---an archive member which
  7218. contains the name of the archive---in the archive itself. Use the
  7219. @value{op-label} option in conjunction with the @value{op-create} operation
  7220. to include a label entry in the archive as it is being created.
  7221. If you create an archive using both @value{op-label} and
  7222. @value{op-multi-volume}, each volume of the archive will have an
  7223. archive label of the form @samp{@var{archive-label} Volume @var{n}},
  7224. where @var{n} is 1 for the first volume, 2 for the next, and so on.
  7225. @FIXME-xref{Multi-Volume Archives, for information on creating multiple
  7226. volume archives.}
  7227. If you list or extract an archive using @value{op-label}, @command{tar} will
  7228. print an error if the archive label doesn't match the @var{archive-label}
  7229. specified, and will then not list nor extract the archive. In those cases,
  7230. @var{archive-label} argument is interpreted as a globbing-style pattern
  7231. which must match the actual magnetic volume label. @xref{exclude}, for
  7232. a precise description of how match is attempted@footnote{Previous versions
  7233. of @command{tar} used full regular expression matching, or before that, only
  7234. exact string matching, instead of wildcard matchers. We decided for the
  7235. sake of simplicity to use a uniform matching device through @command{tar}.}.
  7236. If the switch @value{op-multi-volume} is being used, the volume label
  7237. matcher will also suffix @var{archive-label} by @w{@samp{ Volume [1-9]*}}
  7238. if the initial match fails, before giving up. Since the volume numbering
  7239. is automatically added in labels at creation time, it sounded logical to
  7240. equally help the user taking care of it when the archive is being read.
  7241. The @value{op-label} was once called @samp{--volume}, but is not available
  7242. under that name anymore.
  7243. To find out an archive's label entry (or to find out if an archive has
  7244. a label at all), use @samp{tar --list --verbose}. @command{tar} will
  7245. print the label first, and then print archive member information, as
  7246. in the example below:
  7247. @smallexample
  7248. $ @kbd{tar --verbose --list --file=iamanarchive}
  7249. V--------- 0 0 0 1992-03-07 12:01 iamalabel--Volume Header--
  7250. -rw-rw-rw- ringo user 40 1990-05-21 13:30 iamafilename
  7251. @end smallexample
  7252. @table @kbd
  7253. @item --label=@var{archive-label}
  7254. @itemx -V @var{archive-label}
  7255. Includes an @dfn{archive-label} at the beginning of the archive when
  7256. the archive is being created, when used in conjunction with the
  7257. @value{op-create} option. Checks to make sure the archive label
  7258. matches the one specified (when used in conjunction with the
  7259. @value{op-extract} option.
  7260. @end table
  7261. To get a common information on all tapes of a series, use the
  7262. @value{op-label} option. For having this information different in each
  7263. series created through a single script used on a regular basis, just
  7264. manage to get some date string as part of the label. For example:
  7265. @smallexample
  7266. $ @kbd{tar cfMV /dev/tape "Daily backup for `date +%Y-%m-%d`"}
  7267. $ @kbd{tar --create --file=/dev/tape --multi-volume \
  7268. --volume="Daily backup for `date +%Y-%m-%d`"}
  7269. @end smallexample
  7270. Also note that each label has its own date and time, which corresponds
  7271. to when @GNUTAR{} initially attempted to write it,
  7272. often soon after the operator launches @command{tar} or types the
  7273. carriage return telling that the next tape is ready. Comparing date
  7274. labels does give an idea of tape throughput only if the delays for
  7275. rewinding tapes and the operator switching them were negligible, which
  7276. is usually not the case.
  7277. @FIXME{was --volume}
  7278. @node verify
  7279. @section Verifying Data as It is Stored
  7280. @cindex Verifying a write operation
  7281. @cindex Double-checking a write operation
  7282. @table @kbd
  7283. @item -W
  7284. @itemx --verify
  7285. Attempt to verify the archive after writing.
  7286. @end table
  7287. This option causes @command{tar} to verify the archive after writing it.
  7288. Each volume is checked after it is written, and any discrepancies
  7289. are recorded on the standard error output.
  7290. Verification requires that the archive be on a back-space-able medium.
  7291. This means pipes, some cartridge tape drives, and some other devices
  7292. cannot be verified.
  7293. You can insure the accuracy of an archive by comparing files in the
  7294. system with archive members. @command{tar} can compare an archive to the
  7295. file system as the archive is being written, to verify a write
  7296. operation, or can compare a previously written archive, to insure that
  7297. it is up to date.
  7298. To check for discrepancies in an archive immediately after it is
  7299. written, use the @value{op-verify} option in conjunction with
  7300. the @value{op-create} operation. When this option is
  7301. specified, @command{tar} checks archive members against their counterparts
  7302. in the file system, and reports discrepancies on the standard error.
  7303. To verify an archive, you must be able to read it from before the end
  7304. of the last written entry. This option is useful for detecting data
  7305. errors on some tapes. Archives written to pipes, some cartridge tape
  7306. drives, and some other devices cannot be verified.
  7307. One can explicitly compare an already made archive with the file system
  7308. by using the @value{op-compare} option, instead of using the more automatic
  7309. @value{op-verify} option. @value{xref-compare}.
  7310. Note that these two options have a slightly different intent. The
  7311. @value{op-compare} option how identical are the logical contents of some
  7312. archive with what is on your disks, while the @value{op-verify} option is
  7313. really for checking if the physical contents agree and if the recording
  7314. media itself is of dependable quality. So, for the @value{op-verify}
  7315. operation, @command{tar} tries to defeat all in-memory cache pertaining to
  7316. the archive, while it lets the speed optimization undisturbed for the
  7317. @value{op-compare} option. If you nevertheless use @value{op-compare} for
  7318. media verification, you may have to defeat the in-memory cache yourself,
  7319. maybe by opening and reclosing the door latch of your recording unit,
  7320. forcing some doubt in your operating system about the fact this is really
  7321. the same volume as the one just written or read.
  7322. The @value{op-verify} option would not be necessary if drivers were indeed
  7323. able to detect dependably all write failures. This sometimes require many
  7324. magnetic heads, some able to read after the writes occurred. One would
  7325. not say that drivers unable to detect all cases are necessarily flawed,
  7326. as long as programming is concerned.
  7327. The @value{op-verify} option will not work in conjunction with the
  7328. @value{op-multi-volume} option or the @value{op-append},
  7329. @value{op-update} and @value{op-delete} operations. @xref{Operations},
  7330. for more information on these operations.
  7331. Also, since @command{tar} normally strips leading @samp{/} from file
  7332. names (@pxref{absolute}), a command like @samp{tar --verify -cf
  7333. /tmp/foo.tar /etc} will work as desired only if the working directory is
  7334. @file{/}, as @command{tar} uses the archive's relative member names
  7335. (e.g., @file{etc/motd}) when verifying the archive.
  7336. @node Write Protection
  7337. @section Write Protection
  7338. Almost all tapes and diskettes, and in a few rare cases, even disks can
  7339. be @dfn{write protected}, to protect data on them from being changed.
  7340. Once an archive is written, you should write protect the media to prevent
  7341. the archive from being accidentally overwritten or deleted. (This will
  7342. protect the archive from being changed with a tape or floppy drive---it
  7343. will not protect it from magnet fields or other physical hazards).
  7344. The write protection device itself is usually an integral part of the
  7345. physical media, and can be a two position (write enabled/write
  7346. disabled) switch, a notch which can be popped out or covered, a ring
  7347. which can be removed from the center of a tape reel, or some other
  7348. changeable feature.
  7349. @node Free Software Needs Free Documentation
  7350. @appendix Free Software Needs Free Documentation
  7351. @include freemanuals.texi
  7352. @node Copying This Manual
  7353. @appendix Copying This Manual
  7354. @menu
  7355. * GNU Free Documentation License:: License for copying this manual
  7356. @end menu
  7357. @include fdl.texi
  7358. @node Index
  7359. @appendix Index
  7360. @printindex cp
  7361. @summarycontents
  7362. @contents
  7363. @bye
  7364. @c Local variables:
  7365. @c texinfo-column-for-description: 32
  7366. @c End: