4
0

tar.texi 362 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454
  1. \input texinfo @c -*-texinfo-*-
  2. @comment %**start of header
  3. @setfilename tar.info
  4. @include version.texi
  5. @settitle GNU tar @value{VERSION}
  6. @setchapternewpage odd
  7. @finalout
  8. @smallbook
  9. @c %**end of header
  10. @include rendition.texi
  11. @include value.texi
  12. @c Put everything in one index (arbitrarily chosen to be the concept index).
  13. @syncodeindex fn cp
  14. @syncodeindex ky cp
  15. @syncodeindex pg cp
  16. @syncodeindex vr cp
  17. @defindex op
  18. @copying
  19. This manual is for @acronym{GNU} @command{tar} (version
  20. @value{VERSION}, @value{UPDATED}), which creates and extracts files
  21. from archives.
  22. Copyright @copyright{} 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2001,
  23. 2003, 2004 Free Software Foundation, Inc.
  24. @quotation
  25. Permission is granted to copy, distribute and/or modify this document
  26. under the terms of the GNU Free Documentation License, Version 1.1 or
  27. any later version published by the Free Software Foundation; with the
  28. Invariant Sections being "GNU General Public License", with the
  29. Front-Cover Texts being ``A GNU Manual,'' and with the Back-Cover Texts
  30. as in (a) below. A copy of the license is included in the section
  31. entitled "GNU Free Documentation License".
  32. (a) The FSF's Back-Cover Text is: ``You are free to copy and modify
  33. this GNU Manual. Buying copies from GNU Press supports the FSF in
  34. developing GNU and promoting software freedom.''
  35. @end quotation
  36. @end copying
  37. @dircategory Archiving
  38. @direntry
  39. * Tar: (tar). Making tape (or disk) archives.
  40. @end direntry
  41. @dircategory Individual utilities
  42. @direntry
  43. * tar: (tar)tar invocation. Invoking @GNUTAR{}.
  44. @end direntry
  45. @shorttitlepage @acronym{GNU} @command{tar}
  46. @titlepage
  47. @title @acronym{GNU} tar: an archiver tool
  48. @subtitle @value{RENDITION} @value{VERSION}, @value{UPDATED}
  49. @author John Gilmore, Jay Fenlason et al.
  50. @page
  51. @vskip 0pt plus 1filll
  52. @insertcopying
  53. @end titlepage
  54. @ifnottex
  55. @node Top
  56. @top @acronym{GNU} tar: an archiver tool
  57. @insertcopying
  58. @cindex file archival
  59. @cindex archiving files
  60. The first part of this master menu lists the major nodes in this Info
  61. document. The rest of the menu lists all the lower level nodes.
  62. @end ifnottex
  63. @c The master menu, created with texinfo-master-menu, goes here.
  64. @c (However, getdate.texi's menu is interpolated by hand.)
  65. @menu
  66. * Introduction::
  67. * Tutorial::
  68. * tar invocation::
  69. * operations::
  70. * Backups::
  71. * Choosing::
  72. * Date input formats::
  73. * Formats::
  74. * Media::
  75. Appendices
  76. * Genfile::
  77. * Snapshot Files::
  78. * Free Software Needs Free Documentation::
  79. * Copying This Manual::
  80. * Index of Command Line Options::
  81. * Index::
  82. @detailmenu
  83. --- The Detailed Node Listing ---
  84. Introduction
  85. * Book Contents:: What this Book Contains
  86. * Definitions:: Some Definitions
  87. * What tar Does:: What @command{tar} Does
  88. * Naming tar Archives:: How @command{tar} Archives are Named
  89. * Current status:: Current development status of @GNUTAR{}
  90. * Authors:: @GNUTAR{} Authors
  91. * Reports:: Reporting bugs or suggestions
  92. Tutorial Introduction to @command{tar}
  93. * assumptions::
  94. * stylistic conventions::
  95. * basic tar options:: Basic @command{tar} Operations and Options
  96. * frequent operations::
  97. * Two Frequent Options::
  98. * create:: How to Create Archives
  99. * list:: How to List Archives
  100. * extract:: How to Extract Members from an Archive
  101. * going further::
  102. Two Frequently Used Options
  103. * file tutorial::
  104. * verbose tutorial::
  105. * help tutorial::
  106. How to Create Archives
  107. * prepare for examples::
  108. * Creating the archive::
  109. * create verbose::
  110. * short create::
  111. * create dir::
  112. How to List Archives
  113. * list dir::
  114. How to Extract Members from an Archive
  115. * extracting archives::
  116. * extracting files::
  117. * extract dir::
  118. * failing commands::
  119. Invoking @GNUTAR{}
  120. * Synopsis::
  121. * using tar options::
  122. * Styles::
  123. * All Options::
  124. * help::
  125. * defaults::
  126. * verbose::
  127. * interactive::
  128. The Three Option Styles
  129. * Mnemonic Options:: Mnemonic Option Style
  130. * Short Options:: Short Option Style
  131. * Old Options:: Old Option Style
  132. * Mixing:: Mixing Option Styles
  133. All @command{tar} Options
  134. * Operation Summary::
  135. * Option Summary::
  136. * Short Option Summary::
  137. @GNUTAR{} Operations
  138. * Basic tar::
  139. * Advanced tar::
  140. * create options::
  141. * extract options::
  142. * backup::
  143. * Applications::
  144. * looking ahead::
  145. Advanced @GNUTAR{} Operations
  146. * Operations::
  147. * append::
  148. * update::
  149. * concatenate::
  150. * delete::
  151. * compare::
  152. How to Add Files to Existing Archives: @option{--append}
  153. * appending files:: Appending Files to an Archive
  154. * multiple::
  155. Updating an Archive
  156. * how to update::
  157. Options Used by @option{--create}
  158. * Ignore Failed Read::
  159. Options Used by @option{--extract}
  160. * Reading:: Options to Help Read Archives
  161. * Writing:: Changing How @command{tar} Writes Files
  162. * Scarce:: Coping with Scarce Resources
  163. Options to Help Read Archives
  164. * read full records::
  165. * Ignore Zeros::
  166. Changing How @command{tar} Writes Files
  167. * Dealing with Old Files::
  168. * Overwrite Old Files::
  169. * Keep Old Files::
  170. * Keep Newer Files::
  171. * Unlink First::
  172. * Recursive Unlink::
  173. * Data Modification Times::
  174. * Setting Access Permissions::
  175. * Writing to Standard Output::
  176. * remove files::
  177. Coping with Scarce Resources
  178. * Starting File::
  179. * Same Order::
  180. Performing Backups and Restoring Files
  181. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  182. * Incremental Dumps:: Using @command{tar} to Perform Incremental Dumps
  183. * Backup Levels:: Levels of Backups
  184. * Backup Parameters:: Setting Parameters for Backups and Restoration
  185. * Scripted Backups:: Using the Backup Scripts
  186. * Scripted Restoration:: Using the Restore Script
  187. Setting Parameters for Backups and Restoration
  188. * General-Purpose Variables::
  189. * Magnetic Tape Control::
  190. * User Hooks::
  191. * backup-specs example:: An Example Text of @file{Backup-specs}
  192. Choosing Files and Names for @command{tar}
  193. * file:: Choosing the Archive's Name
  194. * Selecting Archive Members::
  195. * files:: Reading Names from a File
  196. * exclude:: Excluding Some Files
  197. * Wildcards::
  198. * after:: Operating Only on New Files
  199. * recurse:: Descending into Directories
  200. * one:: Crossing File System Boundaries
  201. Reading Names from a File
  202. * nul::
  203. Excluding Some Files
  204. * controlling pattern-matching with exclude::
  205. * problems with exclude::
  206. Crossing File System Boundaries
  207. * directory:: Changing Directory
  208. * absolute:: Absolute File Names
  209. Date input formats
  210. * General date syntax:: Common rules.
  211. * Calendar date items:: 19 Dec 1994.
  212. * Time of day items:: 9:20pm.
  213. * Time zone items:: @sc{est}, @sc{pdt}, @sc{gmt}, ...
  214. * Day of week items:: Monday and others.
  215. * Relative items in date strings:: next tuesday, 2 years ago.
  216. * Pure numbers in date strings:: 19931219, 1440.
  217. * Seconds since the Epoch:: @@1078100502.
  218. * Authors of get_date:: Bellovin, Eggert, Salz, Berets, et al.
  219. Controlling the Archive Format
  220. * Portability:: Making @command{tar} Archives More Portable
  221. * Compression:: Using Less Space through Compression
  222. * Attributes:: Handling File Attributes
  223. * Standard:: The Standard Format
  224. * Extensions:: @acronym{GNU} Extensions to the Archive Format
  225. * cpio:: Comparison of @command{tar} and @command{cpio}
  226. Making @command{tar} Archives More Portable
  227. * Portable Names:: Portable Names
  228. * dereference:: Symbolic Links
  229. * old:: Old V7 Archives
  230. * posix:: @acronym{POSIX} archives
  231. * Checksumming:: Checksumming Problems
  232. * Large or Negative Values:: Large files, negative time stamps, etc.
  233. Using Less Space through Compression
  234. * gzip:: Creating and Reading Compressed Archives
  235. * sparse:: Archiving Sparse Files
  236. Tapes and Other Archive Media
  237. * Device:: Device selection and switching
  238. * Remote Tape Server::
  239. * Common Problems and Solutions::
  240. * Blocking:: Blocking
  241. * Many:: Many archives on one tape
  242. * Using Multiple Tapes:: Using Multiple Tapes
  243. * label:: Including a Label in the Archive
  244. * verify::
  245. * Write Protection::
  246. Blocking
  247. * Format Variations:: Format Variations
  248. * Blocking Factor:: The Blocking Factor of an Archive
  249. Many Archives on One Tape
  250. * Tape Positioning:: Tape Positions and Tape Marks
  251. * mt:: The @command{mt} Utility
  252. Using Multiple Tapes
  253. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  254. * Tape Files:: Tape Files
  255. * Tarcat:: Concatenate Volumes into a Single Archive
  256. GNU tar internals and development
  257. * Genfile::
  258. * Snapshot Files::
  259. Copying This Manual
  260. * GNU Free Documentation License:: License for copying this manual
  261. @end detailmenu
  262. @end menu
  263. @node Introduction
  264. @chapter Introduction
  265. @GNUTAR{} creates
  266. and manipulates @dfn{archives} which are actually collections of
  267. many other files; the program provides users with an organized and
  268. systematic method for controlling a large amount of data.
  269. The name ``tar'' originally came from the phrase ``Tape ARchive'', but
  270. archives need not (and these days, typically do not) reside on tapes.
  271. @menu
  272. * Book Contents:: What this Book Contains
  273. * Definitions:: Some Definitions
  274. * What tar Does:: What @command{tar} Does
  275. * Naming tar Archives:: How @command{tar} Archives are Named
  276. * Current status:: Current development status of @GNUTAR{}
  277. * Authors:: @GNUTAR{} Authors
  278. * Reports:: Reporting bugs or suggestions
  279. @end menu
  280. @node Book Contents
  281. @section What this Book Contains
  282. The first part of this chapter introduces you to various terms that will
  283. recur throughout the book. It also tells you who has worked on @GNUTAR{}
  284. and its documentation, and where you should send bug reports
  285. or comments.
  286. The second chapter is a tutorial (@pxref{Tutorial}) which provides a
  287. gentle introduction for people who are new to using @command{tar}. It is
  288. meant to be self contained, not requiring any reading from subsequent
  289. chapters to make sense. It moves from topic to topic in a logical,
  290. progressive order, building on information already explained.
  291. Although the tutorial is paced and structured to allow beginners to
  292. learn how to use @command{tar}, it is not intended solely for beginners.
  293. The tutorial explains how to use the three most frequently used
  294. operations (@samp{create}, @samp{list}, and @samp{extract}) as well as
  295. two frequently used options (@samp{file} and @samp{verbose}). The other
  296. chapters do not refer to the tutorial frequently; however, if a section
  297. discusses something which is a complex variant of a basic concept, there
  298. may be a cross reference to that basic concept. (The entire book,
  299. including the tutorial, assumes that the reader understands some basic
  300. concepts of using a Unix-type operating system; @pxref{Tutorial}.)
  301. The third chapter presents the remaining five operations, and
  302. information about using @command{tar} options and option syntax.
  303. @FIXME{this sounds more like a @acronym{GNU} Project Manuals Concept [tm] more
  304. than the reality. should think about whether this makes sense to say
  305. here, or not.} The other chapters are meant to be used as a
  306. reference. Each chapter presents everything that needs to be said
  307. about a specific topic.
  308. One of the chapters (@pxref{Date input formats}) exists in its
  309. entirety in other @acronym{GNU} manuals, and is mostly self-contained.
  310. In addition, one section of this manual (@pxref{Standard}) contains a
  311. big quote which is taken directly from @command{tar} sources.
  312. In general, we give both long and short (abbreviated) option names
  313. at least once in each section where the relevant option is covered, so
  314. that novice readers will become familiar with both styles. (A few
  315. options have no short versions, and the relevant sections will
  316. indicate this.)
  317. @node Definitions
  318. @section Some Definitions
  319. @cindex archive
  320. @cindex tar archive
  321. The @command{tar} program is used to create and manipulate @command{tar}
  322. archives. An @dfn{archive} is a single file which contains the contents
  323. of many files, while still identifying the names of the files, their
  324. owner(s), and so forth. (In addition, archives record access
  325. permissions, user and group, size in bytes, and data modification time.
  326. Some archives also record the file names in each archived directory, as
  327. well as other file and directory information.) You can use @command{tar}
  328. to @dfn{create} a new archive in a specified directory.
  329. @cindex member
  330. @cindex archive member
  331. @cindex file name
  332. @cindex member name
  333. The files inside an archive are called @dfn{members}. Within this
  334. manual, we use the term @dfn{file} to refer only to files accessible in
  335. the normal ways (by @command{ls}, @command{cat}, and so forth), and the term
  336. @dfn{member} to refer only to the members of an archive. Similarly, a
  337. @dfn{file name} is the name of a file, as it resides in the file system,
  338. and a @dfn{member name} is the name of an archive member within the
  339. archive.
  340. @cindex extraction
  341. @cindex unpacking
  342. The term @dfn{extraction} refers to the process of copying an archive
  343. member (or multiple members) into a file in the file system. Extracting
  344. all the members of an archive is often called @dfn{extracting the
  345. archive}. The term @dfn{unpack} can also be used to refer to the
  346. extraction of many or all the members of an archive. Extracting an
  347. archive does not destroy the archive's structure, just as creating an
  348. archive does not destroy the copies of the files that exist outside of
  349. the archive. You may also @dfn{list} the members in a given archive
  350. (this is often thought of as ``printing'' them to the standard output,
  351. or the command line), or @dfn{append} members to a pre-existing archive.
  352. All of these operations can be performed using @command{tar}.
  353. @node What tar Does
  354. @section What @command{tar} Does
  355. @cindex tar
  356. The @command{tar} program provides the ability to create @command{tar}
  357. archives, as well as various other kinds of manipulation. For example,
  358. you can use @command{tar} on previously created archives to extract files,
  359. to store additional files, or to update or list files which were already
  360. stored.
  361. Initially, @command{tar} archives were used to store files conveniently on
  362. magnetic tape. The name @command{tar} comes from this use; it stands for
  363. @code{t}ape @code{ar}chiver. Despite the utility's name, @command{tar} can
  364. direct its output to available devices, files, or other programs (using
  365. pipes). @command{tar} may even access remote devices or files (as archives).
  366. @FIXME{the following table entries need a bit of work..}
  367. You can use @command{tar} archives in many ways. We want to stress a few
  368. of them: storage, backup, and transportation.
  369. @table @asis
  370. @item Storage
  371. Often, @command{tar} archives are used to store related files for
  372. convenient file transfer over a network. For example, the
  373. @acronym{GNU} Project distributes its software bundled into
  374. @command{tar} archives, so that all the files relating to a particular
  375. program (or set of related programs) can be transferred as a single
  376. unit.
  377. A magnetic tape can store several files in sequence. However, the tape
  378. has no names for these files; it only knows their relative position on
  379. the tape. One way to store several files on one tape and retain their
  380. names is by creating a @command{tar} archive. Even when the basic transfer
  381. mechanism can keep track of names, as FTP can, the nuisance of handling
  382. multiple files, directories, and multiple links makes @command{tar}
  383. archives useful.
  384. Archive files are also used for long-term storage. You can think of
  385. this as transportation from the present into the future. (It is a
  386. science-fiction idiom that you can move through time as well as in
  387. space; the idea here is that @command{tar} can be used to move archives in
  388. all dimensions, even time!)
  389. @item Backup
  390. Because the archive created by @command{tar} is capable of preserving
  391. file information and directory structure, @command{tar} is commonly
  392. used for performing full and incremental backups of disks. A backup
  393. puts a collection of files (possibly pertaining to many users and
  394. projects) together on a disk or a tape. This guards against
  395. accidental destruction of the information in those files.
  396. @GNUTAR{} has special features that allow it to be
  397. used to make incremental and full dumps of all the files in a
  398. file system.
  399. @item Transportation
  400. You can create an archive on one system, transfer it to another system,
  401. and extract the contents there. This allows you to transport a group of
  402. files from one system to another.
  403. @end table
  404. @node Naming tar Archives
  405. @section How @command{tar} Archives are Named
  406. Conventionally, @command{tar} archives are given names ending with
  407. @samp{.tar}. This is not necessary for @command{tar} to operate properly,
  408. but this manual follows that convention in order to accustom readers to
  409. it and to make examples more clear.
  410. @cindex tar file
  411. @cindex entry
  412. @cindex tar entry
  413. Often, people refer to @command{tar} archives as ``@command{tar} files,'' and
  414. archive members as ``files'' or ``entries''. For people familiar with
  415. the operation of @command{tar}, this causes no difficulty. However, in
  416. this manual, we consistently refer to ``archives'' and ``archive
  417. members'' to make learning to use @command{tar} easier for novice users.
  418. @node Current status
  419. @section Current development status of @GNUTAR{}
  420. @GNUTAR{} is currently in the process of active development, whose
  421. primary aims are:
  422. @itemize @bullet
  423. @item Improve compatibility between @GNUTAR{} and other @command{tar}
  424. implementations.
  425. @item Switch to using @acronym{POSIX} archives.
  426. @item Revise sparse file handling and multiple volume processing.
  427. @item Merge with the @acronym{GNU} @code{paxutils} project.
  428. @end itemize
  429. Some of these aims are already attained, while others are still
  430. being worked upon. From the point of view of an end user, the
  431. following issues need special mentioning:
  432. @table @asis
  433. @item Use of short option @option{-o}.
  434. Earlier versions of @GNUTAR{} understood @option{-o} command line
  435. option as a synonym for @option{--old-archive}.
  436. @GNUTAR{} starting from version 1.13.90 understands this option as
  437. a synonym for @option{--no-same-owner}. This is compatible with
  438. UNIX98 @command{tar} implementations.
  439. However, to facilitate transition, @option{-o} option retains its
  440. old semantics when it is used with one of archive-creation commands.
  441. Users are encouraged to use @option{--format=oldgnu} instead.
  442. It is especially important, since versions of @acronym{GNU} Automake
  443. up to and including 1.8.4 invoke tar with this option to produce
  444. distribution tarballs. @xref{Formats,v7}, for the detailed discussion
  445. of this issue and its implications.
  446. Future versions of @GNUTAR{} will understand @option{-o} only as a
  447. synonym for @option{--no-same-owner}.
  448. @item Use of short option @option{-l}
  449. Earlier versions of @GNUTAR{} understood @option{-l} option as a
  450. synonym for @option{--one-file-system}. Such usage is deprecated.
  451. For compatibility with other implementations future versions of
  452. @GNUTAR{} will understand this option as a synonym for
  453. @option{--check-links}.
  454. @item Use of options @option{--portability} and @option{--old-archive}
  455. These options are deprecated. Please use @option{--format=v7} instead.
  456. @item Use of option @option{--posix}
  457. This option is deprecated. Please use @option{--format=posix} instead.
  458. @end table
  459. @node Authors
  460. @section @GNUTAR{} Authors
  461. @GNUTAR{} was originally written by John Gilmore,
  462. and modified by many people. The @acronym{GNU} enhancements were
  463. written by Jay Fenlason, then Joy Kendall, and the whole package has
  464. been further maintained by Thomas Bushnell, n/BSG, Fran@,{c}ois
  465. Pinard, Paul Eggert, and finally Sergey Poznyakoff with the help of
  466. numerous and kind users.
  467. We wish to stress that @command{tar} is a collective work, and owes much to
  468. all those people who reported problems, offered solutions and other
  469. insights, or shared their thoughts and suggestions. An impressive, yet
  470. partial list of those contributors can be found in the @file{THANKS}
  471. file from the @GNUTAR{} distribution.
  472. @FIXME{i want all of these names mentioned, Absolutely. BUT, i'm not
  473. sure i want to spell out the history in this detail, at least not for
  474. the printed book. i'm just not sure it needs to be said this way.
  475. i'll think about it.}
  476. @FIXME{History is more important, and surely more interesting, than
  477. actual names. Quoting names without history would be meaningless. FP}
  478. Jay Fenlason put together a draft of a @GNUTAR{}
  479. manual, borrowing notes from the original man page from John Gilmore.
  480. This was withdrawn in version 1.11. Thomas Bushnell, n/BSG and Amy
  481. Gorin worked on a tutorial and manual for @GNUTAR{}.
  482. Fran@,{c}ois Pinard put version 1.11.8 of the manual together by
  483. taking information from all these sources and merging them. Melissa
  484. Weisshaus finally edited and redesigned the book to create version
  485. 1.12. @FIXME{update version number as necessary; i'm being
  486. optimistic!} @FIXME{Someone [maybe karl berry? maybe bob chassell?
  487. maybe melissa? maybe julie sussman?] needs to properly index the
  488. thing.}
  489. For version 1.12, Daniel Hagerty contributed a great deal of technical
  490. consulting. In particular, he is the primary author of @ref{Backups}.
  491. In July, 2003 @GNUTAR{} was put on CVS at savannah.gnu.org
  492. (see @url{http://savannah.gnu.org/projects/tar}), and
  493. active development and maintenance work has started
  494. again. Currently @GNUTAR{} is being maintained by Paul Eggert, Sergey
  495. Poznyakoff and Jeff Bailey.
  496. Support for @acronym{POSIX} archives was added by Sergey Poznyakoff.
  497. @node Reports
  498. @section Reporting bugs or suggestions
  499. @cindex bug reports
  500. @cindex reporting bugs
  501. If you find problems or have suggestions about this program or manual,
  502. please report them to @file{bug-tar@@gnu.org}.
  503. When reporting a bug, please be sure to include as much detail as
  504. possible, in order to reproduce it. @FIXME{Be more specific, I'd
  505. like to make this node as detailed as 'Bug reporting' node in Emacs
  506. manual}.
  507. @node Tutorial
  508. @chapter Tutorial Introduction to @command{tar}
  509. This chapter guides you through some basic examples of three @command{tar}
  510. operations: @option{--create}, @option{--list}, and @option{--extract}. If
  511. you already know how to use some other version of @command{tar}, then you
  512. may not need to read this chapter. This chapter omits most complicated
  513. details about how @command{tar} works.
  514. @menu
  515. * assumptions::
  516. * stylistic conventions::
  517. * basic tar options:: Basic @command{tar} Operations and Options
  518. * frequent operations::
  519. * Two Frequent Options::
  520. * create:: How to Create Archives
  521. * list:: How to List Archives
  522. * extract:: How to Extract Members from an Archive
  523. * going further::
  524. @end menu
  525. @node assumptions
  526. @section Assumptions this Tutorial Makes
  527. This chapter is paced to allow beginners to learn about @command{tar}
  528. slowly. At the same time, we will try to cover all the basic aspects of
  529. these three operations. In order to accomplish both of these tasks, we
  530. have made certain assumptions about your knowledge before reading this
  531. manual, and the hardware you will be using:
  532. @itemize @bullet
  533. @item
  534. Before you start to work through this tutorial, you should understand
  535. what the terms ``archive'' and ``archive member'' mean
  536. (@pxref{Definitions}). In addition, you should understand something
  537. about how Unix-type operating systems work, and you should know how to
  538. use some basic utilities. For example, you should know how to create,
  539. list, copy, rename, edit, and delete files and directories; how to
  540. change between directories; and how to figure out where you are in the
  541. file system. You should have some basic understanding of directory
  542. structure and how files are named according to which directory they are
  543. in. You should understand concepts such as standard output and standard
  544. input, what various definitions of the term ``argument'' mean, and the
  545. differences between relative and absolute path names. @FIXME{and what
  546. else?}
  547. @item
  548. This manual assumes that you are working from your own home directory
  549. (unless we state otherwise). In this tutorial, you will create a
  550. directory to practice @command{tar} commands in. When we show path names,
  551. we will assume that those paths are relative to your home directory.
  552. For example, my home directory path is @file{/home/fsf/melissa}. All of
  553. my examples are in a subdirectory of the directory named by that path
  554. name; the subdirectory is called @file{practice}.
  555. @item
  556. In general, we show examples of archives which exist on (or can be
  557. written to, or worked with from) a directory on a hard disk. In most
  558. cases, you could write those archives to, or work with them on any other
  559. device, such as a tape drive. However, some of the later examples in
  560. the tutorial and next chapter will not work on tape drives.
  561. Additionally, working with tapes is much more complicated than working
  562. with hard disks. For these reasons, the tutorial does not cover working
  563. with tape drives. @xref{Media}, for complete information on using
  564. @command{tar} archives with tape drives.
  565. @FIXME{this is a cop out. need to add some simple tape drive info.}
  566. @end itemize
  567. @node stylistic conventions
  568. @section Stylistic Conventions
  569. In the examples, @samp{$} represents a typical shell prompt. It
  570. precedes lines you should type; to make this more clear, those lines are
  571. shown in @kbd{this font}, as opposed to lines which represent the
  572. computer's response; those lines are shown in @code{this font}, or
  573. sometimes @samp{like this}.
  574. @c When we have lines which are too long to be
  575. @c displayed in any other way, we will show them like this:
  576. @node basic tar options
  577. @section Basic @command{tar} Operations and Options
  578. @command{tar} can take a wide variety of arguments which specify and define
  579. the actions it will have on the particular set of files or the archive.
  580. The main types of arguments to @command{tar} fall into one of two classes:
  581. operations, and options.
  582. Some arguments fall into a class called @dfn{operations}; exactly one of
  583. these is both allowed and required for any instance of using @command{tar};
  584. you may @emph{not} specify more than one. People sometimes speak of
  585. @dfn{operating modes}. You are in a particular operating mode when you
  586. have specified the operation which specifies it; there are eight
  587. operations in total, and thus there are eight operating modes.
  588. The other arguments fall into the class known as @dfn{options}. You are
  589. not required to specify any options, and you are allowed to specify more
  590. than one at a time (depending on the way you are using @command{tar} at
  591. that time). Some options are used so frequently, and are so useful for
  592. helping you type commands more carefully that they are effectively
  593. ``required''. We will discuss them in this chapter.
  594. You can write most of the @command{tar} operations and options in any
  595. of three forms: long (mnemonic) form, short form, and old style. Some
  596. of the operations and options have no short or ``old'' forms; however,
  597. the operations and options which we will cover in this tutorial have
  598. corresponding abbreviations. @FIXME{make sure this is still the case,
  599. at the end}We will indicate those abbreviations appropriately to get
  600. you used to seeing them. (Note that the ``old style'' option forms
  601. exist in @GNUTAR{} for compatibility with Unix
  602. @command{tar}. In this book we present a full discussion of this way
  603. of writing options and operations (@pxref{Old Options}), and we discuss
  604. the other two styles of writing options (@xref{Mnemonic Options}, and
  605. @pxref{Short Options}).
  606. In the examples and in the text of this tutorial, we usually use the
  607. long forms of operations and options; but the ``short'' forms produce
  608. the same result and can make typing long @command{tar} commands easier.
  609. For example, instead of typing
  610. @smallexample
  611. @kbd{tar --create --verbose --file=afiles.tar apple angst aspic}
  612. @end smallexample
  613. @noindent
  614. you can type
  615. @smallexample
  616. @kbd{tar -c -v -f afiles.tar apple angst aspic}
  617. @end smallexample
  618. @noindent
  619. or even
  620. @smallexample
  621. @kbd{tar -cvf afiles.tar apple angst aspic}
  622. @end smallexample
  623. @noindent
  624. For more information on option syntax, see @ref{Advanced tar}. In
  625. discussions in the text, when we name an option by its long form, we
  626. also give the corresponding short option in parentheses.
  627. The term, ``option'', can be confusing at times, since ``operations''
  628. are often lumped in with the actual, @emph{optional} ``options'' in certain
  629. general class statements. For example, we just talked about ``short and
  630. long forms of options and operations''. However, experienced @command{tar}
  631. users often refer to these by shorthand terms such as, ``short and long
  632. options''. This term assumes that the ``operations'' are included, also.
  633. Context will help you determine which definition of ``options'' to use.
  634. Similarly, the term ``command'' can be confusing, as it is often used in
  635. two different ways. People sometimes refer to @command{tar} ``commands''.
  636. A @command{tar} @dfn{command} is the entire command line of user input
  637. which tells @command{tar} what to do --- including the operation, options,
  638. and any arguments (file names, pipes, other commands, etc). However,
  639. you will also sometimes hear the term ``the @command{tar} command''. When
  640. the word ``command'' is used specifically like this, a person is usually
  641. referring to the @command{tar} @emph{operation}, not the whole line.
  642. Again, use context to figure out which of the meanings the speaker
  643. intends.
  644. @node frequent operations
  645. @section The Three Most Frequently Used Operations
  646. Here are the three most frequently used operations (both short and long
  647. forms), as well as a brief description of their meanings. The rest of
  648. this chapter will cover how to use these operations in detail. We will
  649. present the rest of the operations in the next chapter.
  650. @table @option
  651. @item --create
  652. @itemx -c
  653. Create a new @command{tar} archive.
  654. @item --list
  655. @itemx -t
  656. List the contents of an archive.
  657. @item --extract
  658. @itemx -x
  659. Extract one or more members from an archive.
  660. @end table
  661. @node Two Frequent Options
  662. @section Two Frequently Used Options
  663. To understand how to run @command{tar} in the three operating modes listed
  664. previously, you also need to understand how to use two of the options to
  665. @command{tar}: @option{--file} (which takes an archive file as an argument)
  666. and @option{--verbose}. (You are usually not @emph{required} to specify
  667. either of these options when you run @command{tar}, but they can be very
  668. useful in making things more clear and helping you avoid errors.)
  669. @menu
  670. * file tutorial::
  671. * verbose tutorial::
  672. * help tutorial::
  673. @end menu
  674. @node file tutorial
  675. @unnumberedsubsec The @option{--file} Option
  676. @table @option
  677. @opindex file, tutorial
  678. @item --file=@var{archive-name}
  679. @itemx -f @var{archive-name}
  680. Specify the name of an archive file.
  681. @end table
  682. You can specify an argument for the @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) option whenever you
  683. use @command{tar}; this option determines the name of the archive file
  684. that @command{tar} will work on.
  685. @vrindex TAPE
  686. If you don't specify this argument, then @command{tar} will examine
  687. the environment variable @env{TAPE}. If it is set, its value will be
  688. used as the archive name. Otherwise, @command{tar} will use the
  689. default archive, determined at the compile time. Usually it is
  690. standard output or some physical tape drive attached to your machine
  691. (you can verify what the default is by running @kbd{tar
  692. --show-defaults}, @pxref{defaults}). If there is no tape drive
  693. attached, or the default is not meaningful, then @command{tar} will
  694. print an error message. The error message might look roughly like one
  695. of the following:
  696. @smallexample
  697. tar: can't open /dev/rmt8 : No such device or address
  698. tar: can't open /dev/rsmt0 : I/O error
  699. @end smallexample
  700. @noindent
  701. To avoid confusion, we recommend that you always specify an archive file
  702. name by using @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) when writing your @command{tar} commands.
  703. For more information on using the @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) option, see
  704. @ref{file}.
  705. @node verbose tutorial
  706. @unnumberedsubsec The @option{--verbose} Option
  707. @table @option
  708. @opindex verbose, introduced
  709. @item --verbose
  710. @itemx -v
  711. Show the files being worked on as @command{tar} is running.
  712. @end table
  713. @option{--verbose} (@option{-v}) shows details about the results of running
  714. @command{tar}. This can be especially useful when the results might not be
  715. obvious. For example, if you want to see the progress of @command{tar} as
  716. it writes files into the archive, you can use the @option{--verbose}
  717. option. In the beginning, you may find it useful to use
  718. @option{--verbose} at all times; when you are more accustomed to
  719. @command{tar}, you will likely want to use it at certain times but not at
  720. others. We will use @option{--verbose} at times to help make something
  721. clear, and we will give many examples both using and not using
  722. @option{--verbose} to show the differences.
  723. Sometimes, a single instance of @option{--verbose} on the command line
  724. will show a full, @samp{ls} style listing of an archive or files,
  725. giving sizes, owners, and similar information. @FIXME{Describe the
  726. exact output format, e.g., how hard links are displayed.}
  727. Other times, @option{--verbose} will only show files or members that the particular
  728. operation is operating on at the time. In the latter case, you can
  729. use @option{--verbose} twice in a command to get a listing such as that
  730. in the former case. For example, instead of saying
  731. @smallexample
  732. @kbd{tar -cvf afiles.tar apple angst aspic}
  733. @end smallexample
  734. @noindent
  735. above, you might say
  736. @smallexample
  737. @kbd{tar -cvvf afiles.tar apple angst aspic}
  738. @end smallexample
  739. @noindent
  740. This works equally well using short or long forms of options. Using
  741. long forms, you would simply write out the mnemonic form of the option
  742. twice, like this:
  743. @smallexample
  744. $ @kbd{tar --create --verbose --verbose @dots{}}
  745. @end smallexample
  746. @noindent
  747. Note that you must double the hyphens properly each time.
  748. Later in the tutorial, we will give examples using @w{@option{--verbose
  749. --verbose}}.
  750. @node help tutorial
  751. @unnumberedsubsec Getting Help: Using the @option{--help} Option
  752. @table @option
  753. @opindex help
  754. @item --help
  755. The @option{--help} option to @command{tar} prints out a very brief list of
  756. all operations and option available for the current version of
  757. @command{tar} available on your system.
  758. @end table
  759. @node create
  760. @section How to Create Archives
  761. @UNREVISED
  762. @cindex Creation of the archive
  763. @cindex Archive, creation of
  764. One of the basic operations of @command{tar} is @option{--create} (@option{-c}), which
  765. you use to create a @command{tar} archive. We will explain
  766. @option{--create} first because, in order to learn about the other
  767. operations, you will find it useful to have an archive available to
  768. practice on.
  769. To make this easier, in this section you will first create a directory
  770. containing three files. Then, we will show you how to create an
  771. @emph{archive} (inside the new directory). Both the directory, and
  772. the archive are specifically for you to practice on. The rest of this
  773. chapter and the next chapter will show many examples using this
  774. directory and the files you will create: some of those files may be
  775. other directories and other archives.
  776. The three files you will archive in this example are called
  777. @file{blues}, @file{folk}, and @file{jazz}. The archive is called
  778. @file{collection.tar}.
  779. This section will proceed slowly, detailing how to use @option{--create}
  780. in @code{verbose} mode, and showing examples using both short and long
  781. forms. In the rest of the tutorial, and in the examples in the next
  782. chapter, we will proceed at a slightly quicker pace. This section
  783. moves more slowly to allow beginning users to understand how
  784. @command{tar} works.
  785. @menu
  786. * prepare for examples::
  787. * Creating the archive::
  788. * create verbose::
  789. * short create::
  790. * create dir::
  791. @end menu
  792. @node prepare for examples
  793. @subsection Preparing a Practice Directory for Examples
  794. To follow along with this and future examples, create a new directory
  795. called @file{practice} containing files called @file{blues}, @file{folk}
  796. and @file{jazz}. The files can contain any information you like:
  797. ideally, they should contain information which relates to their names,
  798. and be of different lengths. Our examples assume that @file{practice}
  799. is a subdirectory of your home directory.
  800. Now @command{cd} to the directory named @file{practice}; @file{practice}
  801. is now your @dfn{working directory}. (@emph{Please note}: Although
  802. the full path name of this directory is
  803. @file{/@var{homedir}/practice}, in our examples we will refer to
  804. this directory as @file{practice}; the @var{homedir} is presumed.
  805. In general, you should check that the files to be archived exist where
  806. you think they do (in the working directory) by running @command{ls}.
  807. Because you just created the directory and the files and have changed to
  808. that directory, you probably don't need to do that this time.
  809. It is very important to make sure there isn't already a file in the
  810. working directory with the archive name you intend to use (in this case,
  811. @samp{collection.tar}), or that you don't care about its contents.
  812. Whenever you use @samp{create}, @command{tar} will erase the current
  813. contents of the file named by @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) if it exists. @command{tar}
  814. will not tell you if you are about to overwrite an archive unless you
  815. specify an option which does this (@pxref{backup}, for the
  816. information on how to do so). To add files to an existing archive,
  817. you need to use a different option, such as @option{--append} (@option{-r}); see
  818. @ref{append} for information on how to do this.
  819. @node Creating the archive
  820. @subsection Creating the Archive
  821. @opindex create, introduced
  822. To place the files @file{blues}, @file{folk}, and @file{jazz} into an
  823. archive named @file{collection.tar}, use the following command:
  824. @smallexample
  825. $ @kbd{tar --create --file=collection.tar blues folk jazz}
  826. @end smallexample
  827. The order of the arguments is not very important, @emph{when using long
  828. option forms}. You could also say:
  829. @smallexample
  830. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  831. @end smallexample
  832. @noindent
  833. However, you can see that this order is harder to understand; this is
  834. why we will list the arguments in the order that makes the commands
  835. easiest to understand (and we encourage you to do the same when you use
  836. @command{tar}, to avoid errors).
  837. Note that the part of the command which says,
  838. @w{@option{--file=collection.tar}} is considered to be @emph{one} argument.
  839. If you substituted any other string of characters for
  840. @kbd{collection.tar}, then that string would become the name of the
  841. archive file you create.
  842. The order of the options becomes more important when you begin to use
  843. short forms. With short forms, if you type commands in the wrong order
  844. (even if you type them correctly in all other ways), you may end up with
  845. results you don't expect. For this reason, it is a good idea to get
  846. into the habit of typing options in the order that makes inherent sense.
  847. @xref{short create}, for more information on this.
  848. In this example, you type the command as shown above: @option{--create}
  849. is the operation which creates the new archive
  850. (@file{collection.tar}), and @option{--file} is the option which lets
  851. you give it the name you chose. The files, @file{blues}, @file{folk},
  852. and @file{jazz}, are now members of the archive, @file{collection.tar}
  853. (they are @dfn{file name arguments} to the @option{--create} operation).
  854. @FIXME{xref here to the discussion of file name args?}Now that they are
  855. in the archive, they are called @emph{archive members}, not files.
  856. (@pxref{Definitions,members}).
  857. When you create an archive, you @emph{must} specify which files you
  858. want placed in the archive. If you do not specify any archive
  859. members, @GNUTAR{} will complain.
  860. If you now list the contents of the working directory (@command{ls}), you will
  861. find the archive file listed as well as the files you saw previously:
  862. @smallexample
  863. blues folk jazz collection.tar
  864. @end smallexample
  865. @noindent
  866. Creating the archive @samp{collection.tar} did not destroy the copies of
  867. the files in the directory.
  868. Keep in mind that if you don't indicate an operation, @command{tar} will not
  869. run and will prompt you for one. If you don't name any files, @command{tar}
  870. will complain. You must have write access to the working directory,
  871. or else you will not be able to create an archive in that directory.
  872. @emph{Caution}: Do not attempt to use @option{--create} (@option{-c}) to add files to
  873. an existing archive; it will delete the archive and write a new one.
  874. Use @option{--append} (@option{-r}) instead. @xref{append}.
  875. @node create verbose
  876. @subsection Running @option{--create} with @option{--verbose}
  877. @opindex create, using with @option{--verbose}
  878. @opindex verbose, using with @option{--create}
  879. If you include the @option{--verbose} (@option{-v}) option on the command line,
  880. @command{tar} will list the files it is acting on as it is working. In
  881. verbose mode, the @code{create} example above would appear as:
  882. @smallexample
  883. $ @kbd{tar --create --verbose --file=collection.tar blues folk jazz}
  884. blues
  885. folk
  886. jazz
  887. @end smallexample
  888. This example is just like the example we showed which did not use
  889. @option{--verbose}, except that @command{tar} generated the remaining lines
  890. @iftex
  891. (note the different font styles).
  892. @end iftex
  893. @ifinfo
  894. .
  895. @end ifinfo
  896. In the rest of the examples in this chapter, we will frequently use
  897. @code{verbose} mode so we can show actions or @command{tar} responses that
  898. you would otherwise not see, and which are important for you to
  899. understand.
  900. @node short create
  901. @subsection Short Forms with @samp{create}
  902. As we said before, the @option{--create} (@option{-c}) operation is one of the most
  903. basic uses of @command{tar}, and you will use it countless times.
  904. Eventually, you will probably want to use abbreviated (or ``short'')
  905. forms of options. A full discussion of the three different forms that
  906. options can take appears in @ref{Styles}; for now, here is what the
  907. previous example (including the @option{--verbose} (@option{-v}) option) looks like
  908. using short option forms:
  909. @smallexample
  910. $ @kbd{tar -cvf collection.tar blues folk jazz}
  911. blues
  912. folk
  913. jazz
  914. @end smallexample
  915. @noindent
  916. As you can see, the system responds the same no matter whether you use
  917. long or short option forms.
  918. @FIXME{i don't like how this is worded:} One difference between using
  919. short and long option forms is that, although the exact placement of
  920. arguments following options is no more specific when using short forms,
  921. it is easier to become confused and make a mistake when using short
  922. forms. For example, suppose you attempted the above example in the
  923. following way:
  924. @smallexample
  925. $ @kbd{tar -cfv collection.tar blues folk jazz}
  926. @end smallexample
  927. @noindent
  928. In this case, @command{tar} will make an archive file called @file{v},
  929. containing the files @file{blues}, @file{folk}, and @file{jazz}, because
  930. the @samp{v} is the closest ``file name'' to the @option{-f} option, and
  931. is thus taken to be the chosen archive file name. @command{tar} will try
  932. to add a file called @file{collection.tar} to the @file{v} archive file;
  933. if the file @file{collection.tar} did not already exist, @command{tar} will
  934. report an error indicating that this file does not exist. If the file
  935. @file{collection.tar} does already exist (e.g., from a previous command
  936. you may have run), then @command{tar} will add this file to the archive.
  937. Because the @option{-v} option did not get registered, @command{tar} will not
  938. run under @samp{verbose} mode, and will not report its progress.
  939. The end result is that you may be quite confused about what happened,
  940. and possibly overwrite a file. To illustrate this further, we will show
  941. you how an example we showed previously would look using short forms.
  942. This example,
  943. @smallexample
  944. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  945. @end smallexample
  946. @noindent
  947. is confusing as it is. When shown using short forms, however, it
  948. becomes much more so:
  949. @smallexample
  950. $ @kbd{tar blues -c folk -f collection.tar jazz}
  951. @end smallexample
  952. @noindent
  953. It would be very easy to put the wrong string of characters
  954. immediately following the @option{-f}, but doing that could sacrifice
  955. valuable data.
  956. For this reason, we recommend that you pay very careful attention to
  957. the order of options and placement of file and archive names,
  958. especially when using short option forms. Not having the option name
  959. written out mnemonically can affect how well you remember which option
  960. does what, and therefore where different names have to be placed.
  961. @node create dir
  962. @subsection Archiving Directories
  963. @cindex Archiving Directories
  964. @cindex Directories, Archiving
  965. You can archive a directory by specifying its directory name as a
  966. file name argument to @command{tar}. The files in the directory will be
  967. archived relative to the working directory, and the directory will be
  968. re-created along with its contents when the archive is extracted.
  969. To archive a directory, first move to its superior directory. If you
  970. have followed the previous instructions in this tutorial, you should
  971. type:
  972. @smallexample
  973. $ @kbd{cd ..}
  974. $
  975. @end smallexample
  976. @noindent
  977. This will put you into the directory which contains @file{practice},
  978. i.e., your home directory. Once in the superior directory, you can
  979. specify the subdirectory, @file{practice}, as a file name argument. To
  980. store @file{practice} in the new archive file @file{music.tar}, type:
  981. @smallexample
  982. $ @kbd{tar --create --verbose --file=music.tar practice}
  983. @end smallexample
  984. @noindent
  985. @command{tar} should output:
  986. @smallexample
  987. practice/
  988. practice/blues
  989. practice/folk
  990. practice/jazz
  991. practice/collection.tar
  992. @end smallexample
  993. Note that the archive thus created is not in the subdirectory
  994. @file{practice}, but rather in the current working directory---the
  995. directory from which @command{tar} was invoked. Before trying to archive a
  996. directory from its superior directory, you should make sure you have
  997. write access to the superior directory itself, not only the directory
  998. you are trying archive with @command{tar}. For example, you will probably
  999. not be able to store your home directory in an archive by invoking
  1000. @command{tar} from the root directory; @xref{absolute}. (Note
  1001. also that @file{collection.tar}, the original archive file, has itself
  1002. been archived. @command{tar} will accept any file as a file to be
  1003. archived, regardless of its content. When @file{music.tar} is
  1004. extracted, the archive file @file{collection.tar} will be re-written
  1005. into the file system).
  1006. If you give @command{tar} a command such as
  1007. @smallexample
  1008. $ @kbd{tar --create --file=foo.tar .}
  1009. @end smallexample
  1010. @noindent
  1011. @command{tar} will report @samp{tar: ./foo.tar is the archive; not
  1012. dumped}. This happens because @command{tar} creates the archive
  1013. @file{foo.tar} in the current directory before putting any files into
  1014. it. Then, when @command{tar} attempts to add all the files in the
  1015. directory @file{.} to the archive, it notices that the file
  1016. @file{./foo.tar} is the same as the archive @file{foo.tar}, and skips
  1017. it. (It makes no sense to put an archive into itself.) @GNUTAR{}
  1018. will continue in this case, and create the archive
  1019. normally, except for the exclusion of that one file. (@emph{Please
  1020. note:} Other versions of @command{tar} are not so clever; they will
  1021. enter an infinite loop when this happens, so you should not depend on
  1022. this behavior unless you are certain you are running @GNUTAR{}.)
  1023. @FIXME{bob doesn't like this sentence, since he does
  1024. it all the time, and we've been doing it in the editing passes for
  1025. this manual: In general, make sure that the archive is not inside a
  1026. directory being dumped.}
  1027. @node list
  1028. @section How to List Archives
  1029. @opindex list
  1030. Frequently, you will find yourself wanting to determine exactly what a
  1031. particular archive contains. You can use the @option{--list} (@option{-t}) operation
  1032. to get the member names as they currently appear in the archive, as well
  1033. as various attributes of the files at the time they were archived. For
  1034. example, you can examine the archive @file{collection.tar} that you
  1035. created in the last section with the command,
  1036. @smallexample
  1037. $ @kbd{tar --list --file=collection.tar}
  1038. @end smallexample
  1039. @noindent
  1040. The output of @command{tar} would then be:
  1041. @smallexample
  1042. blues
  1043. folk
  1044. jazz
  1045. @end smallexample
  1046. @FIXME{we hope this will change. if it doesn't, need to show the
  1047. creation of bfiles somewhere above!!! : }
  1048. @noindent
  1049. The archive @file{bfiles.tar} would list as follows:
  1050. @smallexample
  1051. ./birds
  1052. baboon
  1053. ./box
  1054. @end smallexample
  1055. @noindent
  1056. Be sure to use a @option{--file=@var{archive-name}} (@option{-f @var{archive-name}}) option just as with @option{--create} (@option{-c})
  1057. to specify the name of the archive.
  1058. @opindex list, using with @option{--verbose}
  1059. @opindex verbose, using with @option{--list}
  1060. If you use the @option{--verbose} (@option{-v}) option with @option{--list}, then
  1061. @command{tar} will print out a listing reminiscent of @w{@samp{ls -l}},
  1062. showing owner, file size, and so forth.
  1063. If you had used @option{--verbose} (@option{-v}) mode, the example above would look
  1064. like:
  1065. @smallexample
  1066. $ @kbd{tar --list --verbose --file=collection.tar folk}
  1067. -rw-r--r-- myself user 62 1990-05-23 10:55 folk
  1068. @end smallexample
  1069. @cindex listing member and file names
  1070. @anchor{listing member and file names}
  1071. It is important to notice that the output of @kbd{tar --list
  1072. --verbose} does not necessarily match that produced by @kbd{tar
  1073. --create --verbose} while creating the archive. It is because
  1074. @GNUTAR{}, unless told explicitly not to do so, removes some directory
  1075. prefixes from file names before storing them in the archive
  1076. (@xref{absolute}, for more information). In other
  1077. words, in verbose mode @GNUTAR{} shows @dfn{file names} when creating
  1078. an archive and @dfn{member names} when listing it. Consider this
  1079. example:
  1080. @smallexample
  1081. @group
  1082. $ @kbd{tar cfv archive /etc/mail}
  1083. tar: Removing leading `/' from member names
  1084. /etc/mail/
  1085. /etc/mail/sendmail.cf
  1086. /etc/mail/aliases
  1087. $ @kbd{tar tf archive}
  1088. etc/mail/
  1089. etc/mail/sendmail.cf
  1090. etc/mail/aliases
  1091. @end group
  1092. @end smallexample
  1093. @opindex show-stored-names
  1094. This default behavior can sometimes be inconvenient. You can force
  1095. @GNUTAR{} show member names when creating archive by supplying
  1096. @option{--show-stored-names} option.
  1097. @table @option
  1098. @item --show-stored-names
  1099. Print member (not @emph{file}) names when creating the archive.
  1100. @end table
  1101. @cindex File name arguments, using @option{--list} with
  1102. @opindex list, using with file name arguments
  1103. You can specify one or more individual member names as arguments when
  1104. using @samp{list}. In this case, @command{tar} will only list the
  1105. names of members you identify. For example, @w{@kbd{tar --list
  1106. --file=afiles.tar apple}} would only print @file{apple}.
  1107. @FIXME{we hope the relevant aspects of this will change:}Because
  1108. @command{tar} preserves paths, file names must be specified as they appear
  1109. in the archive (ie., relative to the directory from which the archive
  1110. was created). Therefore, it is essential when specifying member names
  1111. to @command{tar} that you give the exact member names. For example,
  1112. @w{@kbd{tar --list --file=bfiles birds}} would produce an error message
  1113. something like @samp{tar: birds: Not found in archive}, because there is
  1114. no member named @file{birds}, only one named @file{./birds}. While the
  1115. names @file{birds} and @file{./birds} name the same file, @emph{member}
  1116. names are compared using a simplistic name comparison, in which an exact
  1117. match is necessary. @xref{absolute}.
  1118. However, @w{@kbd{tar --list --file=collection.tar folk}} would respond
  1119. with @file{folk}, because @file{folk} is in the archive file
  1120. @file{collection.tar}. If you are not sure of the exact file name, try
  1121. listing all the files in the archive and searching for the one you
  1122. expect to find; remember that if you use @option{--list} with no file
  1123. names as arguments, @command{tar} will print the names of all the members
  1124. stored in the specified archive.
  1125. @menu
  1126. * list dir::
  1127. @end menu
  1128. @node list dir
  1129. @unnumberedsubsec Listing the Contents of a Stored Directory
  1130. To get information about the contents of an archived directory,
  1131. use the directory name as a file name argument in conjunction with
  1132. @option{--list} (@option{-t}). To find out file attributes, include the
  1133. @option{--verbose} (@option{-v}) option.
  1134. For example, to find out about files in the directory @file{practice}, in
  1135. the archive file @file{music.tar}, type:
  1136. @smallexample
  1137. $ @kbd{tar --list --verbose --file=music.tar practice}
  1138. @end smallexample
  1139. @command{tar} responds:
  1140. @smallexample
  1141. drwxrwxrwx myself user 0 1990-05-31 21:49 practice/
  1142. -rw-r--r-- myself user 42 1990-05-21 13:29 practice/blues
  1143. -rw-r--r-- myself user 62 1990-05-23 10:55 practice/folk
  1144. -rw-r--r-- myself user 40 1990-05-21 13:30 practice/jazz
  1145. -rw-r--r-- myself user 10240 1990-05-31 21:49 practice/collection.tar
  1146. @end smallexample
  1147. When you use a directory name as a file name argument, @command{tar} acts on
  1148. all the files (including sub-directories) in that directory.
  1149. @node extract
  1150. @section How to Extract Members from an Archive
  1151. @UNREVISED
  1152. @cindex Extraction
  1153. @cindex Retrieving files from an archive
  1154. @cindex Resurrecting files from an archive
  1155. @opindex extract
  1156. Creating an archive is only half the job---there is no point in storing
  1157. files in an archive if you can't retrieve them. The act of retrieving
  1158. members from an archive so they can be used and manipulated as
  1159. unarchived files again is called @dfn{extraction}. To extract files
  1160. from an archive, use the @option{--extract} (@option{--get} or
  1161. @option{-x}) operation. As with @option{--create}, specify the name
  1162. of the archive with @option{--file} (@option{-f}) option. Extracting
  1163. an archive does not modify the archive in any way; you can extract it
  1164. multiple times if you want or need to.
  1165. Using @option{--extract}, you can extract an entire archive, or specific
  1166. files. The files can be directories containing other files, or not. As
  1167. with @option{--create} (@option{-c}) and @option{--list} (@option{-t}), you may use the short or the
  1168. long form of the operation without affecting the performance.
  1169. @menu
  1170. * extracting archives::
  1171. * extracting files::
  1172. * extract dir::
  1173. * extracting untrusted archives::
  1174. * failing commands::
  1175. @end menu
  1176. @node extracting archives
  1177. @subsection Extracting an Entire Archive
  1178. To extract an entire archive, specify the archive file name only, with
  1179. no individual file names as arguments. For example,
  1180. @smallexample
  1181. $ @kbd{tar -xvf collection.tar}
  1182. @end smallexample
  1183. @noindent
  1184. produces this:
  1185. @smallexample
  1186. -rw-r--r-- me user 28 1996-10-18 16:31 jazz
  1187. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  1188. -rw-r--r-- me user 20 1996-09-23 16:44 folk
  1189. @end smallexample
  1190. @node extracting files
  1191. @subsection Extracting Specific Files
  1192. To extract specific archive members, give their exact member names as
  1193. arguments, as printed by @option{--list} (@option{-t}). If you had mistakenly deleted
  1194. one of the files you had placed in the archive @file{collection.tar}
  1195. earlier (say, @file{blues}), you can extract it from the archive without
  1196. changing the archive's structure. Its contents will be identical to the
  1197. original file @file{blues} that you deleted.
  1198. First, make sure you are in the @file{practice} directory, and list the
  1199. files in the directory. Now, delete the file, @samp{blues}, and list
  1200. the files in the directory again.
  1201. You can now extract the member @file{blues} from the archive file
  1202. @file{collection.tar} like this:
  1203. @smallexample
  1204. $ @kbd{tar --extract --file=collection.tar blues}
  1205. @end smallexample
  1206. @noindent
  1207. If you list the files in the directory again, you will see that the file
  1208. @file{blues} has been restored, with its original permissions, data modification
  1209. times, and owner.@FIXME{This is only accidentally true, but not in
  1210. general. In most cases, one has to be root for restoring the owner, and
  1211. use a special option for restoring permissions. Here, it just happens
  1212. that the restoring user is also the owner of the archived members, and
  1213. that the current @code{umask} is compatible with original permissions.}
  1214. (These parameters will be identical to those which
  1215. the file had when you originally placed it in the archive; any changes
  1216. you may have made before deleting the file from the file system,
  1217. however, will @emph{not} have been made to the archive member.) The
  1218. archive file, @samp{collection.tar}, is the same as it was before you
  1219. extracted @samp{blues}. You can confirm this by running @command{tar} with
  1220. @option{--list} (@option{-t}).
  1221. @FIXME{we hope this will change:}Remember that as with other operations,
  1222. specifying the exact member name is important. @w{@kbd{tar --extract
  1223. --file=bfiles.tar birds}} will fail, because there is no member named
  1224. @file{birds}. To extract the member named @file{./birds}, you must
  1225. specify @w{@kbd{tar --extract --file=bfiles.tar ./birds}}. To find the
  1226. exact member names of the members of an archive, use @option{--list} (@option{-t})
  1227. (@pxref{list}).
  1228. You can extract a file to standard output by combining the above options
  1229. with the @option{--to-stdout} (@option{-O}) option (@pxref{Writing to Standard
  1230. Output}).
  1231. If you give the @option{--verbose} option, then @option{--extract}
  1232. will print the names of the archive members as it extracts them.
  1233. @node extract dir
  1234. @subsection Extracting Files that are Directories
  1235. Extracting directories which are members of an archive is similar to
  1236. extracting other files. The main difference to be aware of is that if
  1237. the extracted directory has the same name as any directory already in
  1238. the working directory, then files in the extracted directory will be
  1239. placed into the directory of the same name. Likewise, if there are
  1240. files in the pre-existing directory with the same names as the members
  1241. which you extract, the files from the extracted archive will replace
  1242. the files already in the working directory (and possible
  1243. subdirectories). This will happen regardless of whether or not the
  1244. files in the working directory were more recent than those extracted
  1245. (there exist, however, special options that alter this behavior
  1246. @pxref{Writing}).
  1247. However, if a file was stored with a directory name as part of its file
  1248. name, and that directory does not exist under the working directory when
  1249. the file is extracted, @command{tar} will create the directory.
  1250. We can demonstrate how to use @option{--extract} to extract a directory
  1251. file with an example. Change to the @file{practice} directory if you
  1252. weren't there, and remove the files @file{folk} and @file{jazz}. Then,
  1253. go back to the parent directory and extract the archive
  1254. @file{music.tar}. You may either extract the entire archive, or you may
  1255. extract only the files you just deleted. To extract the entire archive,
  1256. don't give any file names as arguments after the archive name
  1257. @file{music.tar}. To extract only the files you deleted, use the
  1258. following command:
  1259. @smallexample
  1260. $ @kbd{tar -xvf music.tar practice/folk practice/jazz}
  1261. practice/folk
  1262. practice/jazz
  1263. @end smallexample
  1264. @noindent
  1265. If you were to specify two @option{--verbose} (@option{-v}) options, @command{tar}
  1266. would have displayed more detail about the extracted files, as shown
  1267. in the example below:
  1268. @smallexample
  1269. $ @kbd{tar -xvvf music.tar practice/folk practice/jazz}
  1270. -rw-r--r-- me user 28 1996-10-18 16:31 practice/jazz
  1271. -rw-r--r-- me user 20 1996-09-23 16:44 practice/folk
  1272. @end smallexample
  1273. @noindent
  1274. Because you created the directory with @file{practice} as part of the
  1275. file names of each of the files by archiving the @file{practice}
  1276. directory as @file{practice}, you must give @file{practice} as part
  1277. of the file names when you extract those files from the archive.
  1278. @FIXME{IMPORTANT! show the final structure, here. figure out what it
  1279. will be.}
  1280. @node extracting untrusted archives
  1281. @subsection Extracting Archives from Untrusted Sources
  1282. Extracting files from archives can overwrite files that already exist.
  1283. If you receive an archive from an untrusted source, you should make a
  1284. new directory and extract into that directory, so that you don't have
  1285. to worry about the extraction overwriting one of your existing files.
  1286. For example, if @file{untrusted.tar} came from somewhere else on the
  1287. Internet, and you don't necessarily trust its contents, you can
  1288. extract it as follows:
  1289. @smallexample
  1290. $ @kbd{mkdir newdir}
  1291. $ @kbd{cd newdir}
  1292. $ @kbd{tar -xvf ../untrusted.tar}
  1293. @end smallexample
  1294. It is also a good practice to examine contents of the archive
  1295. before extracting it, using @option{--list} (@option{-t}) option, possibly combined
  1296. with @option{--verbose} (@option{-v}).
  1297. @node failing commands
  1298. @subsection Commands That Will Fail
  1299. Here are some sample commands you might try which will not work, and why
  1300. they won't work.
  1301. If you try to use this command,
  1302. @smallexample
  1303. $ @kbd{tar -xvf music.tar folk jazz}
  1304. @end smallexample
  1305. @noindent
  1306. you will get the following response:
  1307. @smallexample
  1308. tar: folk: Not found in archive
  1309. tar: jazz: Not found in archive
  1310. $
  1311. @end smallexample
  1312. @noindent
  1313. This is because these files were not originally @emph{in} the parent
  1314. directory @file{..}, where the archive is located; they were in the
  1315. @file{practice} directory, and their file names reflect this:
  1316. @smallexample
  1317. $ @kbd{tar -tvf music.tar}
  1318. practice/folk
  1319. practice/jazz
  1320. practice/rock
  1321. @end smallexample
  1322. @FIXME{make sure the above works when going through the examples in
  1323. order...}
  1324. @noindent
  1325. Likewise, if you try to use this command,
  1326. @smallexample
  1327. $ @kbd{tar -tvf music.tar folk jazz}
  1328. @end smallexample
  1329. @noindent
  1330. you would get a similar response. Members with those names are not in the
  1331. archive. You must use the correct member names in order to extract the
  1332. files from the archive.
  1333. If you have forgotten the correct names of the files in the archive,
  1334. use @w{@kbd{tar --list --verbose}} to list them correctly.
  1335. @FIXME{more examples, here? hag thinks it's a good idea.}
  1336. @node going further
  1337. @section Going Further Ahead in this Manual
  1338. @FIXME{need to write up a node here about the things that are going to
  1339. be in the rest of the manual.}
  1340. @node tar invocation
  1341. @chapter Invoking @GNUTAR{}
  1342. @UNREVISED
  1343. This chapter is about how one invokes the @GNUTAR{}
  1344. command, from the command synopsis (@pxref{Synopsis}). There are
  1345. numerous options, and many styles for writing them. One mandatory
  1346. option specifies the operation @command{tar} should perform
  1347. (@pxref{Operation Summary}), other options are meant to detail how
  1348. this operation should be performed (@pxref{Option Summary}).
  1349. Non-option arguments are not always interpreted the same way,
  1350. depending on what the operation is.
  1351. You will find in this chapter everything about option styles and rules for
  1352. writing them (@pxref{Styles}). On the other hand, operations and options
  1353. are fully described elsewhere, in other chapters. Here, you will find
  1354. only synthetic descriptions for operations and options, together with
  1355. pointers to other parts of the @command{tar} manual.
  1356. Some options are so special they are fully described right in this
  1357. chapter. They have the effect of inhibiting the normal operation of
  1358. @command{tar} or else, they globally alter the amount of feedback the user
  1359. receives about what is going on. These are the @option{--help} and
  1360. @option{--version} (@pxref{help}), @option{--verbose} (@pxref{verbose})
  1361. and @option{--interactive} options (@pxref{interactive}).
  1362. @menu
  1363. * Synopsis::
  1364. * using tar options::
  1365. * Styles::
  1366. * All Options::
  1367. * help::
  1368. * defaults::
  1369. * verbose::
  1370. * interactive::
  1371. @end menu
  1372. @node Synopsis
  1373. @section General Synopsis of @command{tar}
  1374. The @GNUTAR{} program is invoked as either one of:
  1375. @smallexample
  1376. @kbd{tar @var{option}@dots{} [@var{name}]@dots{}}
  1377. @kbd{tar @var{letter}@dots{} [@var{argument}]@dots{} [@var{option}]@dots{} [@var{name}]@dots{}}
  1378. @end smallexample
  1379. The second form is for when old options are being used.
  1380. You can use @command{tar} to store files in an archive, to extract them from
  1381. an archive, and to do other types of archive manipulation. The primary
  1382. argument to @command{tar}, which is called the @dfn{operation}, specifies
  1383. which action to take. The other arguments to @command{tar} are either
  1384. @dfn{options}, which change the way @command{tar} performs an operation,
  1385. or file names or archive members, which specify the files or members
  1386. @command{tar} is to act on.
  1387. You can actually type in arguments in any order, even if in this manual
  1388. the options always precede the other arguments, to make examples easier
  1389. to understand. Further, the option stating the main operation mode
  1390. (the @command{tar} main command) is usually given first.
  1391. Each @var{name} in the synopsis above is interpreted as an archive member
  1392. name when the main command is one of @option{--compare}
  1393. (@option{--diff}, @option{-d}), @option{--delete}, @option{--extract}
  1394. (@option{--get}, @option{-x}), @option{--list} (@option{-t}) or
  1395. @option{--update} (@option{-u}). When naming archive members, you
  1396. must give the exact name of the member in the archive, as it is
  1397. printed by @option{--list}. For @option{--append} (@option{-r}) and
  1398. @option{--create} (@option{-c}), these @var{name} arguments specify
  1399. the names of either files or directory hierarchies to place in the archive.
  1400. These files or hierarchies should already exist in the file system,
  1401. prior to the execution of the @command{tar} command.
  1402. @command{tar} interprets relative file names as being relative to the
  1403. working directory. @command{tar} will make all file names relative
  1404. (by removing leading slashes when archiving or restoring files),
  1405. unless you specify otherwise (using the @option{--absolute-names}
  1406. option). @xref{absolute}, for more information about
  1407. @option{--absolute-names}.
  1408. If you give the name of a directory as either a file name or a member
  1409. name, then @command{tar} acts recursively on all the files and directories
  1410. beneath that directory. For example, the name @file{/} identifies all
  1411. the files in the file system to @command{tar}.
  1412. The distinction between file names and archive member names is especially
  1413. important when shell globbing is used, and sometimes a source of confusion
  1414. for newcomers. @xref{Wildcards}, for more information about globbing.
  1415. The problem is that shells may only glob using existing files in the
  1416. file system. Only @command{tar} itself may glob on archive members, so when
  1417. needed, you must ensure that wildcard characters reach @command{tar} without
  1418. being interpreted by the shell first. Using a backslash before @samp{*}
  1419. or @samp{?}, or putting the whole argument between quotes, is usually
  1420. sufficient for this.
  1421. Even if @var{name}s are often specified on the command line, they
  1422. can also be read from a text file in the file system, using the
  1423. @option{--files-from=@var{file-of-names}} (@option{-T @var{file-of-names}}) option.
  1424. If you don't use any file name arguments, @option{--append} (@option{-r}),
  1425. @option{--delete} and @option{--concatenate} (@option{--catenate},
  1426. @option{-A}) will do nothing, while @option{--create} (@option{-c})
  1427. will usually yield a diagnostic and inhibit @command{tar} execution.
  1428. The other operations of @command{tar} (@option{--list},
  1429. @option{--extract}, @option{--compare}, and @option{--update})
  1430. will act on the entire contents of the archive.
  1431. @cindex exit status
  1432. @cindex return status
  1433. Besides successful exits, @GNUTAR{} may fail for
  1434. many reasons. Some reasons correspond to bad usage, that is, when the
  1435. @command{tar} command is improperly written. Errors may be
  1436. encountered later, while encountering an error processing the archive
  1437. or the files. Some errors are recoverable, in which case the failure
  1438. is delayed until @command{tar} has completed all its work. Some
  1439. errors are such that it would not meaningful, or at least risky, to
  1440. continue processing: @command{tar} then aborts processing immediately.
  1441. All abnormal exits, whether immediate or delayed, should always be
  1442. clearly diagnosed on @code{stderr}, after a line stating the nature of
  1443. the error.
  1444. @GNUTAR{} returns only a few exit statuses. I'm really
  1445. aiming simplicity in that area, for now. If you are not using the
  1446. @option{--compare} @option{--diff}, @option{-d}) option, zero means
  1447. that everything went well, besides maybe innocuous warnings. Nonzero
  1448. means that something went wrong. Right now, as of today, ``nonzero''
  1449. is almost always 2, except for remote operations, where it may be
  1450. 128.
  1451. @node using tar options
  1452. @section Using @command{tar} Options
  1453. @GNUTAR{} has a total of eight operating modes which
  1454. allow you to perform a variety of tasks. You are required to choose
  1455. one operating mode each time you employ the @command{tar} program by
  1456. specifying one, and only one operation as an argument to the
  1457. @command{tar} command (two lists of four operations each may be found
  1458. at @ref{frequent operations} and @ref{Operations}). Depending on
  1459. circumstances, you may also wish to customize how the chosen operating
  1460. mode behaves. For example, you may wish to change the way the output
  1461. looks, or the format of the files that you wish to archive may require
  1462. you to do something special in order to make the archive look right.
  1463. You can customize and control @command{tar}'s performance by running
  1464. @command{tar} with one or more options (such as @option{--verbose}
  1465. (@option{-v}), which we used in the tutorial). As we said in the
  1466. tutorial, @dfn{options} are arguments to @command{tar} which are (as
  1467. their name suggests) optional. Depending on the operating mode, you
  1468. may specify one or more options. Different options will have different
  1469. effects, but in general they all change details of the operation, such
  1470. as archive format, archive name, or level of user interaction. Some
  1471. options make sense with all operating modes, while others are
  1472. meaningful only with particular modes. You will likely use some
  1473. options frequently, while you will only use others infrequently, or
  1474. not at all. (A full list of options is available in @pxref{All Options}.)
  1475. @vrindex TAR_OPTIONS, environment variable
  1476. @anchor{TAR_OPTIONS}
  1477. The @env{TAR_OPTIONS} environment variable specifies default options to
  1478. be placed in front of any explicit options. For example, if
  1479. @code{TAR_OPTIONS} is @samp{-v --unlink-first}, @command{tar} behaves as
  1480. if the two options @option{-v} and @option{--unlink-first} had been
  1481. specified before any explicit options. Option specifications are
  1482. separated by whitespace. A backslash escapes the next character, so it
  1483. can be used to specify an option containing whitespace or a backslash.
  1484. Note that @command{tar} options are case sensitive. For example, the
  1485. options @option{-T} and @option{-t} are different; the first requires an
  1486. argument for stating the name of a file providing a list of @var{name}s,
  1487. while the second does not require an argument and is another way to
  1488. write @option{--list} (@option{-t}).
  1489. In addition to the eight operations, there are many options to
  1490. @command{tar}, and three different styles for writing both: long (mnemonic)
  1491. form, short form, and old style. These styles are discussed below.
  1492. Both the options and the operations can be written in any of these three
  1493. styles.
  1494. @FIXME{menu at end of this node. need to think of an actual outline
  1495. for this chapter; probably do that after stuff from chapter 4 is
  1496. incorporated.}
  1497. @node Styles
  1498. @section The Three Option Styles
  1499. There are three styles for writing operations and options to the command
  1500. line invoking @command{tar}. The different styles were developed at
  1501. different times during the history of @command{tar}. These styles will be
  1502. presented below, from the most recent to the oldest.
  1503. Some options must take an argument. (For example, @option{--file}
  1504. (@option{-f})) takes the name of an archive file as an argument. If
  1505. you do not supply an archive file name, @command{tar} will use a
  1506. default, but this can be confusing; thus, we recommend that you always
  1507. supply a specific archive file name.) Where you @emph{place} the
  1508. arguments generally depends on which style of options you choose. We
  1509. will detail specific information relevant to each option style in the
  1510. sections on the different option styles, below. The differences are
  1511. subtle, yet can often be very important; incorrect option placement
  1512. can cause you to overwrite a number of important files. We urge you
  1513. to note these differences, and only use the option style(s) which
  1514. makes the most sense to you until you feel comfortable with the others.
  1515. Some options @emph{may} take an argument (currently, there are
  1516. two such options: @option{--backup} and @option{--occurrence}). Such
  1517. options may have at most long and short forms, they do not have old style
  1518. equivalent. The rules for specifying an argument for such options
  1519. are stricter than those for specifying mandatory arguments. Please,
  1520. pay special attention to them.
  1521. @menu
  1522. * Mnemonic Options:: Mnemonic Option Style
  1523. * Short Options:: Short Option Style
  1524. * Old Options:: Old Option Style
  1525. * Mixing:: Mixing Option Styles
  1526. @end menu
  1527. @node Mnemonic Options
  1528. @subsection Mnemonic Option Style
  1529. @FIXME{have to decide whether or not to replace other occurrences of
  1530. "mnemonic" with "long", or *ugh* vice versa.}
  1531. Each option has at least one long (or mnemonic) name starting with two
  1532. dashes in a row, e.g., @option{--list}. The long names are more clear than
  1533. their corresponding short or old names. It sometimes happens that a
  1534. single mnemonic option has many different different names which are
  1535. synonymous, such as @option{--compare} and @option{--diff}. In addition,
  1536. long option names can be given unique abbreviations. For example,
  1537. @option{--cre} can be used in place of @option{--create} because there is no
  1538. other mnemonic option which begins with @samp{cre}. (One way to find
  1539. this out is by trying it and seeing what happens; if a particular
  1540. abbreviation could represent more than one option, @command{tar} will tell
  1541. you that that abbreviation is ambiguous and you'll know that that
  1542. abbreviation won't work. You may also choose to run @samp{tar --help}
  1543. to see a list of options. Be aware that if you run @command{tar} with a
  1544. unique abbreviation for the long name of an option you didn't want to
  1545. use, you are stuck; @command{tar} will perform the command as ordered.)
  1546. Mnemonic options are meant to be obvious and easy to remember, and their
  1547. meanings are generally easier to discern than those of their
  1548. corresponding short options (see below). For example:
  1549. @smallexample
  1550. $ @kbd{tar --create --verbose --blocking-factor=20 --file=/dev/rmt0}
  1551. @end smallexample
  1552. @noindent
  1553. gives a fairly good set of hints about what the command does, even
  1554. for those not fully acquainted with @command{tar}.
  1555. Mnemonic options which require arguments take those arguments
  1556. immediately following the option name. There are two ways of
  1557. specifying a mandatory argument. It can be separated from the
  1558. option name either by an equal sign, or by any amount of
  1559. white space characters. For example, the @option{--file} option (which
  1560. tells the name of the @command{tar} archive) is given a file such as
  1561. @file{archive.tar} as argument by using any of the following notations:
  1562. @option{--file=archive.tar} or @option{--file archive.tar}.
  1563. In contrast, optional arguments must always be introduced using
  1564. an equal sign. For example, the @option{--backup} option takes
  1565. an optional argument specifying backup type. It must be used
  1566. as @option{--backup=@var{backup-type}}.
  1567. @node Short Options
  1568. @subsection Short Option Style
  1569. Most options also have a short option name. Short options start with
  1570. a single dash, and are followed by a single character, e.g., @option{-t}
  1571. (which is equivalent to @option{--list}). The forms are absolutely
  1572. identical in function; they are interchangeable.
  1573. The short option names are faster to type than long option names.
  1574. Short options which require arguments take their arguments immediately
  1575. following the option, usually separated by white space. It is also
  1576. possible to stick the argument right after the short option name, using
  1577. no intervening space. For example, you might write @w{@option{-f
  1578. archive.tar}} or @option{-farchive.tar} instead of using
  1579. @option{--file=archive.tar}. Both @option{--file=@var{archive-name}} and
  1580. @w{@option{-f @var{archive-name}}} denote the option which indicates a
  1581. specific archive, here named @file{archive.tar}.
  1582. Short options which take optional arguments take their arguments
  1583. immediately following the option letter, @emph{without any intervening
  1584. white space characters}.
  1585. Short options' letters may be clumped together, but you are not
  1586. required to do this (as compared to old options; see below). When
  1587. short options are clumped as a set, use one (single) dash for them
  1588. all, e.g., @w{@samp{@command{tar} -cvf}}. Only the last option in
  1589. such a set is allowed to have an argument@footnote{Clustering many
  1590. options, the last of which has an argument, is a rather opaque way to
  1591. write options. Some wonder if @acronym{GNU} @code{getopt} should not
  1592. even be made helpful enough for considering such usages as invalid.}.
  1593. When the options are separated, the argument for each option which requires
  1594. an argument directly follows that option, as is usual for Unix programs.
  1595. For example:
  1596. @smallexample
  1597. $ @kbd{tar -c -v -b 20 -f /dev/rmt0}
  1598. @end smallexample
  1599. If you reorder short options' locations, be sure to move any arguments
  1600. that belong to them. If you do not move the arguments properly, you may
  1601. end up overwriting files.
  1602. @node Old Options
  1603. @subsection Old Option Style
  1604. @UNREVISED
  1605. Like short options, old options are single letters. However, old options
  1606. must be written together as a single clumped set, without spaces separating
  1607. them or dashes preceding them@footnote{Beware that if you precede options
  1608. with a dash, you are announcing the short option style instead of the
  1609. old option style; short options are decoded differently.}. This set
  1610. of letters must be the first to appear on the command line, after the
  1611. @command{tar} program name and some white space; old options cannot appear
  1612. anywhere else. The letter of an old option is exactly the same letter as
  1613. the corresponding short option. For example, the old option @samp{t} is
  1614. the same as the short option @option{-t}, and consequently, the same as the
  1615. mnemonic option @option{--list}. So for example, the command @w{@samp{tar
  1616. cv}} specifies the option @option{-v} in addition to the operation @option{-c}.
  1617. @FIXME{bob suggests having an uglier example. :-) }
  1618. When options that need arguments are given together with the command,
  1619. all the associated arguments follow, in the same order as the options.
  1620. Thus, the example given previously could also be written in the old
  1621. style as follows:
  1622. @smallexample
  1623. $ @kbd{tar cvbf 20 /dev/rmt0}
  1624. @end smallexample
  1625. @noindent
  1626. Here, @samp{20} is the argument of @option{-b} and @samp{/dev/rmt0} is
  1627. the argument of @option{-f}.
  1628. On the other hand, this old style syntax makes it difficult to match
  1629. option letters with their corresponding arguments, and is often
  1630. confusing. In the command @w{@samp{tar cvbf 20 /dev/rmt0}}, for example,
  1631. @samp{20} is the argument for @option{-b}, @samp{/dev/rmt0} is the
  1632. argument for @option{-f}, and @option{-v} does not have a corresponding
  1633. argument. Even using short options like in @w{@samp{tar -c -v -b 20 -f
  1634. /dev/rmt0}} is clearer, putting all arguments next to the option they
  1635. pertain to.
  1636. If you want to reorder the letters in the old option argument, be
  1637. sure to reorder any corresponding argument appropriately.
  1638. This old way of writing @command{tar} options can surprise even experienced
  1639. users. For example, the two commands:
  1640. @smallexample
  1641. @kbd{tar cfz archive.tar.gz file}
  1642. @kbd{tar -cfz archive.tar.gz file}
  1643. @end smallexample
  1644. @noindent
  1645. are quite different. The first example uses @file{archive.tar.gz} as
  1646. the value for option @samp{f} and recognizes the option @samp{z}. The
  1647. second example, however, uses @file{z} as the value for option
  1648. @samp{f} --- probably not what was intended.
  1649. Old options are kept for compatibility with old versions of @command{tar}.
  1650. This second example could be corrected in many ways, among which the
  1651. following are equivalent:
  1652. @smallexample
  1653. @kbd{tar -czf archive.tar.gz file}
  1654. @kbd{tar -cf archive.tar.gz -z file}
  1655. @kbd{tar cf archive.tar.gz -z file}
  1656. @end smallexample
  1657. @FIXME{still could explain this better; it's redundant:}
  1658. @cindex option syntax, traditional
  1659. As far as we know, all @command{tar} programs, @acronym{GNU} and
  1660. non-@acronym{GNU}, support old options. @GNUTAR{}
  1661. supports them not only for historical reasons, but also because many
  1662. people are used to them. For compatibility with Unix @command{tar},
  1663. the first argument is always treated as containing command and option
  1664. letters even if it doesn't start with @samp{-}. Thus, @samp{tar c} is
  1665. equivalent to @w{@samp{tar -c}:} both of them specify the
  1666. @option{--create} (@option{-c}) command to create an archive.
  1667. @node Mixing
  1668. @subsection Mixing Option Styles
  1669. All three styles may be intermixed in a single @command{tar} command,
  1670. so long as the rules for each style are fully
  1671. respected@footnote{Before @GNUTAR{} version 1.11.6,
  1672. a bug prevented intermixing old style options with mnemonic options in
  1673. some cases.}. Old style options and either of the modern styles of
  1674. options may be mixed within a single @command{tar} command. However,
  1675. old style options must be introduced as the first arguments only,
  1676. following the rule for old options (old options must appear directly
  1677. after the @command{tar} command and some white space). Modern options
  1678. may be given only after all arguments to the old options have been
  1679. collected. If this rule is not respected, a modern option might be
  1680. falsely interpreted as the value of the argument to one of the old
  1681. style options.
  1682. For example, all the following commands are wholly equivalent, and
  1683. illustrate the many combinations and orderings of option styles.
  1684. @smallexample
  1685. @kbd{tar --create --file=archive.tar}
  1686. @kbd{tar --create -f archive.tar}
  1687. @kbd{tar --create -farchive.tar}
  1688. @kbd{tar --file=archive.tar --create}
  1689. @kbd{tar --file=archive.tar -c}
  1690. @kbd{tar -c --file=archive.tar}
  1691. @kbd{tar -c -f archive.tar}
  1692. @kbd{tar -c -farchive.tar}
  1693. @kbd{tar -cf archive.tar}
  1694. @kbd{tar -cfarchive.tar}
  1695. @kbd{tar -f archive.tar --create}
  1696. @kbd{tar -f archive.tar -c}
  1697. @kbd{tar -farchive.tar --create}
  1698. @kbd{tar -farchive.tar -c}
  1699. @kbd{tar c --file=archive.tar}
  1700. @kbd{tar c -f archive.tar}
  1701. @kbd{tar c -farchive.tar}
  1702. @kbd{tar cf archive.tar}
  1703. @kbd{tar f archive.tar --create}
  1704. @kbd{tar f archive.tar -c}
  1705. @kbd{tar fc archive.tar}
  1706. @end smallexample
  1707. On the other hand, the following commands are @emph{not} equivalent to
  1708. the previous set:
  1709. @smallexample
  1710. @kbd{tar -f -c archive.tar}
  1711. @kbd{tar -fc archive.tar}
  1712. @kbd{tar -fcarchive.tar}
  1713. @kbd{tar -farchive.tarc}
  1714. @kbd{tar cfarchive.tar}
  1715. @end smallexample
  1716. @noindent
  1717. These last examples mean something completely different from what the
  1718. user intended (judging based on the example in the previous set which
  1719. uses long options, whose intent is therefore very clear). The first
  1720. four specify that the @command{tar} archive would be a file named
  1721. @option{-c}, @samp{c}, @samp{carchive.tar} or @samp{archive.tarc},
  1722. respectively. The first two examples also specify a single non-option,
  1723. @var{name} argument having the value @samp{archive.tar}. The last
  1724. example contains only old style option letters (repeating option
  1725. @samp{c} twice), not all of which are meaningful (eg., @samp{.},
  1726. @samp{h}, or @samp{i}), with no argument value. @FIXME{not sure i liked
  1727. the first sentence of this paragraph..}
  1728. @node All Options
  1729. @section All @command{tar} Options
  1730. The coming manual sections contain an alphabetical listing of all
  1731. @command{tar} operations and options, with brief descriptions and cross
  1732. references to more in-depth explanations in the body of the manual.
  1733. They also contain an alphabetically arranged table of the short option
  1734. forms with their corresponding long option. You can use this table as
  1735. a reference for deciphering @command{tar} commands in scripts.
  1736. @menu
  1737. * Operation Summary::
  1738. * Option Summary::
  1739. * Short Option Summary::
  1740. @end menu
  1741. @node Operation Summary
  1742. @subsection Operations
  1743. @table @option
  1744. @opindex append, summary
  1745. @item --append
  1746. @itemx -r
  1747. Appends files to the end of the archive. @xref{append}.
  1748. @opindex catenate, summary
  1749. @item --catenate
  1750. @itemx -A
  1751. Same as @option{--concatenate}. @xref{concatenate}.
  1752. @opindex compare, summary
  1753. @item --compare
  1754. @itemx -d
  1755. Compares archive members with their counterparts in the file
  1756. system, and reports differences in file size, mode, owner,
  1757. modification date and contents. @xref{compare}.
  1758. @opindex concatenate, summary
  1759. @item --concatenate
  1760. @itemx -A
  1761. Appends other @command{tar} archives to the end of the archive.
  1762. @xref{concatenate}.
  1763. @opindex create, summary
  1764. @item --create
  1765. @itemx -c
  1766. Creates a new @command{tar} archive. @xref{create}.
  1767. @opindex delete, summary
  1768. @item --delete
  1769. Deletes members from the archive. Don't try this on a archive on a
  1770. tape! @xref{delete}.
  1771. @opindex diff, summary
  1772. @item --diff
  1773. @itemx -d
  1774. Same @option{--compare}. @xref{compare}.
  1775. @opindex extract, summary
  1776. @item --extract
  1777. @itemx -x
  1778. Extracts members from the archive into the file system. @xref{extract}.
  1779. @opindex get, summary
  1780. @item --get
  1781. @itemx -x
  1782. Same as @option{--extract}. @xref{extract}.
  1783. @opindex list, summary
  1784. @item --list
  1785. @itemx -t
  1786. Lists the members in an archive. @xref{list}.
  1787. @opindex update, summary
  1788. @item --update
  1789. @itemx -u
  1790. @FIXME{It was: A combination of the @option{--compare} and
  1791. @option{--append} operations. This is not true and rather misleading,
  1792. as @option{--compare} (@option{--diff}, @option{-d}) does a lot more than @option{--update} (@option{-u}) for
  1793. ensuring files are identical.} Adds files to the end of the archive,
  1794. but only if they are newer than their counterparts already in the
  1795. archive, or if they do not already exist in the archive.
  1796. @xref{update}.
  1797. @end table
  1798. @node Option Summary
  1799. @subsection @command{tar} Options
  1800. @table @option
  1801. @opindex absolute-names, summary
  1802. @item --absolute-names
  1803. @itemx -P
  1804. Normally when creating an archive, @command{tar} strips an initial
  1805. @samp{/} from member names. This option disables that behavior.
  1806. @xref{absolute}.
  1807. @opindex after-date, summary
  1808. @item --after-date
  1809. (See @option{--newer}, @pxref{after})
  1810. @opindex anchored, summary
  1811. @item --anchored
  1812. An exclude pattern must match an initial subsequence of the name's components.
  1813. @xref{controlling pattern-matching with exclude}.
  1814. @opindex atime-preserve, summary
  1815. @item --atime-preserve
  1816. @itemx --atime-preserve=replace
  1817. @itemx --atime-preserve=system
  1818. Attempt to preserve the access time of files when reading them. This
  1819. option currently is effective only on files that you own, unless you
  1820. have superuser privileges.
  1821. @option{--atime-preserve=replace} remembers the access time of a file
  1822. before reading it, and then restores the access time afterwards. This
  1823. may cause problems if other programs are reading the file at the same
  1824. time, as the times of their accesses will be lost. On most platforms
  1825. restoring the access time also requires @command{tar} to restore the
  1826. data modification time too, so this option may also cause problems if
  1827. other programs are writing the file at the same time. (Tar attempts
  1828. to detect this situation, but cannot do so reliably due to race
  1829. conditions.) Worse, on most platforms restoring the access time also
  1830. updates the status change time, which means that this option is
  1831. incompatible with incremental backups.
  1832. @option{--atime-preserve=system} avoids changing time stamps on files,
  1833. without interfering with time stamp updates
  1834. caused by other programs, so it works better with incremental backups.
  1835. However, it requires a special @code{O_NOATIME} option from the
  1836. underlying operating and file system implementation, and it also requires
  1837. that searching directories does not update their access times. As of
  1838. this writing (November 2005) this works only with Linux, and only with
  1839. Linux kernels 2.6.8 and later. Worse, there is currently no reliable
  1840. way to know whether this feature actually works. Sometimes
  1841. @command{tar} knows that it does not work, and if you use
  1842. @option{--atime-preserve=system} then @command{tar} complains and
  1843. exits right away. But other times @command{tar} might think that the
  1844. option works when it actually does not.
  1845. Currently @option{--atime-preserve} with no operand defaults to
  1846. @option{--atime-preserve=replace}, but this may change in the future
  1847. as support for @option{--atime-preserve=system} improves.
  1848. If your operating system does not support
  1849. @option{--atime-preserve=system}, you might be able to preserve access
  1850. times reliably by by using the @command{mount} command. For example,
  1851. you can mount the file system read-only, or access the file system via
  1852. a read-only loopback mount, or use the @samp{noatime} mount option
  1853. available on some systems. However, mounting typically requires
  1854. superuser privileges and can be a pain to manage.
  1855. @opindex backup, summary
  1856. @item --backup=@var{backup-type}
  1857. Rather than deleting files from the file system, @command{tar} will
  1858. back them up using simple or numbered backups, depending upon
  1859. @var{backup-type}. @xref{backup}.
  1860. @opindex block-number, summary
  1861. @item --block-number
  1862. @itemx -R
  1863. With this option present, @command{tar} prints error messages for read errors
  1864. with the block number in the archive file. @xref{block-number}.
  1865. @opindex blocking-factor, summary
  1866. @item --blocking-factor=@var{blocking}
  1867. @itemx -b @var{blocking}
  1868. Sets the blocking factor @command{tar} uses to @var{blocking} x 512 bytes per
  1869. record. @xref{Blocking Factor}.
  1870. @opindex bzip2, summary
  1871. @item --bzip2
  1872. @itemx -j
  1873. This option tells @command{tar} to read or write archives through
  1874. @code{bzip2}. @xref{gzip}.
  1875. @opindex checkpoint, summary
  1876. @item --checkpoint
  1877. This option directs @command{tar} to print periodic checkpoint messages as it
  1878. reads through the archive. Its intended for when you want a visual
  1879. indication that @command{tar} is still running, but don't want to see
  1880. @option{--verbose} output. @FIXME-xref{}
  1881. @opindex check-links, summary
  1882. @item --check-links
  1883. @itemx -l
  1884. If this option was given, @command{tar} will check the number of links
  1885. dumped for each processed file. If this number does not match the
  1886. total number of hard links for the file, a warning message will be
  1887. output.
  1888. Future versions will take @option{-l} as a short version of
  1889. @option{--check-links}. However, current release still retains the old
  1890. semantics for @option{-l}.
  1891. @xref{Current status}, for more information.
  1892. @opindex compress, summary
  1893. @opindex uncompress, summary
  1894. @item --compress
  1895. @itemx --uncompress
  1896. @itemx -Z
  1897. @command{tar} will use the @command{compress} program when reading or
  1898. writing the archive. This allows you to directly act on archives
  1899. while saving space. @xref{gzip}.
  1900. @opindex confirmation, summary
  1901. @item --confirmation
  1902. (See @option{--interactive}.) @xref{interactive}.
  1903. @opindex dereference, summary
  1904. @item --dereference
  1905. @itemx -h
  1906. When creating a @command{tar} archive, @command{tar} will archive the
  1907. file that a symbolic link points to, rather than archiving the
  1908. symlink. @xref{dereference}.
  1909. @opindex directory, summary
  1910. @item --directory=@var{dir}
  1911. @itemx -C @var{dir}
  1912. When this option is specified, @command{tar} will change its current directory
  1913. to @var{dir} before performing any operations. When this option is used
  1914. during archive creation, it is order sensitive. @xref{directory}.
  1915. @opindex exclude, summary
  1916. @item --exclude=@var{pattern}
  1917. When performing operations, @command{tar} will skip files that match
  1918. @var{pattern}. @xref{exclude}.
  1919. @opindex exclude-from, summary
  1920. @item --exclude-from=@var{file}
  1921. @itemx -X @var{file}
  1922. Similar to @option{--exclude}, except @command{tar} will use the list of
  1923. patterns in the file @var{file}. @xref{exclude}.
  1924. @opindex exclude-caches, summary
  1925. @item --exclude-caches
  1926. Automatically excludes all directories
  1927. containing a cache directory tag. @xref{exclude}.
  1928. @opindex file, summary
  1929. @item --file=@var{archive}
  1930. @itemx -f @var{archive}
  1931. @command{tar} will use the file @var{archive} as the @command{tar} archive it
  1932. performs operations on, rather than @command{tar}'s compilation dependent
  1933. default. @xref{file tutorial}.
  1934. @opindex files-from, summary
  1935. @item --files-from=@var{file}
  1936. @itemx -T @var{file}
  1937. @command{tar} will use the contents of @var{file} as a list of archive members
  1938. or files to operate on, in addition to those specified on the
  1939. command-line. @xref{files}.
  1940. @opindex force-local, summary
  1941. @item --force-local
  1942. Forces @command{tar} to interpret the filename given to @option{--file}
  1943. as a local file, even if it looks like a remote tape drive name.
  1944. @xref{local and remote archives}.
  1945. @opindex format, summary
  1946. @item --format=@var{format}
  1947. Selects output archive format. @var{Format} may be one of the
  1948. following:
  1949. @table @samp
  1950. @item v7
  1951. Creates an archive that is compatible with Unix V7 @command{tar}.
  1952. @item oldgnu
  1953. Creates an archive that is compatible with GNU @command{tar} version
  1954. 1.12 or earlier.
  1955. @item gnu
  1956. Creates archive in GNU tar 1.13 format. Basically it is the same as
  1957. @samp{oldgnu} with the only difference in the way it handles long
  1958. numeric fields.
  1959. @item ustar
  1960. Creates a @acronym{POSIX.1-1988} compatible archive.
  1961. @item posix
  1962. Creates a @acronym{POSIX.1-2001 archive}.
  1963. @end table
  1964. @xref{Formats}, for a detailed discussion of these formats.
  1965. @opindex group, summary
  1966. @item --group=@var{group}
  1967. Files added to the @command{tar} archive will have a group id of @var{group},
  1968. rather than the group from the source file. @var{group} is first decoded
  1969. as a group symbolic name, but if this interpretation fails, it has to be
  1970. a decimal numeric group ID. @FIXME-xref{}
  1971. Also see the comments for the @option{--owner=@var{user}} option.
  1972. @opindex gzip, summary
  1973. @opindex gunzip, summary
  1974. @opindex ungzip, summary
  1975. @item --gzip
  1976. @itemx --gunzip
  1977. @itemx --ungzip
  1978. @itemx -z
  1979. This option tells @command{tar} to read or write archives through
  1980. @command{gzip}, allowing @command{tar} to directly operate on several
  1981. kinds of compressed archives transparently. @xref{gzip}.
  1982. @opindex help, summary
  1983. @item --help
  1984. @command{tar} will print out a short message summarizing the operations and
  1985. options to @command{tar} and exit. @xref{help}.
  1986. @opindex ignore-case, summary
  1987. @item --ignore-case
  1988. Ignore case when excluding files. @xref{controlling pattern-matching
  1989. with exclude}.
  1990. @opindex ignore-command-error, summary
  1991. @item --ignore-command-error
  1992. Ignore exit codes of subprocesses. @xref{Writing to an External Program}.
  1993. @opindex ignore-failed-read, summary
  1994. @item --ignore-failed-read
  1995. Do not exit unsuccessfully merely because an unreadable file was encountered.
  1996. @xref{Reading}.
  1997. @opindex ignore-zeros, summary
  1998. @item --ignore-zeros
  1999. @itemx -i
  2000. With this option, @command{tar} will ignore zeroed blocks in the
  2001. archive, which normally signals EOF. @xref{Reading}.
  2002. @opindex incremental, summary
  2003. @item --incremental
  2004. @itemx -G
  2005. Used to inform @command{tar} that it is working with an old
  2006. @acronym{GNU}-format incremental backup archive. It is intended
  2007. primarily for backwards compatibility only. @FIXME{incremental and
  2008. listed-incremental}.
  2009. @opindex index-file, summary
  2010. @item --index-file=@var{file}
  2011. Send verbose output to @var{file} instead of to standard output.
  2012. @opindex info-script, summary
  2013. @opindex new-volume-script, summary
  2014. @item --info-script=@var{script-file}
  2015. @itemx --new-volume-script=@var{script-file}
  2016. @itemx -F @var{script-file}
  2017. When @command{tar} is performing multi-tape backups, @var{script-file} is run
  2018. at the end of each tape. If @var{script-file} exits with nonzero status,
  2019. @command{tar} fails immediately. @xref{info-script}, for a detailed
  2020. discussion of @var{script-file}.
  2021. @opindex interactive, summary
  2022. @item --interactive
  2023. @itemx --confirmation
  2024. @itemx -w
  2025. Specifies that @command{tar} should ask the user for confirmation before
  2026. performing potentially destructive options, such as overwriting files.
  2027. @xref{interactive}.
  2028. @opindex keep-newer-files, summary
  2029. @item --keep-newer-files
  2030. Do not replace existing files that are newer than their archive copies
  2031. when extracting files from an archive.
  2032. @opindex keep-old-files, summary
  2033. @item --keep-old-files
  2034. @itemx -k
  2035. Do not overwrite existing files when extracting files from an archive.
  2036. @xref{Keep Old Files}.
  2037. @opindex label, summary
  2038. @item --label=@var{name}
  2039. @itemx -V @var{name}
  2040. When creating an archive, instructs @command{tar} to write @var{name}
  2041. as a name record in the archive. When extracting or listing archives,
  2042. @command{tar} will only operate on archives that have a label matching
  2043. the pattern specified in @var{name}. @xref{Tape Files}.
  2044. @opindex listed-incremental, summary
  2045. @item --listed-incremental=@var{snapshot-file}
  2046. @itemx -g @var{snapshot-file}
  2047. During a @option{--create} operation, specifies that the archive that
  2048. @command{tar} creates is a new @acronym{GNU}-format incremental
  2049. backup, using @var{snapshot-file} to determine which files to backup.
  2050. With other operations, informs @command{tar} that the archive is in
  2051. incremental format. @FIXME{incremental and listed-incremental}.
  2052. @opindex mode, summary
  2053. @item --mode=@var{permissions}
  2054. When adding files to an archive, @command{tar} will use
  2055. @var{permissions} for the archive members, rather than the permissions
  2056. from the files. The program @command{chmod} and this @command{tar}
  2057. option share the same syntax for what @var{permissions} might be.
  2058. @xref{File permissions, Permissions, File permissions, fileutils,
  2059. @acronym{GNU} file utilities}. This reference also has useful
  2060. information for those not being overly familiar with the Unix
  2061. permission system.
  2062. Of course, @var{permissions} might be plainly specified as an octal number.
  2063. However, by using generic symbolic modifications to mode bits, this allows
  2064. more flexibility. For example, the value @samp{a+rw} adds read and write
  2065. permissions for everybody, while retaining executable bits on directories
  2066. or on any other file already marked as executable.
  2067. @opindex multi-volume, summary
  2068. @item --multi-volume
  2069. @itemx -M
  2070. Informs @command{tar} that it should create or otherwise operate on a
  2071. multi-volume @command{tar} archive. @xref{Using Multiple Tapes}.
  2072. @opindex new-volume-script, summary
  2073. @item --new-volume-script
  2074. (see --info-script)
  2075. @opindex seek, summary
  2076. @item --seek
  2077. @itemx -n
  2078. Assume that the archive media supports seeks to arbitrary
  2079. locations. Usually @command{tar} determines automatically whether
  2080. the archive can be seeked or not. This option is intended for use
  2081. in cases when such recognition fails.
  2082. @opindex newer, summary
  2083. @item --newer=@var{date}
  2084. @itemx --after-date=@var{date}
  2085. @itemx -N
  2086. When creating an archive, @command{tar} will only add files that have changed
  2087. since @var{date}. If @var{date} begins with @samp{/} or @samp{.}, it
  2088. is taken to be the name of a file whose data modification time specifies
  2089. the date. @xref{after}.
  2090. @opindex newer-mtime, summary
  2091. @item --newer-mtime=@var{date}
  2092. Like @option{--newer}, but add only files whose
  2093. contents have changed (as opposed to just @option{--newer}, which will
  2094. also back up files for which any status information has changed).
  2095. @opindex no-anchored, summary
  2096. @item --no-anchored
  2097. An exclude pattern can match any subsequence of the name's components.
  2098. @xref{controlling pattern-matching with exclude}.
  2099. @opindex no-ignore-case, summary
  2100. @item --no-ignore-case
  2101. Use case-sensitive matching when excluding files.
  2102. @xref{controlling pattern-matching with exclude}.
  2103. @opindex no-ignore-command-error, summary
  2104. @item --no-ignore-command-error
  2105. Print warnings about subprocesses terminated with a non-zero exit
  2106. code. @xref{Writing to an External Program}.
  2107. @opindex no-recursion, summary
  2108. @item --no-recursion
  2109. With this option, @command{tar} will not recurse into directories.
  2110. @xref{recurse}.
  2111. @opindex no-same-owner, summary
  2112. @item --no-same-owner
  2113. @itemx -o
  2114. When extracting an archive, do not attempt to preserve the owner
  2115. specified in the @command{tar} archive. This the default behavior
  2116. for ordinary users.
  2117. @opindex no-same-permissions, summary
  2118. @item --no-same-permissions
  2119. When extracting an archive, subtract the user's umask from files from
  2120. the permissions specified in the archive. This is the default behavior
  2121. for ordinary users.
  2122. @opindex no-wildcards, summary
  2123. @item --no-wildcards
  2124. Do not use wildcards when excluding files.
  2125. @xref{controlling pattern-matching with exclude}.
  2126. @opindex no-wildcards-match-slash, summary
  2127. @item --no-wildcards-match-slash
  2128. Wildcards do not match @samp{/} when excluding files.
  2129. @xref{controlling pattern-matching with exclude}.
  2130. @opindex null, summary
  2131. @item --null
  2132. When @command{tar} is using the @option{--files-from} option, this option
  2133. instructs @command{tar} to expect filenames terminated with @option{NUL}, so
  2134. @command{tar} can correctly work with file names that contain newlines.
  2135. @xref{nul}.
  2136. @opindex numeric-owner, summary
  2137. @item --numeric-owner
  2138. This option will notify @command{tar} that it should use numeric user
  2139. and group IDs when creating a @command{tar} file, rather than names.
  2140. @xref{Attributes}.
  2141. @item -o
  2142. When extracting files, this option is a synonym for
  2143. @option{--no-same-owner}, i.e. it prevents @command{tar} from
  2144. restoring ownership of files being extracted.
  2145. When creating an archive, @option{-o} is a synonym for
  2146. @option{--old-archive}. This behavior is for compatibility
  2147. with previous versions of @GNUTAR{}, and will be
  2148. removed in the future releases.
  2149. @xref{Current status}, for more information.
  2150. @opindex occurrence, summary
  2151. @item --occurrence[=@var{number}]
  2152. This option can be used in conjunction with one of the subcommands
  2153. @option{--delete}, @option{--diff}, @option{--extract} or
  2154. @option{--list} when a list of files is given either on the command
  2155. line or via @option{-T} option.
  2156. This option instructs @command{tar} to process only the @var{number}th
  2157. occurrence of each named file. @var{Number} defaults to 1, so
  2158. @smallexample
  2159. tar -x -f archive.tar --occurrence filename
  2160. @end smallexample
  2161. @noindent
  2162. will extract the first occurrence of @file{filename} from @file{archive.tar}
  2163. and will terminate without scanning to the end of the archive.
  2164. @opindex old-archive, summary
  2165. @item --old-archive
  2166. Synonym for @option{--format=v7}.
  2167. @opindex one-file-system, summary
  2168. @item --one-file-system
  2169. @itemx -l
  2170. Used when creating an archive. Prevents @command{tar} from recursing into
  2171. directories that are on different file systems from the current
  2172. directory.
  2173. Earlier versions of @GNUTAR{} understood @option{-l} as a
  2174. synonym for @option{--one-file-system}. Although such usage is still
  2175. allowed in the present version, it is @emph{strongly discouraged}.
  2176. The future versions of @GNUTAR{} will use @option{-l} as
  2177. a synonym for @option{--check-links}.
  2178. @xref{Current status}, for more information.
  2179. @opindex overwrite, summary
  2180. @item --overwrite
  2181. Overwrite existing files and directory metadata when extracting files
  2182. from an archive. @xref{Overwrite Old Files}.
  2183. @opindex overwrite-dir, summary
  2184. @item --overwrite-dir
  2185. Overwrite the metadata of existing directories when extracting files
  2186. from an archive. @xref{Overwrite Old Files}.
  2187. @opindex owner, summary
  2188. @item --owner=@var{user}
  2189. Specifies that @command{tar} should use @var{user} as the owner of members
  2190. when creating archives, instead of the user associated with the source
  2191. file. @var{user} is first decoded as a user symbolic name, but if
  2192. this interpretation fails, it has to be a decimal numeric user ID.
  2193. @FIXME-xref{}
  2194. There is no value indicating a missing number, and @samp{0} usually means
  2195. @code{root}. Some people like to force @samp{0} as the value to offer in
  2196. their distributions for the owner of files, because the @code{root} user is
  2197. anonymous anyway, so that might as well be the owner of anonymous archives.
  2198. This option does not affect extraction from archives.
  2199. @opindex pax-option, summary
  2200. @item --pax-option=@var{keyword-list}
  2201. @FIXME{Such a detailed description does not belong there, move it elsewhere.}
  2202. This option is meaningful only with @acronym{POSIX.1-2001} archives
  2203. (@pxref{posix}). It modifies the way @command{tar} handles the
  2204. extended header keywords. @var{Keyword-list} is a comma-separated
  2205. list of keyword options, each keyword option taking one of
  2206. the following forms:
  2207. @table @asis
  2208. @item delete=@var{pattern}
  2209. When used with one of archive-creation commands,
  2210. this option instructs @command{tar} to omit from extended header records
  2211. that it produces any keywords matching the string @var{pattern}.
  2212. When used in extract or list mode, this option instructs tar
  2213. to ignore any keywords matching the given @var{pattern} in the extended
  2214. header records. In both cases, matching is performed using the pattern
  2215. matching notation described in @acronym{POSIX 1003.2}, 3.13
  2216. (See @cite{glob(7)}). For example:
  2217. @smallexample
  2218. --pax-option delete=security.*
  2219. @end smallexample
  2220. would suppress security-related information.
  2221. @item exthdr.name=@var{string}
  2222. This keyword allows user control over the name that is written into the
  2223. ustar header blocks for the extended headers. The name is obtained
  2224. from @var{string} after substituting the following meta-characters:
  2225. @multitable @columnfractions .30 .70
  2226. @headitem Meta-character @tab Replaced By
  2227. @item %d @tab The directory name of the file, equivalent to the
  2228. result of the @command{dirname} utility on the translated pathname.
  2229. @item %f @tab The filename of the file, equivalent to the result
  2230. of the @command{basename} utility on the translated pathname.
  2231. @item %p @tab The process ID of the @command{tar} process.
  2232. @item %% @tab A @samp{%} character.
  2233. @end multitable
  2234. Any other @samp{%} characters in @var{string} produce undefined
  2235. results.
  2236. If no option @samp{exthdr.name=string} is specified, @command{tar}
  2237. will use the following default value:
  2238. @smallexample
  2239. %d/PaxHeaders.%p/%f
  2240. @end smallexample
  2241. @item globexthdr.name=@var{string}
  2242. This keyword allows user control over the name that is written into
  2243. the ustar header blocks for global extended header records. The name
  2244. shall will be obtained from the contents of @var{string}, after the
  2245. following character substitutions have been made:
  2246. @multitable @columnfractions .30 .70
  2247. @headitem Meta-character @tab Replaced By
  2248. @item %n @tab An integer that represents the
  2249. sequence number of the global extended header record in the archive,
  2250. starting at 1.
  2251. @item %p @tab The process ID of the @command{tar} process.
  2252. @item %% @tab A @samp{%} character.
  2253. @end multitable
  2254. Any other @samp{%} characters in string produce undefined results.
  2255. If no option @samp{globexthdr.name=string} is specified, @command{tar}
  2256. will use the following default value:
  2257. @smallexample
  2258. $TMPDIR/GlobalHead.%p.%n
  2259. @end smallexample
  2260. @noindent
  2261. where @samp{$TMPDIR} represents the value of the @var{TMPDIR}
  2262. environment variable. If @var{TMPDIR} is not set, @command{tar}
  2263. uses @samp{/tmp}.
  2264. @item @var{keyword}=@var{value}
  2265. When used with one of archive-creation commands, these keyword/value pairs
  2266. will be included at the beginning of the archive in a global extended
  2267. header record. When used with one of archive-reading commands,
  2268. @command{tar} will behave as if it has encountered these keyword/value
  2269. pairs at the beginning of the archive in a global extended header
  2270. record.
  2271. @item @var{keyword}:=@var{value}
  2272. When used with one of archive-creation commands, these keyword/value pairs
  2273. will be included as records at the beginning of an extended header for
  2274. each file. This is effectively equivalent to @var{keyword}=@var{value}
  2275. form except that it creates no global extended header records.
  2276. When used with one of archive-reading commands, @command{tar} will
  2277. behave as if these keyword/value pairs were included as records at the
  2278. end of each extended header; thus, they will override any global or
  2279. file-specific extended header record keywords of the same names.
  2280. For example, in the command:
  2281. @smallexample
  2282. tar --format=posix --create \
  2283. --file archive --pax-option gname:=user .
  2284. @end smallexample
  2285. the group name will be forced to a new value for all files
  2286. stored in the archive.
  2287. @end table
  2288. @opindex portability, summary
  2289. @item --portability
  2290. @itemx --old-archive
  2291. Synonym for @option{--format=v7}.
  2292. @opindex posix, summary
  2293. @item --posix
  2294. Same as @option{--format=posix}.
  2295. @opindex preserve, summary
  2296. @item --preserve
  2297. Synonymous with specifying both @option{--preserve-permissions} and
  2298. @option{--same-order}. @xref{Setting Access Permissions}.
  2299. @opindex preserve-order, summary
  2300. @item --preserve-order
  2301. (See @option{--same-order}; @pxref{Reading}.)
  2302. @opindex preserve-permissions, summary
  2303. @opindex same-permissions, summary
  2304. @item --preserve-permissions
  2305. @itemx --same-permissions
  2306. @itemx -p
  2307. When @command{tar} is extracting an archive, it normally subtracts the
  2308. users' umask from the permissions specified in the archive and uses
  2309. that number as the permissions to create the destination file.
  2310. Specifying this option instructs @command{tar} that it should use the
  2311. permissions directly from the archive. @xref{Setting Access Permissions}.
  2312. @opindex read-full-records, summary
  2313. @item --read-full-records
  2314. @itemx -B
  2315. Specifies that @command{tar} should reblock its input, for reading
  2316. from pipes on systems with buggy implementations. @xref{Reading}.
  2317. @opindex record-size, summary
  2318. @item --record-size=@var{size}
  2319. Instructs @command{tar} to use @var{size} bytes per record when accessing the
  2320. archive. @xref{Blocking Factor}.
  2321. @opindex recursion, summary
  2322. @item --recursion
  2323. With this option, @command{tar} recurses into directories.
  2324. @xref{recurse}.
  2325. @opindex recursive-unlink, summary
  2326. @item --recursive-unlink
  2327. Remove existing
  2328. directory hierarchies before extracting directories of the same name
  2329. from the archive. @xref{Recursive Unlink}.
  2330. @opindex remove-files, summary
  2331. @item --remove-files
  2332. Directs @command{tar} to remove the source file from the file system after
  2333. appending it to an archive. @xref{remove files}.
  2334. @opindex restrict, summary
  2335. @item --restrict
  2336. Disable use of some potentially harmful @command{tar} options.
  2337. Currently this option disables shell invocaton from multi-volume menu
  2338. (@pxref{Using Multiple Tapes}).
  2339. @opindex rmt-command, summary
  2340. @item --rmt-command=@var{cmd}
  2341. Notifies @command{tar} that it should use @var{cmd} instead of
  2342. the default @file{/usr/libexec/rmt} (@pxref{Remote Tape Server}).
  2343. @opindex rsh-command, summary
  2344. @item --rsh-command=@var{cmd}
  2345. Notifies @command{tar} that is should use @var{cmd} to communicate with remote
  2346. devices. @xref{Device}.
  2347. @opindex same-order, summary
  2348. @item --same-order
  2349. @itemx --preserve-order
  2350. @itemx -s
  2351. This option is an optimization for @command{tar} when running on machines with
  2352. small amounts of memory. It informs @command{tar} that the list of file
  2353. arguments has already been sorted to match the order of files in the
  2354. archive. @xref{Reading}.
  2355. @opindex same-owner, summary
  2356. @item --same-owner
  2357. When extracting an archive, @command{tar} will attempt to preserve the owner
  2358. specified in the @command{tar} archive with this option present.
  2359. This is the default behavior for the superuser; this option has an
  2360. effect only for ordinary users. @xref{Attributes}.
  2361. @opindex same-permissions, summary
  2362. @item --same-permissions
  2363. (See @option{--preserve-permissions}; @pxref{Setting Access Permissions}.)
  2364. @opindex show-defaults, summary
  2365. @item --show-defaults
  2366. Displays the default options used by @command{tar} and exits
  2367. successfully. This option is intended for use in shell scripts.
  2368. Here is an example of what you can see using this option:
  2369. @smallexample
  2370. $ tar --show-defaults
  2371. --format=gnu -f- -b20
  2372. @end smallexample
  2373. @opindex show-omitted-dirs, summary
  2374. @item --show-omitted-dirs
  2375. Instructs @command{tar} to mention directories its skipping over when
  2376. operating on a @command{tar} archive. @xref{show-omitted-dirs}.
  2377. @opindex show-stored-names, summary
  2378. @item --show-stored-names
  2379. This option has effect only when used in conjunction with one of
  2380. archive creation operations. It instructs tar to list the member names
  2381. stored in the archive, as opposed to the actual file
  2382. names. @xref{listing member and file names}.
  2383. @opindex sparse, summary
  2384. @item --sparse
  2385. @itemx -S
  2386. Invokes a @acronym{GNU} extension when adding files to an archive that handles
  2387. sparse files efficiently. @xref{sparse}.
  2388. @opindex starting-file, summary
  2389. @item --starting-file=@var{name}
  2390. @itemx -K @var{name}
  2391. This option affects extraction only; @command{tar} will skip extracting
  2392. files in the archive until it finds one that matches @var{name}.
  2393. @xref{Scarce}.
  2394. @opindex strip-components, summary
  2395. @item --strip-components=@var{number}
  2396. Strip given @var{number} of leading components from file names before
  2397. extraction.@footnote{This option was called @option{--strip-path} in
  2398. version 1.14.} For example, if archive @file{archive.tar} contained
  2399. @file{/some/file/name}, then running
  2400. @smallexample
  2401. tar --extract --file archive.tar --strip-components=2
  2402. @end smallexample
  2403. @noindent
  2404. would extracted this file to file @file{name}.
  2405. @opindex suffix, summary
  2406. @item --suffix=@var{suffix}
  2407. Alters the suffix @command{tar} uses when backing up files from the default
  2408. @samp{~}. @xref{backup}.
  2409. @opindex tape-length, summary
  2410. @item --tape-length=@var{num}
  2411. @itemx -L @var{num}
  2412. Specifies the length of tapes that @command{tar} is writing as being
  2413. @w{@var{num} x 1024} bytes long. @xref{Using Multiple Tapes}.
  2414. @opindex test-label, summary
  2415. @item --test-label
  2416. Reads the volume label. If an argument is specified, test whether it
  2417. matches the volume label. @xref{--test-label option}.
  2418. @opindex to-command, summary
  2419. @item --to-command=@var{command}
  2420. During extraction @command{tar} will pipe extracted files to the
  2421. standard input of @var{command}. @xref{Writing to an External Program}.
  2422. @opindex to-stdout, summary
  2423. @item --to-stdout
  2424. @itemx -O
  2425. During extraction, @command{tar} will extract files to stdout rather
  2426. than to the file system. @xref{Writing to Standard Output}.
  2427. @opindex totals, summary
  2428. @item --totals
  2429. Displays the total number of bytes written after creating an archive.
  2430. @xref{verbose}.
  2431. @opindex touch, summary
  2432. @item --touch
  2433. @itemx -m
  2434. Sets the data modification time of extracted files to the extraction time,
  2435. rather than the data modification time stored in the archive.
  2436. @xref{Data Modification Times}.
  2437. @opindex uncompress, summary
  2438. @item --uncompress
  2439. (See @option{--compress}. @pxref{gzip})
  2440. @opindex ungzip, summary
  2441. @item --ungzip
  2442. (See @option{--gzip}. @pxref{gzip})
  2443. @opindex unlink-first, summary
  2444. @item --unlink-first
  2445. @itemx -U
  2446. Directs @command{tar} to remove the corresponding file from the file
  2447. system before extracting it from the archive. @xref{Unlink First}.
  2448. @opindex use-compress-program, summary
  2449. @item --use-compress-program=@var{prog}
  2450. Instructs @command{tar} to access the archive through @var{prog}, which is
  2451. presumed to be a compression program of some sort. @xref{gzip}.
  2452. @opindex utc, summary
  2453. @item --utc
  2454. Display file modification dates in @acronym{UTC}. This option implies
  2455. @option{--verbose}.
  2456. @opindex verbose, summary
  2457. @item --verbose
  2458. @itemx -v
  2459. Specifies that @command{tar} should be more verbose about the operations its
  2460. performing. This option can be specified multiple times for some
  2461. operations to increase the amount of information displayed.
  2462. @xref{verbose}.
  2463. @opindex verify, summary
  2464. @item --verify
  2465. @itemx -W
  2466. Verifies that the archive was correctly written when creating an
  2467. archive. @xref{verify}.
  2468. @opindex version, summary
  2469. @item --version
  2470. @command{tar} will print an informational message about what version
  2471. it is and a copyright message, some credits, and then exit.
  2472. @xref{help}.
  2473. @opindex volno-file, summary
  2474. @item --volno-file=@var{file}
  2475. Used in conjunction with @option{--multi-volume}. @command{tar} will keep track
  2476. of which volume of a multi-volume archive its working in @var{file}.
  2477. @xref{volno-file}.
  2478. @opindex wildcards, summary
  2479. @item --wildcards
  2480. Use wildcards when excluding files.
  2481. @xref{controlling pattern-matching with exclude}.
  2482. @opindex wildcards-match-slash, summary
  2483. @item --wildcards-match-slash
  2484. Wildcards match @samp{/} when excluding files.
  2485. @xref{controlling pattern-matching with exclude}.
  2486. @end table
  2487. @node Short Option Summary
  2488. @subsection Short Options Cross Reference
  2489. Here is an alphabetized list of all of the short option forms, matching
  2490. them with the equivalent long option.
  2491. @table @option
  2492. @item -A
  2493. @option{--concatenate}
  2494. @item -B
  2495. @option{--read-full-records}
  2496. @item -C
  2497. @option{--directory}
  2498. @item -F
  2499. @option{--info-script}
  2500. @item -G
  2501. @option{--incremental}
  2502. @item -K
  2503. @option{--starting-file}
  2504. @item -L
  2505. @option{--tape-length}
  2506. @item -M
  2507. @option{--multi-volume}
  2508. @item -N
  2509. @option{--newer}
  2510. @item -O
  2511. @option{--to-stdout}
  2512. @item -P
  2513. @option{--absolute-names}
  2514. @item -R
  2515. @option{--block-number}
  2516. @item -S
  2517. @option{--sparse}
  2518. @item -T
  2519. @option{--files-from}
  2520. @item -U
  2521. @option{--unlink-first}
  2522. @item -V
  2523. @option{--label}
  2524. @item -W
  2525. @option{--verify}
  2526. @item -X
  2527. @option{--exclude-from}
  2528. @item -Z
  2529. @option{--compress}
  2530. @item -b
  2531. @option{--blocking-factor}
  2532. @item -c
  2533. @option{--create}
  2534. @item -d
  2535. @option{--compare}
  2536. @item -f
  2537. @option{--file}
  2538. @item -g
  2539. @option{--listed-incremental}
  2540. @item -h
  2541. @option{--dereference}
  2542. @item -i
  2543. @option{--ignore-zeros}
  2544. @item -j
  2545. @option{--bzip2}
  2546. @item -k
  2547. @option{--keep-old-files}
  2548. @item -l
  2549. @option{--one-file-system}. Use of this short option is deprecated. It
  2550. is retained for compatibility with the earlier versions of GNU
  2551. @command{tar}, and will be changed in future releases.
  2552. @xref{Current status}, for more information.
  2553. @item -m
  2554. @option{--touch}
  2555. @item -o
  2556. When creating --- @option{--no-same-owner}, when extracting ---
  2557. @option{--portability}.
  2558. The later usage is deprecated. It is retained for compatibility with
  2559. the earlier versions of @GNUTAR{}. In the future releases
  2560. @option{-o} will be equivalent to @option{--no-same-owner} only.
  2561. @item -p
  2562. @option{--preserve-permissions}
  2563. @item -r
  2564. @option{--append}
  2565. @item -s
  2566. @option{--same-order}
  2567. @item -t
  2568. @option{--list}
  2569. @item -u
  2570. @option{--update}
  2571. @item -v
  2572. @option{--verbose}
  2573. @item -w
  2574. @option{--interactive}
  2575. @item -x
  2576. @option{--extract}
  2577. @item -z
  2578. @option{--gzip}
  2579. @end table
  2580. @node help
  2581. @section @GNUTAR{} documentation
  2582. @cindex Getting program version number
  2583. @opindex version
  2584. @cindex Version of the @command{tar} program
  2585. Being careful, the first thing is really checking that you are using
  2586. @GNUTAR{}, indeed. The @option{--version} option
  2587. will generate a message giving confirmation that you are using
  2588. @GNUTAR{}, with the precise version of @GNUTAR{}
  2589. you are using. @command{tar} identifies itself and
  2590. prints the version number to the standard output, then immediately
  2591. exits successfully, without doing anything else, ignoring all other
  2592. options. For example, @w{@samp{tar --version}} might return:
  2593. @smallexample
  2594. tar (@acronym{GNU} tar) @value{VERSION}
  2595. @end smallexample
  2596. @noindent
  2597. The first occurrence of @samp{tar} in the result above is the program
  2598. name in the package (for example, @command{rmt} is another program),
  2599. while the second occurrence of @samp{tar} is the name of the package
  2600. itself, containing possibly many programs. The package is currently
  2601. named @samp{tar}, after the name of the main program it
  2602. contains@footnote{There are plans to merge the @command{cpio} and
  2603. @command{tar} packages into a single one which would be called
  2604. @code{paxutils}. So, who knows if, one of this days, the
  2605. @option{--version} would not yield @w{@samp{tar (@acronym{GNU}
  2606. paxutils) 3.2}}}.
  2607. @cindex Obtaining help
  2608. @cindex Listing all @command{tar} options
  2609. @opindex help, introduction
  2610. Another thing you might want to do is checking the spelling or meaning
  2611. of some particular @command{tar} option, without resorting to this
  2612. manual, for once you have carefully read it. @GNUTAR{}
  2613. has a short help feature, triggerable through the
  2614. @option{--help} option. By using this option, @command{tar} will
  2615. print a usage message listing all available options on standard
  2616. output, then exit successfully, without doing anything else and
  2617. ignoring all other options. Even if this is only a brief summary, it
  2618. may be several screens long. So, if you are not using some kind of
  2619. scrollable window, you might prefer to use something like:
  2620. @smallexample
  2621. $ @kbd{tar --help | less}
  2622. @end smallexample
  2623. @noindent
  2624. presuming, here, that you like using @command{less} for a pager. Other
  2625. popular pagers are @command{more} and @command{pg}. If you know about some
  2626. @var{keyword} which interests you and do not want to read all the
  2627. @option{--help} output, another common idiom is doing:
  2628. @smallexample
  2629. tar --help | grep @var{keyword}
  2630. @end smallexample
  2631. @noindent
  2632. for getting only the pertinent lines. Notice, however, that some
  2633. @command{tar} options have long description lines and the above
  2634. command will list only the first of them.
  2635. @opindex usage
  2636. If you only wish to check the spelling of an option, running @kbd{tar
  2637. --usage} may be a better choice. This will display a terse list of
  2638. @command{tar} option without accompanying explanations.
  2639. The short help output is quite succinct, and you might have to get
  2640. back to the full documentation for precise points. If you are reading
  2641. this paragraph, you already have the @command{tar} manual in some
  2642. form. This manual is available in a variety of forms from
  2643. @url{http://www.gnu.org/software/tar/manual}. It may printed out of the @GNUTAR{}
  2644. distribution, provided you have @TeX{} already installed somewhere,
  2645. and a laser printer around. Just configure the distribution, execute
  2646. the command @w{@samp{make dvi}}, then print @file{doc/tar.dvi} the
  2647. usual way (contact your local guru to know how). If @GNUTAR{}
  2648. has been conveniently installed at your place, this
  2649. manual is also available in interactive, hypertextual form as an Info
  2650. file. Just call @w{@samp{info tar}} or, if you do not have the
  2651. @command{info} program handy, use the Info reader provided within
  2652. @acronym{GNU} Emacs, calling @samp{tar} from the main Info menu.
  2653. There is currently no @code{man} page for @GNUTAR{}.
  2654. If you observe such a @code{man} page on the system you are running,
  2655. either it does not belong to @GNUTAR{}, or it has not
  2656. been produced by @acronym{GNU}. Some package maintainers convert
  2657. @kbd{tar --help} output to a man page, using @command{help2man}. In
  2658. any case, please bear in mind that the authoritative source of
  2659. information about @GNUTAR{} is this Texinfo documentation.
  2660. @node defaults
  2661. @section Obtaining @GNUTAR{} default values
  2662. @opindex show-defaults
  2663. @GNUTAR{} has some predefined defaults that are used when you do not
  2664. explicitely specify another values. To obtain a list of such
  2665. defaults, use @option{--show-defaults} option. This will output the
  2666. values in the form of @command{tar} command line options:
  2667. @smallexample
  2668. @group
  2669. @kbd{tar --show-defaults}
  2670. --format=gnu -f- -b20 --rmt-command=/etc/rmt --rsh-command=/usr/bin/rsh
  2671. @end group
  2672. @end smallexample
  2673. @noindent
  2674. The above output shows that this version of @GNUTAR{} defaults to
  2675. using @samp{gnu} archive format (@pxref{Formats}), it uses standard
  2676. output as the archive, if no @option{--file} option has been given
  2677. (@pxref{file tutorial}), the default blocking factor is 20
  2678. (@pxref{Blocking Factor}). It also shows the default locations where
  2679. @command{tar} will look for @command{rmt} and @command{rsh} binaries.
  2680. @node verbose
  2681. @section Checking @command{tar} progress
  2682. Typically, @command{tar} performs most operations without reporting any
  2683. information to the user except error messages. When using @command{tar}
  2684. with many options, particularly ones with complicated or
  2685. difficult-to-predict behavior, it is possible to make serious mistakes.
  2686. @command{tar} provides several options that make observing @command{tar}
  2687. easier. These options cause @command{tar} to print information as it
  2688. progresses in its job, and you might want to use them just for being
  2689. more careful about what is going on, or merely for entertaining
  2690. yourself. If you have encountered a problem when operating on an
  2691. archive, however, you may need more information than just an error
  2692. message in order to solve the problem. The following options can be
  2693. helpful diagnostic tools.
  2694. @cindex Verbose operation
  2695. @opindex verbose
  2696. Normally, the @option{--list} (@option{-t}) command to list an archive
  2697. prints just the file names (one per line) and the other commands are
  2698. silent. When used with most operations, the @option{--verbose}
  2699. (@option{-v}) option causes @command{tar} to print the name of each
  2700. file or archive member as it is processed. This and the other options
  2701. which make @command{tar} print status information can be useful in
  2702. monitoring @command{tar}.
  2703. With @option{--create} or @option{--extract}, @option{--verbose} used
  2704. once just prints the names of the files or members as they are processed.
  2705. Using it twice causes @command{tar} to print a longer listing
  2706. (reminiscent of @samp{ls -l}) for each member. Since @option{--list}
  2707. already prints the names of the members, @option{--verbose} used once
  2708. with @option{--list} causes @command{tar} to print an @samp{ls -l}
  2709. type listing of the files in the archive. The following examples both
  2710. extract members with long list output:
  2711. @smallexample
  2712. $ @kbd{tar --extract --file=archive.tar --verbose --verbose}
  2713. $ @kbd{tar xvvf archive.tar}
  2714. @end smallexample
  2715. Verbose output appears on the standard output except when an archive is
  2716. being written to the standard output, as with @samp{tar --create
  2717. --file=- --verbose} (@samp{tar cfv -}, or even @samp{tar cv}---if the
  2718. installer let standard output be the default archive). In that case
  2719. @command{tar} writes verbose output to the standard error stream.
  2720. If @option{--index-file=@var{file}} is specified, @command{tar} sends
  2721. verbose output to @var{file} rather than to standard output or standard
  2722. error.
  2723. @cindex Obtaining total status information
  2724. @opindex totals
  2725. The @option{--totals} option---which is only meaningful when used with
  2726. @option{--create} (@option{-c})---causes @command{tar} to print the total
  2727. amount written to the archive, after it has been fully created.
  2728. @cindex Progress information
  2729. @opindex checkpoint
  2730. The @option{--checkpoint} option prints an occasional message
  2731. as @command{tar} reads or writes the archive. In fact, it prints
  2732. a message each 10 records read or written. It is designed for
  2733. those who don't need the more detailed (and voluminous) output of
  2734. @option{--block-number} (@option{-R}), but do want visual confirmation that @command{tar}
  2735. is actually making forward progress.
  2736. @FIXME{There is some confusion here. It seems that -R once wrote a
  2737. message at @samp{every} record read or written.}
  2738. @opindex show-omitted-dirs
  2739. @anchor{show-omitted-dirs}
  2740. The @option{--show-omitted-dirs} option, when reading an archive---with
  2741. @option{--list} or @option{--extract}, for example---causes a message
  2742. to be printed for each directory in the archive which is skipped.
  2743. This happens regardless of the reason for skipping: the directory might
  2744. not have been named on the command line (implicitly or explicitly),
  2745. it might be excluded by the use of the @option{--exclude=@var{pattern}} option, or
  2746. some other reason.
  2747. @opindex block-number
  2748. @cindex Block number where error occurred
  2749. @anchor{block-number}
  2750. If @option{--block-number} (@option{-R}) is used, @command{tar} prints, along with
  2751. every message it would normally produce, the block number within the
  2752. archive where the message was triggered. Also, supplementary messages
  2753. are triggered when reading blocks full of NULs, or when hitting end of
  2754. file on the archive. As of now, if the archive if properly terminated
  2755. with a NUL block, the reading of the file may stop before end of file
  2756. is met, so the position of end of file will not usually show when
  2757. @option{--block-number} (@option{-R}) is used. Note that @GNUTAR{}
  2758. drains the archive before exiting when reading the
  2759. archive from a pipe.
  2760. @cindex Error message, block number of
  2761. This option is especially useful when reading damaged archives, since
  2762. it helps pinpoint the damaged sections. It can also be used with
  2763. @option{--list} (@option{-t}) when listing a file-system backup tape, allowing you to
  2764. choose among several backup tapes when retrieving a file later, in
  2765. favor of the tape where the file appears earliest (closest to the
  2766. front of the tape). @xref{backup}.
  2767. @node interactive
  2768. @section Asking for Confirmation During Operations
  2769. @cindex Interactive operation
  2770. Typically, @command{tar} carries out a command without stopping for
  2771. further instructions. In some situations however, you may want to
  2772. exclude some files and archive members from the operation (for instance
  2773. if disk or storage space is tight). You can do this by excluding
  2774. certain files automatically (@pxref{Choosing}), or by performing
  2775. an operation interactively, using the @option{--interactive} (@option{-w}) option.
  2776. @command{tar} also accepts @option{--confirmation} for this option.
  2777. @opindex interactive
  2778. When the @option{--interactive} (@option{-w}) option is specified, before
  2779. reading, writing, or deleting files, @command{tar} first prints a message
  2780. for each such file, telling what operation it intends to take, then asks
  2781. for confirmation on the terminal. The actions which require
  2782. confirmation include adding a file to the archive, extracting a file
  2783. from the archive, deleting a file from the archive, and deleting a file
  2784. from disk. To confirm the action, you must type a line of input
  2785. beginning with @samp{y}. If your input line begins with anything other
  2786. than @samp{y}, @command{tar} skips that file.
  2787. If @command{tar} is reading the archive from the standard input,
  2788. @command{tar} opens the file @file{/dev/tty} to support the interactive
  2789. communications.
  2790. Verbose output is normally sent to standard output, separate from
  2791. other error messages. However, if the archive is produced directly
  2792. on standard output, then verbose output is mixed with errors on
  2793. @code{stderr}. Producing the archive on standard output may be used
  2794. as a way to avoid using disk space, when the archive is soon to be
  2795. consumed by another process reading it, say. Some people felt the need
  2796. of producing an archive on stdout, still willing to segregate between
  2797. verbose output and error output. A possible approach would be using a
  2798. named pipe to receive the archive, and having the consumer process to
  2799. read from that named pipe. This has the advantage of letting standard
  2800. output free to receive verbose output, all separate from errors.
  2801. @node operations
  2802. @chapter @GNUTAR{} Operations
  2803. @menu
  2804. * Basic tar::
  2805. * Advanced tar::
  2806. * create options::
  2807. * extract options::
  2808. * backup::
  2809. * Applications::
  2810. * looking ahead::
  2811. @end menu
  2812. @node Basic tar
  2813. @section Basic @GNUTAR{} Operations
  2814. The basic @command{tar} operations, @option{--create} (@option{-c}),
  2815. @option{--list} (@option{-t}) and @option{--extract} (@option{--get},
  2816. @option{-x}), are currently presented and described in the tutorial
  2817. chapter of this manual. This section provides some complementary notes
  2818. for these operations.
  2819. @table @option
  2820. @opindex create, complementary notes
  2821. @item --create
  2822. @itemx -c
  2823. Creating an empty archive would have some kind of elegance. One can
  2824. initialize an empty archive and later use @option{--append}
  2825. (@option{-r}) for adding all members. Some applications would not
  2826. welcome making an exception in the way of adding the first archive
  2827. member. On the other hand, many people reported that it is
  2828. dangerously too easy for @command{tar} to destroy a magnetic tape with
  2829. an empty archive@footnote{This is well described in @cite{Unix-haters
  2830. Handbook}, by Simson Garfinkel, Daniel Weise & Steven Strassmann, IDG
  2831. Books, ISBN 1-56884-203-1.}. The two most common errors are:
  2832. @enumerate
  2833. @item
  2834. Mistakingly using @code{create} instead of @code{extract}, when the
  2835. intent was to extract the full contents of an archive. This error
  2836. is likely: keys @kbd{c} and @kbd{x} are right next to each other on
  2837. the QWERTY keyboard. Instead of being unpacked, the archive then
  2838. gets wholly destroyed. When users speak about @dfn{exploding} an
  2839. archive, they usually mean something else :-).
  2840. @item
  2841. Forgetting the argument to @code{file}, when the intent was to create
  2842. an archive with a single file in it. This error is likely because a
  2843. tired user can easily add the @kbd{f} key to the cluster of option
  2844. letters, by the mere force of habit, without realizing the full
  2845. consequence of doing so. The usual consequence is that the single
  2846. file, which was meant to be saved, is rather destroyed.
  2847. @end enumerate
  2848. So, recognizing the likelihood and the catastrophical nature of these
  2849. errors, @GNUTAR{} now takes some distance from elegance, and
  2850. cowardly refuses to create an archive when @option{--create} option is
  2851. given, there are no arguments besides options, and
  2852. @option{--files-from} (@option{-T}) option is @emph{not} used. To get
  2853. around the cautiousness of @GNUTAR{} and nevertheless create an
  2854. archive with nothing in it, one may still use, as the value for the
  2855. @option{--files-from} option, a file with no names in it, as shown in
  2856. the following commands:
  2857. @smallexample
  2858. @kbd{tar --create --file=empty-archive.tar --files-from=/dev/null}
  2859. @kbd{tar cfT empty-archive.tar /dev/null}
  2860. @end smallexample
  2861. @opindex extract, complementary notes
  2862. @item --extract
  2863. @itemx --get
  2864. @itemx -x
  2865. A socket is stored, within a @GNUTAR{} archive, as a pipe.
  2866. @item @option{--list} (@option{-t})
  2867. @GNUTAR{} now shows dates as @samp{1996-08-30},
  2868. while it used to show them as @samp{Aug 30 1996}. Preferably,
  2869. people should get used to ISO 8601 dates. Local American dates should
  2870. be made available again with full date localization support, once
  2871. ready. In the meantime, programs not being localizable for dates
  2872. should prefer international dates, that's really the way to go.
  2873. Look up @url{http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html} if you
  2874. are curious, it contains a detailed explanation of the ISO 8601 standard.
  2875. @end table
  2876. @node Advanced tar
  2877. @section Advanced @GNUTAR{} Operations
  2878. Now that you have learned the basics of using @GNUTAR{}, you may want
  2879. to learn about further ways in which @command{tar} can help you.
  2880. This chapter presents five, more advanced operations which you probably
  2881. won't use on a daily basis, but which serve more specialized functions.
  2882. We also explain the different styles of options and why you might want
  2883. to use one or another, or a combination of them in your @command{tar}
  2884. commands. Additionally, this chapter includes options which allow you to
  2885. define the output from @command{tar} more carefully, and provide help and
  2886. error correction in special circumstances.
  2887. @FIXME{check this after the chapter is actually revised to make sure
  2888. it still introduces the info in the chapter correctly : ).}
  2889. @menu
  2890. * Operations::
  2891. * append::
  2892. * update::
  2893. * concatenate::
  2894. * delete::
  2895. * compare::
  2896. @end menu
  2897. @node Operations
  2898. @subsection The Five Advanced @command{tar} Operations
  2899. @UNREVISED
  2900. In the last chapter, you learned about the first three operations to
  2901. @command{tar}. This chapter presents the remaining five operations to
  2902. @command{tar}: @option{--append}, @option{--update}, @option{--concatenate},
  2903. @option{--delete}, and @option{--compare}.
  2904. You are not likely to use these operations as frequently as those
  2905. covered in the last chapter; however, since they perform specialized
  2906. functions, they are quite useful when you do need to use them. We
  2907. will give examples using the same directory and files that you created
  2908. in the last chapter. As you may recall, the directory is called
  2909. @file{practice}, the files are @samp{jazz}, @samp{blues}, @samp{folk},
  2910. @samp{rock}, and the two archive files you created are
  2911. @samp{collection.tar} and @samp{music.tar}.
  2912. We will also use the archive files @samp{afiles.tar} and
  2913. @samp{bfiles.tar}. @samp{afiles.tar} contains the members @samp{apple},
  2914. @samp{angst}, and @samp{aspic}. @samp{bfiles.tar} contains the members
  2915. @samp{./birds}, @samp{baboon}, and @samp{./box}.
  2916. Unless we state otherwise, all practicing you do and examples you follow
  2917. in this chapter will take place in the @file{practice} directory that
  2918. you created in the previous chapter; see @ref{prepare for examples}.
  2919. (Below in this section, we will remind you of the state of the examples
  2920. where the last chapter left them.)
  2921. The five operations that we will cover in this chapter are:
  2922. @table @option
  2923. @item --append
  2924. @itemx -r
  2925. Add new entries to an archive that already exists.
  2926. @item --update
  2927. @itemx -r
  2928. Add more recent copies of archive members to the end of an archive, if
  2929. they exist.
  2930. @item --concatenate
  2931. @itemx --catenate
  2932. @itemx -A
  2933. Add one or more pre-existing archives to the end of another archive.
  2934. @item --delete
  2935. Delete items from an archive (does not work on tapes).
  2936. @item --compare
  2937. @itemx --diff
  2938. @itemx -d
  2939. Compare archive members to their counterparts in the file system.
  2940. @end table
  2941. @node append
  2942. @subsection How to Add Files to Existing Archives: @option{--append}
  2943. @UNREVISED
  2944. @opindex append
  2945. If you want to add files to an existing archive, you don't need to
  2946. create a new archive; you can use @option{--append} (@option{-r}).
  2947. The archive must already exist in order to use @option{--append}. (A
  2948. related operation is the @option{--update} operation; you can use this
  2949. to add newer versions of archive members to an existing archive. To learn how to
  2950. do this with @option{--update}, @pxref{update}.)
  2951. If you use @option{--append} to add a file that has the same name as an
  2952. archive member to an archive containing that archive member, then the
  2953. old member is not deleted. What does happen, however, is somewhat
  2954. complex. @command{tar} @emph{allows} you to have infinite number of files
  2955. with the same name. Some operations treat these same-named members no
  2956. differently than any other set of archive members: for example, if you
  2957. view an archive with @option{--list} (@option{-t}), you will see all
  2958. of those members listed, with their data modification times, owners, etc.
  2959. Other operations don't deal with these members as perfectly as you might
  2960. prefer; if you were to use @option{--extract} to extract the archive,
  2961. only the most recently added copy of a member with the same name as four
  2962. other members would end up in the working directory. This is because
  2963. @option{--extract} extracts an archive in the order the members appeared
  2964. in the archive; the most recently archived members will be extracted
  2965. last. Additionally, an extracted member will @emph{replace} a file of
  2966. the same name which existed in the directory already, and @command{tar}
  2967. will not prompt you about this@footnote{Unless you give it
  2968. @option{--keep-old-files} option, or the disk copy is newer than the
  2969. the one in the archive and you invoke @command{tar} with
  2970. @option{--keep-newer-files} option}. Thus, only the most recently archived
  2971. member will end up being extracted, as it will replace the one
  2972. extracted before it, and so on.
  2973. There exists a special option that allows you to get around this
  2974. behavior and extract (or list) only a particular copy of the file.
  2975. This is @option{--occurrence} option. If you run @command{tar} with
  2976. this option, it will extract only the first copy of the file. You
  2977. may also give this option an argument specifying the number of
  2978. copy to be extracted. Thus, for example if the archive
  2979. @file{archive.tar} contained three copies of file @file{myfile}, then
  2980. the command
  2981. @smallexample
  2982. tar --extract --file archive.tar --occurrence=2 myfile
  2983. @end smallexample
  2984. @noindent
  2985. would extract only the second copy. @xref{Option
  2986. Summary,---occurrence}, for the description of @option{--occurrence}
  2987. option.
  2988. @FIXME{ hag -- you might want to incorporate some of the above into the
  2989. MMwtSN node; not sure. i didn't know how to make it simpler...
  2990. There are a few ways to get around this. (maybe xref Multiple Members
  2991. with the Same Name.}
  2992. @cindex Members, replacing with other members
  2993. @cindex Replacing members with other members
  2994. If you want to replace an archive member, use @option{--delete} to
  2995. delete the member you want to remove from the archive, , and then use
  2996. @option{--append} to add the member you want to be in the archive. Note
  2997. that you can not change the order of the archive; the most recently
  2998. added member will still appear last. In this sense, you cannot truly
  2999. ``replace'' one member with another. (Replacing one member with another
  3000. will not work on certain types of media, such as tapes; see @ref{delete}
  3001. and @ref{Media}, for more information.)
  3002. @menu
  3003. * appending files:: Appending Files to an Archive
  3004. * multiple::
  3005. @end menu
  3006. @node appending files
  3007. @subsubsection Appending Files to an Archive
  3008. @UNREVISED
  3009. @cindex Adding files to an Archive
  3010. @cindex Appending files to an Archive
  3011. @cindex Archives, Appending files to
  3012. The simplest way to add a file to an already existing archive is the
  3013. @option{--append} (@option{-r}) operation, which writes specified files into the
  3014. archive whether or not they are already among the archived files.
  3015. When you use @option{--append}, you @emph{must} specify file name
  3016. arguments, as there is no default. If you specify a file that already
  3017. exists in the archive, another copy of the file will be added to the
  3018. end of the archive. As with other operations, the member names of the
  3019. newly added files will be exactly the same as their names given on the
  3020. command line. The @option{--verbose} (@option{-v}) option will print
  3021. out the names of the files as they are written into the archive.
  3022. @option{--append} cannot be performed on some tape drives, unfortunately,
  3023. due to deficiencies in the formats those tape drives use. The archive
  3024. must be a valid @command{tar} archive, or else the results of using this
  3025. operation will be unpredictable. @xref{Media}.
  3026. To demonstrate using @option{--append} to add a file to an archive,
  3027. create a file called @file{rock} in the @file{practice} directory.
  3028. Make sure you are in the @file{practice} directory. Then, run the
  3029. following @command{tar} command to add @file{rock} to
  3030. @file{collection.tar}:
  3031. @smallexample
  3032. $ @kbd{tar --append --file=collection.tar rock}
  3033. @end smallexample
  3034. @noindent
  3035. If you now use the @option{--list} (@option{-t}) operation, you will see that
  3036. @file{rock} has been added to the archive:
  3037. @smallexample
  3038. $ @kbd{tar --list --file=collection.tar}
  3039. -rw-r--r-- me user 28 1996-10-18 16:31 jazz
  3040. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  3041. -rw-r--r-- me user 20 1996-09-23 16:44 folk
  3042. -rw-r--r-- me user 20 1996-09-23 16:44 rock
  3043. @end smallexample
  3044. @FIXME{in theory, dan will (soon) try to turn this node into what it's
  3045. title claims it will become...}
  3046. @node multiple
  3047. @subsubsection Multiple Files with the Same Name
  3048. You can use @option{--append} (@option{-r}) to add copies of files which have been
  3049. updated since the archive was created. (However, we do not recommend
  3050. doing this since there is another @command{tar} option called
  3051. @option{--update}; @pxref{update} for more information. We describe this
  3052. use of @option{--append} here for the sake of completeness.) @FIXME{is
  3053. this really a good idea, to give this whole description for something
  3054. which i believe is basically a Stupid way of doing something? certain
  3055. aspects of it show ways in which tar is more broken than i'd personally
  3056. like to admit to, specifically the last sentence. On the other hand, i
  3057. don't think it's a good idea to be saying that we explicitly don't
  3058. recommend using something, but i can't see any better way to deal with
  3059. the situation.}When you extract the archive, the older version will be
  3060. effectively lost. This works because files are extracted from an
  3061. archive in the order in which they were archived. Thus, when the
  3062. archive is extracted, a file archived later in time will replace a
  3063. file of the same name which was archived earlier, even though the older
  3064. version of the file will remain in the archive unless you delete all
  3065. versions of the file.
  3066. Supposing you change the file @file{blues} and then append the changed
  3067. version to @file{collection.tar}. As you saw above, the original
  3068. @file{blues} is in the archive @file{collection.tar}. If you change the
  3069. file and append the new version of the file to the archive, there will
  3070. be two copies in the archive. When you extract the archive, the older
  3071. version of the file will be extracted first, and then replaced by the
  3072. newer version when it is extracted.
  3073. You can append the new, changed copy of the file @file{blues} to the
  3074. archive in this way:
  3075. @smallexample
  3076. $ @kbd{tar --append --verbose --file=collection.tar blues}
  3077. blues
  3078. @end smallexample
  3079. @noindent
  3080. Because you specified the @option{--verbose} option, @command{tar} has
  3081. printed the name of the file being appended as it was acted on. Now
  3082. list the contents of the archive:
  3083. @smallexample
  3084. $ @kbd{tar --list --verbose --file=collection.tar}
  3085. -rw-r--r-- me user 28 1996-10-18 16:31 jazz
  3086. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  3087. -rw-r--r-- me user 20 1996-09-23 16:44 folk
  3088. -rw-r--r-- me user 20 1996-09-23 16:44 rock
  3089. -rw-r--r-- me user 58 1996-10-24 18:30 blues
  3090. @end smallexample
  3091. @noindent
  3092. The newest version of @file{blues} is now at the end of the archive
  3093. (note the different creation dates and file sizes). If you extract
  3094. the archive, the older version of the file @file{blues} will be
  3095. replaced by the newer version. You can confirm this by extracting
  3096. the archive and running @samp{ls} on the directory.
  3097. If you wish to extract the first occurrence of the file @file{blues}
  3098. from the archive, use @option{--occurrence} option, as shown in
  3099. the following example:
  3100. @smallexample
  3101. $ @kbd{tar --extract -vv --occurrence --file=collection.tar blues}
  3102. -rw-r--r-- me user 21 1996-09-23 16:44 blues
  3103. @end smallexample
  3104. @xref{Writing}, for more information on @option{--extract} and
  3105. @xref{Option Summary, --occurrence}, for the description of
  3106. @option{--occurrence} option.
  3107. @node update
  3108. @subsection Updating an Archive
  3109. @UNREVISED
  3110. @cindex Updating an archive
  3111. @opindex update
  3112. In the previous section, you learned how to use @option{--append} to
  3113. add a file to an existing archive. A related operation is
  3114. @option{--update} (@option{-u}). The @option{--update} operation
  3115. updates a @command{tar} archive by comparing the date of the specified
  3116. archive members against the date of the file with the same name. If
  3117. the file has been modified more recently than the archive member, then
  3118. the newer version of the file is added to the archive (as with
  3119. @option{--append}).
  3120. Unfortunately, you cannot use @option{--update} with magnetic tape drives.
  3121. The operation will fail.
  3122. @FIXME{other examples of media on which --update will fail? need to ask
  3123. charles and/or mib/thomas/dave shevett..}
  3124. Both @option{--update} and @option{--append} work by adding to the end
  3125. of the archive. When you extract a file from the archive, only the
  3126. version stored last will wind up in the file system, unless you use
  3127. the @option{--backup} option. @FIXME-ref{Multiple Members with the
  3128. Same Name}
  3129. @menu
  3130. * how to update::
  3131. @end menu
  3132. @node how to update
  3133. @subsubsection How to Update an Archive Using @option{--update}
  3134. You must use file name arguments with the @option{--update} (@option{-u}) operation.
  3135. If you don't specify any files, @command{tar} won't act on any files and
  3136. won't tell you that it didn't do anything (which may end up confusing
  3137. you).
  3138. @FIXME{note: the above parenthetical added because in fact, this
  3139. behavior just confused the author. :-) }
  3140. To see the @option{--update} option at work, create a new file,
  3141. @file{classical}, in your practice directory, and some extra text to the
  3142. file @file{blues}, using any text editor. Then invoke @command{tar} with
  3143. the @samp{update} operation and the @option{--verbose} (@option{-v}) option specified,
  3144. using the names of all the files in the practice directory as file name
  3145. arguments:
  3146. @smallexample
  3147. $ @kbd{tar --update -v -f collection.tar blues folk rock classical}
  3148. blues
  3149. classical
  3150. $
  3151. @end smallexample
  3152. @noindent
  3153. Because we have specified verbose mode, @command{tar} prints out the names
  3154. of the files it is working on, which in this case are the names of the
  3155. files that needed to be updated. If you run @samp{tar --list} and look
  3156. at the archive, you will see @file{blues} and @file{classical} at its
  3157. end. There will be a total of two versions of the member @samp{blues};
  3158. the one at the end will be newer and larger, since you added text before
  3159. updating it.
  3160. (The reason @command{tar} does not overwrite the older file when updating
  3161. it is because writing to the middle of a section of tape is a difficult
  3162. process. Tapes are not designed to go backward. @xref{Media}, for more
  3163. information about tapes.
  3164. @option{--update} (@option{-u}) is not suitable for performing backups for two
  3165. reasons: it does not change directory content entries, and it
  3166. lengthens the archive every time it is used. The @GNUTAR{}
  3167. options intended specifically for backups are more
  3168. efficient. If you need to run backups, please consult @ref{Backups}.
  3169. @node concatenate
  3170. @subsection Combining Archives with @option{--concatenate}
  3171. @cindex Adding archives to an archive
  3172. @cindex Concatenating Archives
  3173. @opindex concatenate
  3174. @opindex catenate
  3175. @c @cindex @option{-A} described
  3176. Sometimes it may be convenient to add a second archive onto the end of
  3177. an archive rather than adding individual files to the archive. To add
  3178. one or more archives to the end of another archive, you should use the
  3179. @option{--concatenate} (@option{--catenate}, @option{-A}) operation.
  3180. To use @option{--concatenate}, give the first archive with
  3181. @option{--file} option and name the rest of archives to be
  3182. concatenated on the command line. The members, and their member
  3183. names, will be copied verbatim from those archives to the first one.
  3184. @FIXME-ref{This can cause multiple members to have the same name, for
  3185. information on how this affects reading the archive, Multiple
  3186. Members with the Same Name.}
  3187. The new, concatenated archive will be called by the same name as the
  3188. one given with the @option{--file} option. As usual, if you omit
  3189. @option{--file}, @command{tar} will use the value of the environment
  3190. variable @env{TAPE}, or, if this has not been set, the default archive name.
  3191. @FIXME{There is no way to specify a new name...}
  3192. To demonstrate how @option{--concatenate} works, create two small archives
  3193. called @file{bluesrock.tar} and @file{folkjazz.tar}, using the relevant
  3194. files from @file{practice}:
  3195. @smallexample
  3196. $ @kbd{tar -cvf bluesrock.tar blues rock}
  3197. blues
  3198. classical
  3199. $ @kbd{tar -cvf folkjazz.tar folk jazz}
  3200. folk
  3201. jazz
  3202. @end smallexample
  3203. @noindent
  3204. If you like, You can run @samp{tar --list} to make sure the archives
  3205. contain what they are supposed to:
  3206. @smallexample
  3207. $ @kbd{tar -tvf bluesrock.tar}
  3208. -rw-r--r-- melissa user 105 1997-01-21 19:42 blues
  3209. -rw-r--r-- melissa user 33 1997-01-20 15:34 rock
  3210. $ @kbd{tar -tvf folkjazz.tar}
  3211. -rw-r--r-- melissa user 20 1996-09-23 16:44 folk
  3212. -rw-r--r-- melissa user 65 1997-01-30 14:15 jazz
  3213. @end smallexample
  3214. We can concatenate these two archives with @command{tar}:
  3215. @smallexample
  3216. $ @kbd{cd ..}
  3217. $ @kbd{tar --concatenate --file=bluesrock.tar jazzfolk.tar}
  3218. @end smallexample
  3219. If you now list the contents of the @file{bluesclass.tar}, you will see
  3220. that now it also contains the archive members of @file{jazzfolk.tar}:
  3221. @smallexample
  3222. $ @kbd{tar --list --file=bluesrock.tar}
  3223. blues
  3224. rock
  3225. jazz
  3226. folk
  3227. @end smallexample
  3228. When you use @option{--concatenate}, the source and target archives must
  3229. already exist and must have been created using compatible format
  3230. parameters. Notice, that @command{tar} does not check whether the
  3231. archives it concatenates have compatible formats, it does not
  3232. even check if the files are really tar archives.
  3233. Like @option{--append} (@option{-r}), this operation cannot be performed on some
  3234. tape drives, due to deficiencies in the formats those tape drives use.
  3235. @cindex @code{concatenate} vs @command{cat}
  3236. @cindex @command{cat} vs @code{concatenate}
  3237. It may seem more intuitive to you to want or try to use @command{cat} to
  3238. concatenate two archives instead of using the @option{--concatenate}
  3239. operation; after all, @command{cat} is the utility for combining files.
  3240. However, @command{tar} archives incorporate an end-of-file marker which
  3241. must be removed if the concatenated archives are to be read properly as
  3242. one archive. @option{--concatenate} removes the end-of-archive marker
  3243. from the target archive before each new archive is appended. If you use
  3244. @command{cat} to combine the archives, the result will not be a valid
  3245. @command{tar} format archive. If you need to retrieve files from an
  3246. archive that was added to using the @command{cat} utility, use the
  3247. @option{--ignore-zeros} (@option{-i}) option. @xref{Ignore Zeros}, for further
  3248. information on dealing with archives improperly combined using the
  3249. @command{cat} shell utility.
  3250. @node delete
  3251. @subsection Removing Archive Members Using @option{--delete}
  3252. @UNREVISED
  3253. @cindex Deleting files from an archive
  3254. @cindex Removing files from an archive
  3255. @opindex delete
  3256. You can remove members from an archive by using the @option{--delete}
  3257. option. Specify the name of the archive with @option{--file}
  3258. (@option{-f}) and then specify the names of the members to be deleted;
  3259. if you list no member names, nothing will be deleted. The
  3260. @option{--verbose} option will cause @command{tar} to print the names
  3261. of the members as they are deleted. As with @option{--extract}, you
  3262. must give the exact member names when using @samp{tar --delete}.
  3263. @option{--delete} will remove all versions of the named file from the
  3264. archive. The @option{--delete} operation can run very slowly.
  3265. Unlike other operations, @option{--delete} has no short form.
  3266. @cindex Tapes, using @option{--delete} and
  3267. @cindex Deleting from tape archives
  3268. This operation will rewrite the archive. You can only use
  3269. @option{--delete} on an archive if the archive device allows you to
  3270. write to any point on the media, such as a disk; because of this, it
  3271. does not work on magnetic tapes. Do not try to delete an archive member
  3272. from a magnetic tape; the action will not succeed, and you will be
  3273. likely to scramble the archive and damage your tape. There is no safe
  3274. way (except by completely re-writing the archive) to delete files from
  3275. most kinds of magnetic tape. @xref{Media}.
  3276. To delete all versions of the file @file{blues} from the archive
  3277. @file{collection.tar} in the @file{practice} directory, make sure you
  3278. are in that directory, and then,
  3279. @smallexample
  3280. $ @kbd{tar --list --file=collection.tar}
  3281. blues
  3282. folk
  3283. jazz
  3284. rock
  3285. practice/blues
  3286. practice/folk
  3287. practice/jazz
  3288. practice/rock
  3289. practice/blues
  3290. $ @kbd{tar --delete --file=collection.tar blues}
  3291. $ @kbd{tar --list --file=collection.tar}
  3292. folk
  3293. jazz
  3294. rock
  3295. $
  3296. @end smallexample
  3297. @FIXME{I changed the order of these nodes around and haven't had a chance
  3298. to fix the above example's results, yet. I have to play with this and
  3299. follow it and see what it actually does!}
  3300. The @option{--delete} option has been reported to work properly when
  3301. @command{tar} acts as a filter from @code{stdin} to @code{stdout}.
  3302. @node compare
  3303. @subsection Comparing Archive Members with the File System
  3304. @cindex Verifying the currency of an archive
  3305. @UNREVISED
  3306. @opindex compare
  3307. The @option{--compare} (@option{-d}), or @option{--diff} operation compares
  3308. specified archive members against files with the same names, and then
  3309. reports differences in file size, mode, owner, modification date and
  3310. contents. You should @emph{only} specify archive member names, not file
  3311. names. If you do not name any members, then @command{tar} will compare the
  3312. entire archive. If a file is represented in the archive but does not
  3313. exist in the file system, @command{tar} reports a difference.
  3314. You have to specify the record size of the archive when modifying an
  3315. archive with a non-default record size.
  3316. @command{tar} ignores files in the file system that do not have
  3317. corresponding members in the archive.
  3318. The following example compares the archive members @file{rock},
  3319. @file{blues} and @file{funk} in the archive @file{bluesrock.tar} with
  3320. files of the same name in the file system. (Note that there is no file,
  3321. @file{funk}; @command{tar} will report an error message.)
  3322. @smallexample
  3323. $ @kbd{tar --compare --file=bluesrock.tar rock blues funk}
  3324. rock
  3325. blues
  3326. tar: funk not found in archive
  3327. @end smallexample
  3328. The spirit behind the @option{--compare} (@option{--diff}, @option{-d}) option is to check whether the
  3329. archive represents the current state of files on disk, more than validating
  3330. the integrity of the archive media. For this later goal, @xref{verify}.
  3331. @node create options
  3332. @section Options Used by @option{--create}
  3333. @opindex create, additional options
  3334. The previous chapter described the basics of how to use
  3335. @option{--create} (@option{-c}) to create an archive from a set of files.
  3336. @xref{create}. This section described advanced options to be used with
  3337. @option{--create}.
  3338. @menu
  3339. * Ignore Failed Read::
  3340. @end menu
  3341. @node Ignore Failed Read
  3342. @subsection Ignore Fail Read
  3343. @table @option
  3344. @item --ignore-failed-read
  3345. Do not exit with nonzero on unreadable files or directories.
  3346. @end table
  3347. @node extract options
  3348. @section Options Used by @option{--extract}
  3349. @UNREVISED
  3350. @FIXME{i need to get dan to go over these options with me and see if
  3351. there's a better way of organizing them.}
  3352. @opindex extract, additional options
  3353. The previous chapter showed how to use @option{--extract} to extract
  3354. an archive into the file system. Various options cause @command{tar} to
  3355. extract more information than just file contents, such as the owner,
  3356. the permissions, the modification date, and so forth. This section
  3357. presents options to be used with @option{--extract} when certain special
  3358. considerations arise. You may review the information presented in
  3359. @ref{extract} for more basic information about the
  3360. @option{--extract} operation.
  3361. @menu
  3362. * Reading:: Options to Help Read Archives
  3363. * Writing:: Changing How @command{tar} Writes Files
  3364. * Scarce:: Coping with Scarce Resources
  3365. @end menu
  3366. @node Reading
  3367. @subsection Options to Help Read Archives
  3368. @cindex Options when reading archives
  3369. @UNREVISED
  3370. @cindex Reading incomplete records
  3371. @cindex Records, incomplete
  3372. @opindex read-full-records
  3373. Normally, @command{tar} will request data in full record increments from
  3374. an archive storage device. If the device cannot return a full record,
  3375. @command{tar} will report an error. However, some devices do not always
  3376. return full records, or do not require the last record of an archive to
  3377. be padded out to the next record boundary. To keep reading until you
  3378. obtain a full record, or to accept an incomplete record if it contains
  3379. an end-of-archive marker, specify the @option{--read-full-records} (@option{-B}) option
  3380. in conjunction with the @option{--extract} or @option{--list} operations.
  3381. @xref{Blocking}.
  3382. The @option{--read-full-records} (@option{-B}) option is turned on by default when
  3383. @command{tar} reads an archive from standard input, or from a remote
  3384. machine. This is because on BSD Unix systems, attempting to read a
  3385. pipe returns however much happens to be in the pipe, even if it is
  3386. less than was requested. If this option were not enabled, @command{tar}
  3387. would fail as soon as it read an incomplete record from the pipe.
  3388. If you're not sure of the blocking factor of an archive, you can
  3389. read the archive by specifying @option{--read-full-records} (@option{-B}) and
  3390. @option{--blocking-factor=@var{512-size}} (@option{-b
  3391. @var{512-size}}), using a blocking factor larger than what the archive
  3392. uses. This lets you avoid having to determine the blocking factor
  3393. of an archive. @xref{Blocking Factor}.
  3394. @menu
  3395. * read full records::
  3396. * Ignore Zeros::
  3397. @end menu
  3398. @node read full records
  3399. @unnumberedsubsubsec Reading Full Records
  3400. @FIXME{need sentence or so of intro here}
  3401. @table @option
  3402. @opindex read-full-records
  3403. @item --read-full-records
  3404. @item -B
  3405. Use in conjunction with @option{--extract} (@option{--get},
  3406. @option{-x}) to read an archive which contains incomplete records, or
  3407. one which has a blocking factor less than the one specified.
  3408. @end table
  3409. @node Ignore Zeros
  3410. @unnumberedsubsubsec Ignoring Blocks of Zeros
  3411. @cindex End-of-archive blocks, ignoring
  3412. @cindex Ignoring end-of-archive blocks
  3413. @opindex ignore-zeros
  3414. Normally, @command{tar} stops reading when it encounters a block of zeros
  3415. between file entries (which usually indicates the end of the archive).
  3416. @option{--ignore-zeros} (@option{-i}) allows @command{tar} to
  3417. completely read an archive which contains a block of zeros before the
  3418. end (i.e., a damaged archive, or one that was created by concatenating
  3419. several archives together).
  3420. The @option{--ignore-zeros} (@option{-i}) option is turned off by default because many
  3421. versions of @command{tar} write garbage after the end-of-archive entry,
  3422. since that part of the media is never supposed to be read. @GNUTAR{}
  3423. does not write after the end of an archive, but seeks to
  3424. maintain compatiblity among archiving utilities.
  3425. @table @option
  3426. @item --ignore-zeros
  3427. @itemx -i
  3428. To ignore blocks of zeros (i.e., end-of-archive entries) which may be
  3429. encountered while reading an archive. Use in conjunction with
  3430. @option{--extract} or @option{--list}.
  3431. @end table
  3432. @node Writing
  3433. @subsection Changing How @command{tar} Writes Files
  3434. @UNREVISED
  3435. @FIXME{Introductory paragraph}
  3436. @menu
  3437. * Dealing with Old Files::
  3438. * Overwrite Old Files::
  3439. * Keep Old Files::
  3440. * Keep Newer Files::
  3441. * Unlink First::
  3442. * Recursive Unlink::
  3443. * Data Modification Times::
  3444. * Setting Access Permissions::
  3445. * Writing to Standard Output::
  3446. * Writing to an External Program::
  3447. * remove files::
  3448. @end menu
  3449. @node Dealing with Old Files
  3450. @unnumberedsubsubsec Options Controlling the Overwriting of Existing Files
  3451. @opindex overwrite-dir, introduced
  3452. When extracting files, if @command{tar} discovers that the extracted
  3453. file already exists, it normally replaces the file by removing it before
  3454. extracting it, to prevent confusion in the presence of hard or symbolic
  3455. links. (If the existing file is a symbolic link, it is removed, not
  3456. followed.) However, if a directory cannot be removed because it is
  3457. nonempty, @command{tar} normally overwrites its metadata (ownership,
  3458. permission, etc.). The @option{--overwrite-dir} option enables this
  3459. default behavior. To be more cautious and preserve the metadata of
  3460. such a directory, use the @option{--no-overwrite-dir} option.
  3461. @cindex Overwriting old files, prevention
  3462. @opindex keep-old-files, introduced
  3463. To be even more cautious and prevent existing files from being replaced, use
  3464. the @option{--keep-old-files} (@option{-k}) option. It causes @command{tar} to refuse
  3465. to replace or update a file that already exists, i.e., a file with the
  3466. same name as an archive member prevents extraction of that archive
  3467. member. Instead, it reports an error.
  3468. @opindex overwrite, introduced
  3469. To be more aggressive about altering existing files, use the
  3470. @option{--overwrite} option. It causes @command{tar} to overwrite
  3471. existing files and to follow existing symbolic links when extracting.
  3472. @cindex Protecting old files
  3473. Some people argue that @GNUTAR{} should not hesitate
  3474. to overwrite files with other files when extracting. When extracting
  3475. a @command{tar} archive, they expect to see a faithful copy of the
  3476. state of the file system when the archive was created. It is debatable
  3477. that this would always be a proper behavior. For example, suppose one
  3478. has an archive in which @file{usr/local} is a link to
  3479. @file{usr/local2}. Since then, maybe the site removed the link and
  3480. renamed the whole hierarchy from @file{/usr/local2} to
  3481. @file{/usr/local}. Such things happen all the time. I guess it would
  3482. not be welcome at all that @GNUTAR{} removes the
  3483. whole hierarchy just to make room for the link to be reinstated
  3484. (unless it @emph{also} simultaneously restores the full
  3485. @file{/usr/local2}, of course!) @GNUTAR{} is indeed
  3486. able to remove a whole hierarchy to reestablish a symbolic link, for
  3487. example, but @emph{only if} @option{--recursive-unlink} is specified
  3488. to allow this behavior. In any case, single files are silently
  3489. removed.
  3490. @opindex unlink-first, introduced
  3491. Finally, the @option{--unlink-first} (@option{-U}) option can improve performance in
  3492. some cases by causing @command{tar} to remove files unconditionally
  3493. before extracting them.
  3494. @node Overwrite Old Files
  3495. @unnumberedsubsubsec Overwrite Old Files
  3496. @table @option
  3497. @opindex overwrite
  3498. @item --overwrite
  3499. Overwrite existing files and directory metadata when extracting files
  3500. from an archive.
  3501. This causes @command{tar} to write extracted files into the file system without
  3502. regard to the files already on the system; i.e., files with the same
  3503. names as archive members are overwritten when the archive is extracted.
  3504. It also causes @command{tar} to extract the ownership, permissions,
  3505. and time stamps onto any preexisting files or directories.
  3506. If the name of a corresponding file name is a symbolic link, the file
  3507. pointed to by the symbolic link will be overwritten instead of the
  3508. symbolic link itself (if this is possible). Moreover, special devices,
  3509. empty directories and even symbolic links are automatically removed if
  3510. they are in the way of extraction.
  3511. Be careful when using the @option{--overwrite} option, particularly when
  3512. combined with the @option{--absolute-names} (@option{-P}) option, as this combination
  3513. can change the contents, ownership or permissions of any file on your
  3514. system. Also, many systems do not take kindly to overwriting files that
  3515. are currently being executed.
  3516. @opindex overwrite-dir
  3517. @item --overwrite-dir
  3518. Overwrite the metadata of directories when extracting files from an
  3519. archive, but remove other files before extracting.
  3520. @end table
  3521. @node Keep Old Files
  3522. @unnumberedsubsubsec Keep Old Files
  3523. @table @option
  3524. @opindex keep-old-files
  3525. @item --keep-old-files
  3526. @itemx -k
  3527. Do not replace existing files from archive. The
  3528. @option{--keep-old-files} (@option{-k}) option prevents @command{tar}
  3529. from replacing existing files with files with the same name from the
  3530. archive. The @option{--keep-old-files} option is meaningless with
  3531. @option{--list} (@option{-t}). Prevents @command{tar} from replacing
  3532. files in the file system during extraction.
  3533. @end table
  3534. @node Keep Newer Files
  3535. @unnumberedsubsubsec Keep Newer Files
  3536. @table @option
  3537. @opindex keep-newer-files
  3538. @item --keep-newer-files
  3539. Do not replace existing files that are newer than their archive
  3540. copies. This option is meaningless with @option{--list} (@option{-t}).
  3541. @end table
  3542. @node Unlink First
  3543. @unnumberedsubsubsec Unlink First
  3544. @table @option
  3545. @opindex unlink-first
  3546. @item --unlink-first
  3547. @itemx -U
  3548. Remove files before extracting over them.
  3549. This can make @command{tar} run a bit faster if you know in advance
  3550. that the extracted files all need to be removed. Normally this option
  3551. slows @command{tar} down slightly, so it is disabled by default.
  3552. @end table
  3553. @node Recursive Unlink
  3554. @unnumberedsubsubsec Recursive Unlink
  3555. @table @option
  3556. @opindex recursive-unlink
  3557. @item --recursive-unlink
  3558. When this option is specified, try removing files and directory hierarchies
  3559. before extracting over them. @emph{This is a dangerous option!}
  3560. @end table
  3561. If you specify the @option{--recursive-unlink} option,
  3562. @command{tar} removes @emph{anything} that keeps you from extracting a file
  3563. as far as current permissions will allow it. This could include removal
  3564. of the contents of a full directory hierarchy.
  3565. @node Data Modification Times
  3566. @unnumberedsubsubsec Setting Data Modification Times
  3567. @cindex Data modification times of extracted files
  3568. @cindex Modification times of extracted files
  3569. Normally, @command{tar} sets the data modification times of extracted
  3570. files to the corresponding times recorded for the files in the archive, but
  3571. limits the permissions of extracted files by the current @code{umask}
  3572. setting.
  3573. To set the data modification times of extracted files to the time when
  3574. the files were extracted, use the @option{--touch} (@option{-m}) option in
  3575. conjunction with @option{--extract} (@option{--get}, @option{-x}).
  3576. @table @option
  3577. @opindex touch
  3578. @item --touch
  3579. @itemx -m
  3580. Sets the data modification time of extracted archive members to the time
  3581. they were extracted, not the time recorded for them in the archive.
  3582. Use in conjunction with @option{--extract} (@option{--get}, @option{-x}).
  3583. @end table
  3584. @node Setting Access Permissions
  3585. @unnumberedsubsubsec Setting Access Permissions
  3586. @cindex Permissions of extracted files
  3587. @cindex Modes of extracted files
  3588. To set the modes (access permissions) of extracted files to those
  3589. recorded for those files in the archive, use @option{--same-permissions}
  3590. in conjunction with the @option{--extract} (@option{--get},
  3591. @option{-x}) operation. @FIXME{Should be aliased to ignore-umask.}
  3592. @table @option
  3593. @opindex preserve-permission
  3594. @opindex same-permission
  3595. @item --preserve-permission
  3596. @itemx --same-permission
  3597. @c @itemx --ignore-umask
  3598. @itemx -p
  3599. Set modes of extracted archive members to those recorded in the
  3600. archive, instead of current umask settings. Use in conjunction with
  3601. @option{--extract} (@option{--get}, @option{-x}).
  3602. @end table
  3603. @node Writing to Standard Output
  3604. @unnumberedsubsubsec Writing to Standard Output
  3605. @cindex Writing extracted files to standard output
  3606. @cindex Standard output, writing extracted files to
  3607. To write the extracted files to the standard output, instead of
  3608. creating the files on the file system, use @option{--to-stdout} (@option{-O}) in
  3609. conjunction with @option{--extract} (@option{--get}, @option{-x}). This option is useful if you are
  3610. extracting files to send them through a pipe, and do not need to
  3611. preserve them in the file system. If you extract multiple members,
  3612. they appear on standard output concatenated, in the order they are
  3613. found in the archive.
  3614. @table @option
  3615. @opindex to-stdout
  3616. @item --to-stdout
  3617. @itemx -O
  3618. Writes files to the standard output. Use only in conjunction with
  3619. @option{--extract} (@option{--get}, @option{-x}). When this option is
  3620. used, instead of creating the files specified, @command{tar} writes
  3621. the contents of the files extracted to its standard output. This may
  3622. be useful if you are only extracting the files in order to send them
  3623. through a pipe. This option is meaningless with @option{--list}
  3624. (@option{-t}).
  3625. @end table
  3626. This can be useful, for example, if you have a tar archive containing
  3627. a big file and don't want to store the file on disk before processing
  3628. it. You can use a command like this:
  3629. @smallexample
  3630. tar -xOzf foo.tgz bigfile | process
  3631. @end smallexample
  3632. or even like this if you want to process the concatenation of the files:
  3633. @smallexample
  3634. tar -xOzf foo.tgz bigfile1 bigfile2 | process
  3635. @end smallexample
  3636. Hovewer, @option{--to-command} may be more convenient for use with
  3637. multiple files. See the next section.
  3638. @node Writing to an External Program
  3639. @unnumberedsubsubsec Writing to an External Program
  3640. You can instruct @command{tar} to send the contents of each extracted
  3641. file to the standard input of an external program:
  3642. @table @option
  3643. @opindex to-program
  3644. @item --to-program=@var{command}
  3645. Extract files and pipe their contents to the standard input of
  3646. @var{command}. When this option is used, instead of creating the
  3647. files specified, @command{tar} invokes @var{command} and pipes the
  3648. contents of the files to its standard output. @var{Command} may
  3649. contain command line arguments. The program is executed via
  3650. @code{sh -c}. Notice, that @var{command} is executed once for each regular file
  3651. extracted. Non-regular files (directories, etc.) are ignored when this
  3652. option is used.
  3653. @end table
  3654. The command can obtain the information about the file it processes
  3655. from the following environment variables:
  3656. @table @var
  3657. @vrindex TAR_FILETYPE, to-command environment
  3658. @item TAR_FILETYPE
  3659. Type of the file. It is a single letter with the following meaning:
  3660. @multitable @columnfractions 0.10 0.90
  3661. @item f @tab Regular file
  3662. @item d @tab Directory
  3663. @item l @tab Symbolic link
  3664. @item h @tab Hard link
  3665. @item b @tab Block device
  3666. @item c @tab Character device
  3667. @end multitable
  3668. Currently only regular files are supported.
  3669. @vrindex TAR_MODE, to-command environment
  3670. @item TAR_MODE
  3671. File mode, an octal number.
  3672. @vrindex TAR_FILENAME, to-command environment
  3673. @item TAR_FILENAME
  3674. The name of the file.
  3675. @vrindex TAR_REALNAME, to-command environment
  3676. @item TAR_REALNAME
  3677. Name of the file as stored in the archive.
  3678. @vrindex TAR_UNAME, to-command environment
  3679. @item TAR_UNAME
  3680. Name of the file owner.
  3681. @vrindex TAR_GNAME, to-command environment
  3682. @item TAR_GNAME
  3683. Name of the file owner group.
  3684. @vrindex TAR_ATIME, to-command environment
  3685. @item TAR_ATIME
  3686. Time of last access. It is a decimal number, representing seconds
  3687. since the epoch. If the archive provides times with nanosecond
  3688. precision, the nanoseconds are appended to the timestamp after a
  3689. decimal point.
  3690. @vrindex TAR_MTIME, to-command environment
  3691. @item TAR_MTIME
  3692. Time of last modification.
  3693. @vrindex TAR_CTIME, to-command environment
  3694. @item TAR_CTIME
  3695. Time of last status change.
  3696. @vrindex TAR_SIZE, to-command environment
  3697. @item TAR_SIZE
  3698. Size of the file.
  3699. @vrindex TAR_UID, to-command environment
  3700. @item TAR_UID
  3701. UID of the file owner.
  3702. @vrindex TAR_GID, to-command environment
  3703. @item TAR_GID
  3704. GID of the file owner.
  3705. @end table
  3706. In addition to these variables, @env{TAR_VERSION} contains the
  3707. @GNUTAR{} version number.
  3708. If @var{command} exits with a non-0 status, @command{tar} will print
  3709. an error message similar to the following:
  3710. @smallexample
  3711. tar: 2345: Child returned status 1
  3712. @end smallexample
  3713. Here, @samp{2345} is the PID of the finished process.
  3714. If this behavior is not wanted, use @option{--ignore-command-error}:
  3715. @table @option
  3716. @opindex ignore-command-error
  3717. @item --ignore-command-error
  3718. Ignore exit codes of subprocesses. Notice that if the program
  3719. exits on signal or otherwise terminates abnormally, the error message
  3720. will be printed even if this option is used.
  3721. @opindex no-ignore-command-error
  3722. @item --no-ignore-command-error
  3723. Cancel the effect of any previous @option{--ignore-command-error}
  3724. option. This option is useful if you have set
  3725. @option{--ignore-command-error} in @env{TAR_OPTIONS}
  3726. (@pxref{TAR_OPTIONS}) and wish to temporarily cancel it.
  3727. @end table
  3728. @node remove files
  3729. @unnumberedsubsubsec Removing Files
  3730. @FIXME{the various macros in the front of the manual think that this
  3731. option goes in this section. i have no idea; i only know it's nowhere
  3732. else in the book...}
  3733. @table @option
  3734. @opindex remove-files
  3735. @item --remove-files
  3736. Remove files after adding them to the archive.
  3737. @end table
  3738. @node Scarce
  3739. @subsection Coping with Scarce Resources
  3740. @UNREVISED
  3741. @cindex Small memory
  3742. @cindex Running out of space
  3743. @menu
  3744. * Starting File::
  3745. * Same Order::
  3746. @end menu
  3747. @node Starting File
  3748. @unnumberedsubsubsec Starting File
  3749. @table @option
  3750. @opindex starting-file
  3751. @item --starting-file=@var{name}
  3752. @itemx -K @var{name}
  3753. Starts an operation in the middle of an archive. Use in conjunction
  3754. with @option{--extract} (@option{--get}, @option{-x}) or @option{--list} (@option{-t}).
  3755. @end table
  3756. @cindex Middle of the archive, starting in the
  3757. If a previous attempt to extract files failed due to lack of disk
  3758. space, you can use @option{--starting-file=@var{name}} (@option{-K
  3759. @var{name}}) to start extracting only after member @var{name} of the
  3760. archive. This assumes, of course, that there is now free space, or
  3761. that you are now extracting into a different file system. (You could
  3762. also choose to suspend @command{tar}, remove unnecessary files from
  3763. the file system, and then restart the same @command{tar} operation.
  3764. In this case, @option{--starting-file} is not necessary.
  3765. @xref{Incremental Dumps}, @xref{interactive}, and @ref{exclude}.)
  3766. @node Same Order
  3767. @unnumberedsubsubsec Same Order
  3768. @table @option
  3769. @cindex Large lists of file names on small machines
  3770. @opindex same-order
  3771. @opindex preserve-order
  3772. @item --same-order
  3773. @itemx --preserve-order
  3774. @itemx -s
  3775. To process large lists of file names on machines with small amounts of
  3776. memory. Use in conjunction with @option{--compare} (@option{--diff},
  3777. @option{-d}), @option{--list} (@option{-t}) or @option{--extract}
  3778. (@option{--get}, @option{-x}).
  3779. @end table
  3780. The @option{--same-order} (@option{--preserve-order}, @option{-s}) option tells @command{tar} that the list of file
  3781. names to be listed or extracted is sorted in the same order as the
  3782. files in the archive. This allows a large list of names to be used,
  3783. even on a small machine that would not otherwise be able to hold all
  3784. the names in memory at the same time. Such a sorted list can easily be
  3785. created by running @samp{tar -t} on the archive and editing its output.
  3786. This option is probably never needed on modern computer systems.
  3787. @node backup
  3788. @section Backup options
  3789. @cindex backup options
  3790. @GNUTAR{} offers options for making backups of files
  3791. before writing new versions. These options control the details of
  3792. these backups. They may apply to the archive itself before it is
  3793. created or rewritten, as well as individual extracted members. Other
  3794. @acronym{GNU} programs (@command{cp}, @command{install}, @command{ln},
  3795. and @command{mv}, for example) offer similar options.
  3796. Backup options may prove unexpectedly useful when extracting archives
  3797. containing many members having identical name, or when extracting archives
  3798. on systems having file name limitations, making different members appear
  3799. has having similar names through the side-effect of name truncation.
  3800. (This is true only if we have a good scheme for truncated backup names,
  3801. which I'm not sure at all: I suspect work is needed in this area.)
  3802. When any existing file is backed up before being overwritten by extraction,
  3803. then clashing files are automatically be renamed to be unique, and the
  3804. true name is kept for only the last file of a series of clashing files.
  3805. By using verbose mode, users may track exactly what happens.
  3806. At the detail level, some decisions are still experimental, and may
  3807. change in the future, we are waiting comments from our users. So, please
  3808. do not learn to depend blindly on the details of the backup features.
  3809. For example, currently, directories themselves are never renamed through
  3810. using these options, so, extracting a file over a directory still has
  3811. good chances to fail. Also, backup options apply to created archives,
  3812. not only to extracted members. For created archives, backups will not
  3813. be attempted when the archive is a block or character device, or when it
  3814. refers to a remote file.
  3815. For the sake of simplicity and efficiency, backups are made by renaming old
  3816. files prior to creation or extraction, and not by copying. The original
  3817. name is restored if the file creation fails. If a failure occurs after a
  3818. partial extraction of a file, both the backup and the partially extracted
  3819. file are kept.
  3820. @table @samp
  3821. @item --backup[=@var{method}]
  3822. @opindex backup
  3823. @vindex VERSION_CONTROL
  3824. @cindex backups
  3825. Back up files that are about to be overwritten or removed.
  3826. Without this option, the original versions are destroyed.
  3827. Use @var{method} to determine the type of backups made.
  3828. If @var{method} is not specified, use the value of the @env{VERSION_CONTROL}
  3829. environment variable. And if @env{VERSION_CONTROL} is not set,
  3830. use the @samp{existing} method.
  3831. @vindex version-control @r{Emacs variable}
  3832. This option corresponds to the Emacs variable @samp{version-control};
  3833. the same values for @var{method} are accepted as in Emacs. This option
  3834. also allows more descriptive names. The valid @var{method}s are:
  3835. @table @samp
  3836. @item t
  3837. @itemx numbered
  3838. @cindex numbered @r{backup method}
  3839. Always make numbered backups.
  3840. @item nil
  3841. @itemx existing
  3842. @cindex existing @r{backup method}
  3843. Make numbered backups of files that already have them, simple backups
  3844. of the others.
  3845. @item never
  3846. @itemx simple
  3847. @cindex simple @r{backup method}
  3848. Always make simple backups.
  3849. @end table
  3850. @item --suffix=@var{suffix}
  3851. @opindex suffix
  3852. @cindex backup suffix
  3853. @vindex SIMPLE_BACKUP_SUFFIX
  3854. Append @var{suffix} to each backup file made with @option{--backup}. If this
  3855. option is not specified, the value of the @env{SIMPLE_BACKUP_SUFFIX}
  3856. environment variable is used. And if @env{SIMPLE_BACKUP_SUFFIX} is not
  3857. set, the default is @samp{~}, just as in Emacs.
  3858. @end table
  3859. Some people express the desire to @emph{always} use the @option{--backup}
  3860. option, by defining some kind of alias or script. This is not as easy
  3861. as one may think, due to the fact that old style options should appear first
  3862. and consume arguments a bit unpredictably for an alias or script. But,
  3863. if you are ready to give up using old style options, you may resort to
  3864. using something like (a Bourne shell function here):
  3865. @smallexample
  3866. tar () @{ /usr/local/bin/tar --backup $*; @}
  3867. @end smallexample
  3868. @node Applications
  3869. @section Notable @command{tar} Usages
  3870. @UNREVISED
  3871. @FIXME{Using Unix file linking capability to recreate directory
  3872. structures---linking files into one subdirectory and then
  3873. @command{tar}ring that directory.}
  3874. @FIXME{Nice hairy example using absolute-names, newer, etc.}
  3875. @findex uuencode
  3876. You can easily use archive files to transport a group of files from
  3877. one system to another: put all relevant files into an archive on one
  3878. computer system, transfer the archive to another system, and extract
  3879. the contents there. The basic transfer medium might be magnetic tape,
  3880. Internet FTP, or even electronic mail (though you must encode the
  3881. archive with @command{uuencode} in order to transport it properly by
  3882. mail). Both machines do not have to use the same operating system, as
  3883. long as they both support the @command{tar} program.
  3884. For example, here is how you might copy a directory's contents from
  3885. one disk to another, while preserving the dates, modes, owners and
  3886. link-structure of all the files therein. In this case, the transfer
  3887. medium is a @dfn{pipe}, which is one a Unix redirection mechanism:
  3888. @smallexample
  3889. $ @kbd{cd sourcedir; tar -cf - . | (cd targetdir; tar -xf -)}
  3890. @end smallexample
  3891. @noindent
  3892. The command also works using short option forms:
  3893. @smallexample
  3894. $ @w{@kbd{cd sourcedir; tar --create --file=- . | (cd targetdir; tar --extract --file=-)}}
  3895. @end smallexample
  3896. @noindent
  3897. This is one of the easiest methods to transfer a @command{tar} archive.
  3898. @node looking ahead
  3899. @section Looking Ahead: The Rest of this Manual
  3900. You have now seen how to use all eight of the operations available to
  3901. @command{tar}, and a number of the possible options. The next chapter
  3902. explains how to choose and change file and archive names, how to use
  3903. files to store names of other files which you can then call as
  3904. arguments to @command{tar} (this can help you save time if you expect to
  3905. archive the same list of files a number of times), and so forth.
  3906. @FIXME{in case it's not obvious, i'm making this up in some sense
  3907. based on my limited memory of what the next chapter *really* does. i
  3908. just wanted to flesh out this final section a little bit so i'd
  3909. remember to stick it in here. :-)}
  3910. If there are too many files to conveniently list on the command line,
  3911. you can list the names in a file, and @command{tar} will read that file.
  3912. @xref{files}.
  3913. There are various ways of causing @command{tar} to skip over some files,
  3914. and not archive them. @xref{Choosing}.
  3915. @node Backups
  3916. @chapter Performing Backups and Restoring Files
  3917. @UNREVISED
  3918. @GNUTAR{} is distributed along with the scripts
  3919. which the Free Software Foundation uses for performing backups. There
  3920. is no corresponding scripts available yet for doing restoration of
  3921. files. Even if there is a good chance those scripts may be satisfying
  3922. to you, they are not the only scripts or methods available for doing
  3923. backups and restore. You may well create your own, or use more
  3924. sophisticated packages dedicated to that purpose.
  3925. Some users are enthusiastic about @code{Amanda} (The Advanced Maryland
  3926. Automatic Network Disk Archiver), a backup system developed by James
  3927. da Silva @file{jds@@cs.umd.edu} and available on many Unix systems.
  3928. This is free software, and it is available at these places:
  3929. @smallexample
  3930. http://www.cs.umd.edu/projects/amanda/amanda.html
  3931. ftp://ftp.cs.umd.edu/pub/amanda
  3932. @end smallexample
  3933. @FIXME{
  3934. Here is a possible plan for a future documentation about the backuping
  3935. scripts which are provided within the @GNUTAR{}
  3936. distribution.
  3937. @itemize @bullet
  3938. @item dumps
  3939. @itemize @minus
  3940. @item what are dumps
  3941. @item different levels of dumps
  3942. @itemize +
  3943. @item full dump = dump everything
  3944. @item level 1, level 2 dumps etc
  3945. A level @var{n} dump dumps everything changed since the last level
  3946. @var{n}-1 dump (?)
  3947. @end itemize
  3948. @item how to use scripts for dumps (ie, the concept)
  3949. @itemize +
  3950. @item scripts to run after editing backup specs (details)
  3951. @end itemize
  3952. @item Backup Specs, what is it.
  3953. @itemize +
  3954. @item how to customize
  3955. @item actual text of script [/sp/dump/backup-specs]
  3956. @end itemize
  3957. @item Problems
  3958. @itemize +
  3959. @item rsh doesn't work
  3960. @item rtape isn't installed
  3961. @item (others?)
  3962. @end itemize
  3963. @item the @option{--incremental} option of tar
  3964. @item tapes
  3965. @itemize +
  3966. @item write protection
  3967. @item types of media, different sizes and types, useful for different things
  3968. @item files and tape marks
  3969. one tape mark between files, two at end.
  3970. @item positioning the tape
  3971. MT writes two at end of write,
  3972. backspaces over one when writing again.
  3973. @end itemize
  3974. @end itemize
  3975. @end itemize
  3976. }
  3977. This chapter documents both the provided shell scripts and @command{tar}
  3978. options which are more specific to usage as a backup tool.
  3979. To @dfn{back up} a file system means to create archives that contain
  3980. all the files in that file system. Those archives can then be used to
  3981. restore any or all of those files (for instance if a disk crashes or a
  3982. file is accidentally deleted). File system @dfn{backups} are also
  3983. called @dfn{dumps}.
  3984. @menu
  3985. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  3986. * Incremental Dumps:: Using @command{tar} to Perform Incremental Dumps
  3987. * Backup Levels:: Levels of Backups
  3988. * Backup Parameters:: Setting Parameters for Backups and Restoration
  3989. * Scripted Backups:: Using the Backup Scripts
  3990. * Scripted Restoration:: Using the Restore Script
  3991. @end menu
  3992. @node Full Dumps
  3993. @section Using @command{tar} to Perform Full Dumps
  3994. @UNREVISED
  3995. @cindex full dumps
  3996. @cindex dumps, full
  3997. @cindex corrupted archives
  3998. Full dumps should only be made when no other people or programs
  3999. are modifying files in the file system. If files are modified while
  4000. @command{tar} is making the backup, they may not be stored properly in
  4001. the archive, in which case you won't be able to restore them if you
  4002. have to. (Files not being modified are written with no trouble, and do
  4003. not corrupt the entire archive.)
  4004. You will want to use the @option{--label=@var{archive-label}}
  4005. (@option{-V @var{archive-label}}) option to give the archive a
  4006. volume label, so you can tell what this archive is even if the label
  4007. falls off the tape, or anything like that.
  4008. Unless the file system you are dumping is guaranteed to fit on
  4009. one volume, you will need to use the @option{--multi-volume} (@option{-M}) option.
  4010. Make sure you have enough tapes on hand to complete the backup.
  4011. If you want to dump each file system separately you will need to use
  4012. the @option{--one-file-system} (@option{-l}) option to prevent
  4013. @command{tar} from crossing file system boundaries when storing
  4014. (sub)directories.
  4015. The @option{--incremental} (@option{-G}) (@pxref{Incremental Dumps})
  4016. option is not needed, since this is a complete copy of everything in
  4017. the file system, and a full restore from this backup would only be
  4018. done onto a completely
  4019. empty disk.
  4020. Unless you are in a hurry, and trust the @command{tar} program (and your
  4021. tapes), it is a good idea to use the @option{--verify} (@option{-W})
  4022. option, to make sure your files really made it onto the dump properly.
  4023. This will also detect cases where the file was modified while (or just
  4024. after) it was being archived. Not all media (notably cartridge tapes)
  4025. are capable of being verified, unfortunately.
  4026. @node Incremental Dumps
  4027. @section Using @command{tar} to Perform Incremental Dumps
  4028. @dfn{Incremental backup} is a special form of @GNUTAR{} archive that
  4029. stores additional metadata so that exact state of the file system
  4030. can be restored when extracting the archive.
  4031. @GNUTAR{} currently offers two options for handling incremental
  4032. backups: @option{--listed-incremental=@var{snapshot-file}} (@option{-g
  4033. @var{snapshot-file}}) and @option{--incremental} (@option{-G}).
  4034. @opindex listed-incremental
  4035. The option @option{--listed-incremental} instructs tar to operate on
  4036. an incremental archive with additional metadata stored in a standalone
  4037. file, called a @dfn{snapshot file}. The purpose of this file is to help
  4038. determine which files have been changed, added or deleted since the
  4039. last backup, so that the next incremental backup will contain only
  4040. modified files. The name of the snapshot file is given as an argument
  4041. to the option:
  4042. @table @option
  4043. @item --listed-incremental=@var{file}
  4044. @itemx -g @var{file}
  4045. Handle incremental backups with snapshot data in @var{file}.
  4046. @end table
  4047. To create an incremental backup, you would use
  4048. @option{--listed-incremental} together with @option{--create}
  4049. (@pxref{create}). For example:
  4050. @smallexample
  4051. $ @kbd{tar --create \
  4052. --file=archive.1.tar \
  4053. --listed-incremental=/var/log/usr.snar \
  4054. /usr}
  4055. @end smallexample
  4056. This will create in @file{archive.1.tar} an incremental backup of
  4057. the @file{/usr} file system, storing additional metadata in the file
  4058. @file{/var/log/usr.snar}. If this file does not exist, it will be
  4059. created. The created archive will then be a @dfn{level 0 backup};
  4060. please see the next section for more on backup levels.
  4061. Otherwise, if the file @file{/var/log/usr.snar} exists, it
  4062. determines which files are modified. In this case only these files will be
  4063. stored in the archive. Suppose, for example, that after running the
  4064. above command, you delete file @file{/usr/doc/old} and create
  4065. directory @file{/usr/local/db} with the following contents:
  4066. @smallexample
  4067. $ @kbd{ls /usr/local/db}
  4068. /usr/local/db/data
  4069. /usr/local/db/index
  4070. @end smallexample
  4071. Some time later you create another incremental backup. You will
  4072. then see:
  4073. @smallexample
  4074. $ @kbd{tar --create \
  4075. --file=archive.2.tar \
  4076. --listed-incremental=/var/log/usr.snar \
  4077. /usr}
  4078. tar: usr/local/db: Directory is new
  4079. usr/local/db/
  4080. usr/local/db/data
  4081. usr/local/db/index
  4082. @end smallexample
  4083. @noindent
  4084. The created archive @file{archive.2.tar} will contain only these
  4085. three members. This archive is called a @dfn{level 1 backup}. Notice
  4086. that @file{/var/log/usr.snar} will be updated with the new data, so if
  4087. you plan to create more @samp{level 1} backups, it is necessary to
  4088. create a working copy of the snapshot file before running
  4089. @command{tar}. The above example will then be modified as follows:
  4090. @smallexample
  4091. $ @kbd{cp /var/log/usr.snar /var/log/usr.snar-1}
  4092. $ @kbd{tar --create \
  4093. --file=archive.2.tar \
  4094. --listed-incremental=/var/log/usr.snar-1 \
  4095. /usr}
  4096. @end smallexample
  4097. Incremental dumps depend crucially on time stamps, so the results are
  4098. unreliable if you modify a file's time stamps during dumping (e.g.,
  4099. with the @option{--atime-preserve=replace} option), or if you set the clock
  4100. backwards.
  4101. Metadata stored in snapshot files include device numbers, which,
  4102. obviously is supposed to be a non-volatile value. However, it turns
  4103. out that NFS devices have undependable values when an automounter
  4104. gets in the picture. This can lead to a great deal of spurious
  4105. redumping in incremental dumps, so it is somewhat useless to compare
  4106. two NFS devices numbers over time. The solution implemented currently
  4107. is to considers all NFS devices as being equal when it comes to
  4108. comparing directories; this is fairly gross, but there does not seem
  4109. to be a better way to go.
  4110. Note that incremental archives use @command{tar} extensions and may
  4111. not be readable by non-@acronym{GNU} versions of the @command{tar} program.
  4112. @opindex listed-incremental, using with @option{--extract}
  4113. @opindex extract, using with @option{--listed-incremental}
  4114. To extract from the incremental dumps, use
  4115. @option{--listed-incremental} together with @option{--extract}
  4116. option (@pxref{extracting files}). In this case, @command{tar} does
  4117. not need to access snapshot file, since all the data necessary for
  4118. extraction are stored in the archive itself. So, when extracting, you
  4119. can give whatever argument to @option{--listed-incremental}, the usual
  4120. practice is to use @option{--listed-incremental=/dev/null}.
  4121. Alternatively, you can use @option{--incremental}, which needs no
  4122. arguments. In general, @option{--incremental} (@option{-G}) can be
  4123. used as a shortcut for @option{--listed-incremental} when listing or
  4124. extracting incremental backups (for more information, regarding this
  4125. option, @pxref{incremental-op}).
  4126. When extracting from the incremental backup @GNUTAR{} attempts to
  4127. restore the exact state the file system had when the archive was
  4128. created. In particular, it will @emph{delete} those files in the file
  4129. system that did not exist in their directories when the archive was
  4130. created. If you have created several levels of incremental files,
  4131. then in order to restore the exact contents the file system had when
  4132. the last level was created, you will need to restore from all backups
  4133. in turn. Continuing our example, to restore the state of @file{/usr}
  4134. file system, one would do@footnote{Notice, that since both archives
  4135. were created withouth @option{-P} option (@pxref{absolute}), these
  4136. commands should be run from the root file system.}:
  4137. @smallexample
  4138. $ @kbd{tar --extract \
  4139. --listed-incremental=/dev/null \
  4140. --file archive.1.tar}
  4141. $ @kbd{tar --extract \
  4142. --listed-incremental=/dev/null \
  4143. --file archive.2.tar}
  4144. @end smallexample
  4145. To list the contents of an incremental archive, use @option{--list}
  4146. (@pxref{list}), as usual. To obtain more information about the
  4147. archive, use @option{--listed-incremental} or @option{--incremental}
  4148. combined with two @option{--verbose} options@footnote{Two
  4149. @option{--verbose} options were selected to avoid breaking usual
  4150. verbose listing output (@option{--list --verbose}) when using in
  4151. scripts.
  4152. @opindex incremental, using with @option{--list}
  4153. @opindex listed-incremental, using with @option{--list}
  4154. @opindex list, using with @option{--incremental}
  4155. @opindex list, using with @option{--listed-incremental}
  4156. Versions of @GNUTAR{} up to 1.15.1 used to dump verbatim binary
  4157. contents of the DUMPDIR header (with terminating nulls) when
  4158. @option{--incremental} or @option{--listed-incremental} option was
  4159. given, no matter what the verbosity level. This behavior, and,
  4160. especially, the binary output it produced were considered incovenient
  4161. and were changed in version 1.16}:
  4162. @smallexample
  4163. @kbd{tar --list --incremental --verbose --verbose archive.tar}
  4164. @end smallexample
  4165. This command will print, for each directory in the archive, the list
  4166. of files in that directory at the time the archive was created. This
  4167. information is put out in a format which is both human-readable and
  4168. unambiguous for a program: each file name is printed as
  4169. @smallexample
  4170. @var{x} @var{file}
  4171. @end smallexample
  4172. @noindent
  4173. where @var{x} is a letter describing the status of the file: @samp{Y}
  4174. if the file is present in the archive, @samp{N} if the file is not
  4175. included in the archive, or a @samp{D} if the file is a directory (and
  4176. is included in the archive).@FIXME-xref{dumpdir format}. Each such
  4177. line is terminated by a newline character. The last line is followed
  4178. by an additional newline to indicate the end of the data.
  4179. @anchor{incremental-op}The option @option{--incremental} (@option{-G})
  4180. gives the same behavior as @option{--listed-incremental} when used
  4181. with @option{--list} and @option{--extract} options. When used with
  4182. @option{--create} option, it creates an incremental archive without
  4183. creating snapshot file. Thus, it is impossible to create several
  4184. levels of incremental backups with @option{--incremental} option.
  4185. @node Backup Levels
  4186. @section Levels of Backups
  4187. An archive containing all the files in the file system is called a
  4188. @dfn{full backup} or @dfn{full dump}. You could insure your data by
  4189. creating a full dump every day. This strategy, however, would waste a
  4190. substantial amount of archive media and user time, as unchanged files
  4191. are daily re-archived.
  4192. It is more efficient to do a full dump only occasionally. To back up
  4193. files between full dumps, you can use @dfn{incremental dumps}. A @dfn{level
  4194. one} dump archives all the files that have changed since the last full
  4195. dump.
  4196. A typical dump strategy would be to perform a full dump once a week,
  4197. and a level one dump once a day. This means some versions of files
  4198. will in fact be archived more than once, but this dump strategy makes
  4199. it possible to restore a file system to within one day of accuracy by
  4200. only extracting two archives---the last weekly (full) dump and the
  4201. last daily (level one) dump. The only information lost would be in
  4202. files changed or created since the last daily backup. (Doing dumps
  4203. more than once a day is usually not worth the trouble).
  4204. @GNUTAR{} comes with scripts you can use to do full
  4205. and level-one (actually, even level-two and so on) dumps. Using
  4206. scripts (shell programs) to perform backups and restoration is a
  4207. convenient and reliable alternative to typing out file name lists
  4208. and @command{tar} commands by hand.
  4209. Before you use these scripts, you need to edit the file
  4210. @file{backup-specs}, which specifies parameters used by the backup
  4211. scripts and by the restore script. This file is usually located
  4212. in @file{/etc/backup} directory. @xref{Backup Parameters}, for its
  4213. detailed description. Once the backup parameters are set, you can
  4214. perform backups or restoration by running the appropriate script.
  4215. The name of the backup script is @code{backup}. The name of the
  4216. restore script is @code{restore}. The following sections describe
  4217. their use in detail.
  4218. @emph{Please Note:} The backup and restoration scripts are
  4219. designed to be used together. While it is possible to restore files by
  4220. hand from an archive which was created using a backup script, and to create
  4221. an archive by hand which could then be extracted using the restore script,
  4222. it is easier to use the scripts. @xref{Incremental Dumps}, before
  4223. making such an attempt.
  4224. @node Backup Parameters
  4225. @section Setting Parameters for Backups and Restoration
  4226. The file @file{backup-specs} specifies backup parameters for the
  4227. backup and restoration scripts provided with @command{tar}. You must
  4228. edit @file{backup-specs} to fit your system configuration and schedule
  4229. before using these scripts.
  4230. Syntactically, @file{backup-specs} is a shell script, containing
  4231. mainly variable assignments. However, any valid shell construct
  4232. is allowed in this file. Particularly, you may wish to define
  4233. functions within that script (e.g., see @code{RESTORE_BEGIN} below).
  4234. For more information about shell script syntax, please refer to
  4235. @url{http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#ta
  4236. g_02, the definition of the Shell Command Language}. See also
  4237. @ref{Top,,Bash Features,bashref,Bash Reference Manual}.
  4238. The shell variables controlling behavior of @code{backup} and
  4239. @code{restore} are described in the following subsections.
  4240. @menu
  4241. * General-Purpose Variables::
  4242. * Magnetic Tape Control::
  4243. * User Hooks::
  4244. * backup-specs example:: An Example Text of @file{Backup-specs}
  4245. @end menu
  4246. @node General-Purpose Variables
  4247. @subsection General-Purpose Variables
  4248. @defvr {Backup variable} ADMINISTRATOR
  4249. The user name of the backup administrator. @code{Backup} scripts
  4250. sends a backup report to this address.
  4251. @end defvr
  4252. @defvr {Backup variable} BACKUP_HOUR
  4253. The hour at which the backups are done. This can be a number from 0
  4254. to 23, or the time specification in form @var{hours}:@var{minutes},
  4255. or the string @samp{now}.
  4256. This variable is used by @code{backup}. Its value may be overridden
  4257. using @option{--time} option (@pxref{Scripted Backups}).
  4258. @end defvr
  4259. @defvr {Backup variable} TAPE_FILE
  4260. The device @command{tar} writes the archive to. If @var{TAPE_FILE}
  4261. is a remote archive (@pxref{remote-dev}), backup script will suppose
  4262. that your @command{mt} is able to access remote devices. If @var{RSH}
  4263. (@pxref{RSH}) is set, @option{--rsh-command} option will be added to
  4264. invocations of @command{mt}.
  4265. @end defvr
  4266. @defvr {Backup variable} BLOCKING
  4267. The blocking factor @command{tar} will use when writing the dump archive.
  4268. @xref{Blocking Factor}.
  4269. @end defvr
  4270. @defvr {Backup variable} BACKUP_DIRS
  4271. A list of file systems to be dumped (for @code{backup}), or restored
  4272. (for @code{restore}). You can include any directory
  4273. name in the list --- subdirectories on that file system will be
  4274. included, regardless of how they may look to other networked machines.
  4275. Subdirectories on other file systems will be ignored.
  4276. The host name specifies which host to run @command{tar} on, and should
  4277. normally be the host that actually contains the file system. However,
  4278. the host machine must have @GNUTAR{} installed, and
  4279. must be able to access the directory containing the backup scripts and
  4280. their support files using the same file name that is used on the
  4281. machine where the scripts are run (ie. what @command{pwd} will print
  4282. when in that directory on that machine). If the host that contains
  4283. the file system does not have this capability, you can specify another
  4284. host as long as it can access the file system through NFS.
  4285. If the list of file systems is very long you may wish to put it
  4286. in a separate file. This file is usually named
  4287. @file{/etc/backup/dirs}, but this name may be overridden in
  4288. @file{backup-specs} using @code{DIRLIST} variable.
  4289. @end defvr
  4290. @defvr {Backup variable} DIRLIST
  4291. A path to the file containing the list of the file systems to backup
  4292. or restore. By default it is @file{/etc/backup/dirs}.
  4293. @end defvr
  4294. @defvr {Backup variable} BACKUP_FILES
  4295. A list of individual files to be dumped (for @code{backup}), or restored
  4296. (for @code{restore}). These should be accessible from the machine on
  4297. which the backup script is run.
  4298. If the list of file systems is very long you may wish to store it
  4299. in a separate file. This file is usually named
  4300. @file{/etc/backup/files}, but this name may be overridden in
  4301. @file{backup-specs} using @code{FILELIST} variable.
  4302. @end defvr
  4303. @defvr {Backup variable} FILELIST
  4304. A path to the file containing the list of the individual files to backup
  4305. or restore. By default it is @file{/etc/backup/files}.
  4306. @end defvr
  4307. @defvr {Backup variable} MT
  4308. Full file name of @command{mt} binary.
  4309. @end defvr
  4310. @defvr {Backup variable} RSH
  4311. @anchor{RSH}
  4312. Full file name of @command{rsh} binary or its equivalent. You may wish to
  4313. set it to @code{ssh}, to improve security. In this case you will have
  4314. to use public key authentication.
  4315. @end defvr
  4316. @defvr {Backup variable} RSH_COMMAND
  4317. Full file name of @command{rsh} binary on remote mashines. This will
  4318. be passed via @option{--rsh-command} option to the remote invocation
  4319. of @GNUTAR{}.
  4320. @end defvr
  4321. @defvr {Backup variable} VOLNO_FILE
  4322. Name of temporary file to hold volume numbers. This needs to be accessible
  4323. by all the machines which have file systems to be dumped.
  4324. @end defvr
  4325. @defvr {Backup variable} XLIST
  4326. Name of @dfn{exclude file list}. An @dfn{exclude file list} is a file
  4327. located on the remote machine and containing the list of files to
  4328. be excluded from the backup. Exclude file lists are searched in
  4329. /etc/tar-backup directory. A common use for exclude file lists
  4330. is to exclude files containing security-sensitive information
  4331. (e.g., @file{/etc/shadow} from backups).
  4332. This variable affects only @code{backup}.
  4333. @end defvr
  4334. @defvr {Backup variable} SLEEP_TIME
  4335. Time to sleep between dumps of any two successive file systems
  4336. This variable affects only @code{backup}.
  4337. @end defvr
  4338. @defvr {Backup variable} DUMP_REMIND_SCRIPT
  4339. Script to be run when it's time to insert a new tape in for the next
  4340. volume. Administrators may want to tailor this script for their site.
  4341. If this variable isn't set, @GNUTAR{} will display its built-in prompt
  4342. @FIXME-xref{describe it somewhere!}, and will expect confirmation from
  4343. the console.
  4344. @end defvr
  4345. @defvr {Backup variable} SLEEP_MESSAGE
  4346. Message to display on the terminal while waiting for dump time. Usually
  4347. this will just be some literal text.
  4348. @end defvr
  4349. @defvr {Backup variable} TAR
  4350. Full file name of the @GNUTAR{} executable. If this is not set, backup
  4351. scripts will search @command{tar} in the current shell path.
  4352. @end defvr
  4353. @node Magnetic Tape Control
  4354. @subsection Magnetic Tape Control
  4355. Backup scripts access tape device using special @dfn{hook functions}.
  4356. These functions take a single argument -- the name of the tape
  4357. device. Their names are kept in the following variables:
  4358. @defvr {Backup variable} MT_BEGIN
  4359. The name of @dfn{begin} function. This function is called before
  4360. accessing the drive. By default it retensions the tape:
  4361. @smallexample
  4362. MT_BEGIN=mt_begin
  4363. mt_begin() @{
  4364. mt -f "$1" retension
  4365. @}
  4366. @end smallexample
  4367. @end defvr
  4368. @defvr {Backup variable} MT_REWIND
  4369. The name of @dfn{rewind} function. The default definition is as
  4370. follows:
  4371. @smallexample
  4372. MT_REWIND=mt_rewind
  4373. mt_rewind() @{
  4374. mt -f "$1" rewind
  4375. @}
  4376. @end smallexample
  4377. @end defvr
  4378. @defvr {Backup variable} MT_OFFLINE
  4379. The name of the function switching the tape off line. By default
  4380. it is defined as follows:
  4381. @smallexample
  4382. MT_OFFLINE=mt_offline
  4383. mt_offline() @{
  4384. mt -f "$1" offl
  4385. @}
  4386. @end smallexample
  4387. @end defvr
  4388. @defvr {Backup variable} MT_STATUS
  4389. The name of the function used to obtain the status of the archive device,
  4390. including error count. Default definition:
  4391. @smallexample
  4392. MT_STATUS=mt_status
  4393. mt_status() @{
  4394. mt -f "$1" status
  4395. @}
  4396. @end smallexample
  4397. @end defvr
  4398. @node User Hooks
  4399. @subsection User Hooks
  4400. @dfn{User hooks} are shell functions executed before and after
  4401. each @command{tar} invocation. Thus, there are @dfn{backup
  4402. hooks}, which are executed before and after dumping each file
  4403. system, and @dfn{restore hooks}, executed before and
  4404. after restoring a file system. Each user hook is a shell function
  4405. taking four arguments:
  4406. @deffn {User Hook Function} hook @var{level} @var{host} @var{fs} @var{fsname}
  4407. Its arguments are:
  4408. @table @var
  4409. @item level
  4410. Current backup or restore level.
  4411. @item host
  4412. Name or IP address of the host machine being dumped or restored.
  4413. @item fs
  4414. Full path name to the file system being dumped or restored.
  4415. @item fsname
  4416. File system name with directory separators replaced with colons. This
  4417. is useful, e.g., for creating unique files.
  4418. @end table
  4419. @end deffn
  4420. Following variables keep the names of user hook functions
  4421. @defvr {Backup variable} DUMP_BEGIN
  4422. Dump begin function. It is executed before dumping the file system.
  4423. @end defvr
  4424. @defvr {Backup variable} DUMP_END
  4425. Executed after dumping the file system.
  4426. @end defvr
  4427. @defvr {Backup variable} RESTORE_BEGIN
  4428. Executed before restoring the file system.
  4429. @end defvr
  4430. @defvr {Backup variable} RESTORE_END
  4431. Executed after restoring the file system.
  4432. @end defvr
  4433. @node backup-specs example
  4434. @subsection An Example Text of @file{Backup-specs}
  4435. The following is an example of @file{backup-specs}:
  4436. @smallexample
  4437. # site-specific parameters for file system backup.
  4438. ADMINISTRATOR=friedman
  4439. BACKUP_HOUR=1
  4440. TAPE_FILE=/dev/nrsmt0
  4441. # Use @code{ssh} instead of the less secure @code{rsh}
  4442. RSH=/usr/bin/ssh
  4443. RSH_COMMAND=/usr/bin/ssh
  4444. # Override MT_STATUS function:
  4445. my_status() @{
  4446. mts -t $TAPE_FILE
  4447. @}
  4448. MT_STATUS=my_status
  4449. # Disable MT_OFFLINE function
  4450. MT_OFFLINE=:
  4451. BLOCKING=124
  4452. BACKUP_DIRS="
  4453. albert:/fs/fsf
  4454. apple-gunkies:/gd
  4455. albert:/fs/gd2
  4456. albert:/fs/gp
  4457. geech:/usr/jla
  4458. churchy:/usr/roland
  4459. albert:/
  4460. albert:/usr
  4461. apple-gunkies:/
  4462. apple-gunkies:/usr
  4463. gnu:/hack
  4464. gnu:/u
  4465. apple-gunkies:/com/mailer/gnu
  4466. apple-gunkies:/com/archive/gnu"
  4467. BACKUP_FILES="/com/mailer/aliases /com/mailer/league*[a-z]"
  4468. @end smallexample
  4469. @node Scripted Backups
  4470. @section Using the Backup Scripts
  4471. The syntax for running a backup script is:
  4472. @smallexample
  4473. backup --level=@var{level} --time=@var{time}
  4474. @end smallexample
  4475. The @option{level} option requests the dump level. Thus, to produce
  4476. a full dump, specify @code{--level=0} (this is the default, so
  4477. @option{--level} may be omitted if its value is @code{0}).
  4478. @footnote{For backward compatibility, the @code{backup} will also
  4479. try to deduce the requested dump level from the name of the
  4480. script itself. If the name consists of a string @samp{level-}
  4481. followed by a single decimal digit, that digit is taken as
  4482. the dump level number. Thus, you may create a link from @code{backup}
  4483. to @code{level-1} and then run @code{level-1} whenever you need to
  4484. create a level one dump.}
  4485. The @option{--time} option determines when should the backup be
  4486. run. @var{Time} may take three forms:
  4487. @table @asis
  4488. @item @var{hh}:@var{mm}
  4489. The dump must be run at @var{hh} hours @var{mm} minutes.
  4490. @item @var{hh}
  4491. The dump must be run at @var{hh} hours
  4492. @item now
  4493. The dump must be run immediately.
  4494. @end table
  4495. You should start a script with a tape or disk mounted. Once you
  4496. start a script, it prompts you for new tapes or disks as it
  4497. needs them. Media volumes don't have to correspond to archive
  4498. files --- a multi-volume archive can be started in the middle of a
  4499. tape that already contains the end of another multi-volume archive.
  4500. The @code{restore} script prompts for media by its archive volume,
  4501. so to avoid an error message you should keep track of which tape
  4502. (or disk) contains which volume of the archive (@pxref{Scripted
  4503. Restoration}).
  4504. The backup scripts write two files on the file system. The first is a
  4505. record file in @file{/etc/tar-backup/}, which is used by the scripts
  4506. to store and retrieve information about which files were dumped. This
  4507. file is not meant to be read by humans, and should not be deleted by
  4508. them. @xref{Snapshot Files}, for a more detailed explanation of this
  4509. file.
  4510. The second file is a log file containing the names of the file systems
  4511. and files dumped, what time the backup was made, and any error
  4512. messages that were generated, as well as how much space was left in
  4513. the media volume after the last volume of the archive was written.
  4514. You should check this log file after every backup. The file name is
  4515. @file{log-@var{mm-dd-yyyy}-level-@var{n}}, where @var{mm-dd-yyyy}
  4516. represents current date, and @var{n} represents current dump level number.
  4517. The script also prints the name of each system being dumped to the
  4518. standard output.
  4519. Following is the full list of options accepted by @code{backup}
  4520. script:
  4521. @table @option
  4522. @item -l @var{level}
  4523. @itemx --level=@var{level}
  4524. Do backup level @var{level} (default 0).
  4525. @item -f
  4526. @itemx --force
  4527. Force backup even if today's log file already exists.
  4528. @item -v[@var{level}]
  4529. @itemx --verbose[=@var{level}]
  4530. Set verbosity level. The higher the level is, the more debugging
  4531. information will be output during execution. Devault @var{level}
  4532. is 100, which means the highest debugging level.
  4533. @item -t @var{start-time}
  4534. @itemx --time=@var{start-time}
  4535. Wait till @var{time}, then do backup.
  4536. @item -h
  4537. @itemx --help
  4538. Display short help message and exit.
  4539. @item -L
  4540. @itemx --license
  4541. Display program license and exit.
  4542. @item -V
  4543. @itemx --version
  4544. Display program version and exit.
  4545. @end table
  4546. @node Scripted Restoration
  4547. @section Using the Restore Script
  4548. To restore files that were archived using a scripted backup, use the
  4549. @code{restore} script. Its usage is quite straightforward. In the
  4550. simplest form, invoke @code{restore --all}, it will
  4551. then restore all the file systems and files specified in
  4552. @file{backup-specs} (@pxref{General-Purpose Variables,BACKUP_DIRS}).
  4553. You may select the file systems (and/or files) to restore by
  4554. giving @code{restore} list of @dfn{patterns} in its command
  4555. line. For example, running
  4556. @smallexample
  4557. restore 'albert:*'
  4558. @end smallexample
  4559. @noindent
  4560. will restore all file systems on the machine @samp{albert}. A more
  4561. complicated example:
  4562. @smallexample
  4563. restore 'albert:*' '*:/var'
  4564. @end smallexample
  4565. @noindent
  4566. This command will restore all file systems on the machine @samp{albert}
  4567. as well as @file{/var} file system on all machines.
  4568. By default @code{restore} will start restoring files from the lowest
  4569. available dump level (usually zero) and will continue through
  4570. all available dump levels. There may be situations where such a
  4571. thorough restore is not necessary. For example, you may wish to
  4572. restore only files from the recent level one backup. To do so,
  4573. use @option{--level} option, as shown in the example below:
  4574. @smallexample
  4575. restore --level=1
  4576. @end smallexample
  4577. The full list of options accepted by @code{restore} follows:
  4578. @table @option
  4579. @item -a
  4580. @itemx --all
  4581. Restore all file systems and files specified in @file{backup-specs}
  4582. @item -l @var{level}
  4583. @itemx --level=@var{level}
  4584. Start restoring from the given backup level, instead of the default 0.
  4585. @item -v[@var{level}]
  4586. @itemx --verbose[=@var{level}]
  4587. Set verbosity level. The higher the level is, the more debugging
  4588. information will be output during execution. Devault @var{level}
  4589. is 100, which means the highest debugging level.
  4590. @item -h
  4591. @itemx --help
  4592. Display short help message and exit.
  4593. @item -L
  4594. @itemx --license
  4595. Display program license and exit.
  4596. @item -V
  4597. @itemx --version
  4598. Display program version and exit.
  4599. @end table
  4600. You should start the restore script with the media containing the
  4601. first volume of the archive mounted. The script will prompt for other
  4602. volumes as they are needed. If the archive is on tape, you don't need
  4603. to rewind the tape to to its beginning---if the tape head is
  4604. positioned past the beginning of the archive, the script will rewind
  4605. the tape as needed. @FIXME-xref{Media, for a discussion of tape
  4606. positioning.}
  4607. @quotation
  4608. @strong{Warning:} The script will delete files from the active file
  4609. system if they were not in the file system when the archive was made.
  4610. @end quotation
  4611. @xref{Incremental Dumps}, for an explanation of how the script makes
  4612. that determination.
  4613. @node Choosing
  4614. @chapter Choosing Files and Names for @command{tar}
  4615. @UNREVISED
  4616. @FIXME{Melissa (still) Doesn't Really Like This ``Intro'' Paragraph!!!}
  4617. Certain options to @command{tar} enable you to specify a name for your
  4618. archive. Other options let you decide which files to include or exclude
  4619. from the archive, based on when or whether files were modified, whether
  4620. the file names do or don't match specified patterns, or whether files
  4621. are in specified directories.
  4622. @menu
  4623. * file:: Choosing the Archive's Name
  4624. * Selecting Archive Members::
  4625. * files:: Reading Names from a File
  4626. * exclude:: Excluding Some Files
  4627. * Wildcards::
  4628. * after:: Operating Only on New Files
  4629. * recurse:: Descending into Directories
  4630. * one:: Crossing File System Boundaries
  4631. @end menu
  4632. @node file
  4633. @section Choosing and Naming Archive Files
  4634. @UNREVISED
  4635. @FIXME{should the title of this section actually be, "naming an
  4636. archive"?}
  4637. @cindex Naming an archive
  4638. @cindex Archive Name
  4639. @cindex Choosing an archive file
  4640. @cindex Where is the archive?
  4641. By default, @command{tar} uses an archive file name that was compiled when
  4642. it was built on the system; usually this name refers to some physical
  4643. tape drive on the machine. However, the person who installed @command{tar}
  4644. on the system may not set the default to a meaningful value as far as
  4645. most users are concerned. As a result, you will usually want to tell
  4646. @command{tar} where to find (or create) the archive. The @option{--file=@var{archive-name}} (@option{-f @var{archive-name}})
  4647. option allows you to either specify or name a file to use as the archive
  4648. instead of the default archive file location.
  4649. @table @option
  4650. @opindex file, short description
  4651. @item --file=@var{archive-name}
  4652. @itemx -f @var{archive-name}
  4653. Name the archive to create or operate on. Use in conjunction with
  4654. any operation.
  4655. @end table
  4656. For example, in this @command{tar} command,
  4657. @smallexample
  4658. $ @kbd{tar -cvf collection.tar blues folk jazz}
  4659. @end smallexample
  4660. @noindent
  4661. @file{collection.tar} is the name of the archive. It must directly
  4662. follow the @option{-f} option, since whatever directly follows @option{-f}
  4663. @emph{will} end up naming the archive. If you neglect to specify an
  4664. archive name, you may end up overwriting a file in the working directory
  4665. with the archive you create since @command{tar} will use this file's name
  4666. for the archive name.
  4667. An archive can be saved as a file in the file system, sent through a
  4668. pipe or over a network, or written to an I/O device such as a tape,
  4669. floppy disk, or CD write drive.
  4670. @cindex Writing new archives
  4671. @cindex Archive creation
  4672. If you do not name the archive, @command{tar} uses the value of the
  4673. environment variable @env{TAPE} as the file name for the archive. If
  4674. that is not available, @command{tar} uses a default, compiled-in archive
  4675. name, usually that for tape unit zero (ie. @file{/dev/tu00}).
  4676. @command{tar} always needs an archive name.
  4677. If you use @file{-} as an @var{archive-name}, @command{tar} reads the
  4678. archive from standard input (when listing or extracting files), or
  4679. writes it to standard output (when creating an archive). If you use
  4680. @file{-} as an @var{archive-name} when modifying an archive,
  4681. @command{tar} reads the original archive from its standard input and
  4682. writes the entire new archive to its standard output.
  4683. @FIXME{might want a different example here; this is already used in
  4684. "notable tar usages".}
  4685. @smallexample
  4686. $ @kbd{cd sourcedir; tar -cf - . | (cd targetdir; tar -xf -)}
  4687. @end smallexample
  4688. @FIXME{help!}
  4689. @cindex Standard input and output
  4690. @cindex tar to standard input and output
  4691. @anchor{remote-dev}
  4692. To specify an archive file on a device attached to a remote machine,
  4693. use the following:
  4694. @smallexample
  4695. @kbd{--file=@var{hostname}:/@var{dev}/@var{file name}}
  4696. @end smallexample
  4697. @noindent
  4698. @command{tar} will complete the remote connection, if possible, and
  4699. prompt you for a username and password. If you use
  4700. @option{--file=@@@var{hostname}:/@var{dev}/@var{file name}}, @command{tar}
  4701. will complete the remote connection, if possible, using your username
  4702. as the username on the remote machine.
  4703. @cindex Local and remote archives
  4704. @anchor{local and remote archives}
  4705. If the archive file name includes a colon (@samp{:}), then it is assumed
  4706. to be a file on another machine. If the archive file is
  4707. @samp{@var{user}@@@var{host}:@var{file}}, then @var{file} is used on the
  4708. host @var{host}. The remote host is accessed using the @command{rsh}
  4709. program, with a username of @var{user}. If the username is omitted
  4710. (along with the @samp{@@} sign), then your user name will be used.
  4711. (This is the normal @command{rsh} behavior.) It is necessary for the
  4712. remote machine, in addition to permitting your @command{rsh} access, to
  4713. have the @file{rmt} program installed (This command is included in
  4714. the @GNUTAR{} distribution and by default is installed under
  4715. @file{@var{prefix}/libexec/rmt}, were @var{prefix} means your
  4716. installation prefix). If you need to use a file whose name includes a
  4717. colon, then the remote tape drive behavior
  4718. can be inhibited by using the @option{--force-local} option.
  4719. @FIXME{i know we went over this yesterday, but bob (and now i do again,
  4720. too) thinks it's out of the middle of nowhere. it doesn't seem to tie
  4721. into what came before it well enough <<i moved it now, is it better
  4722. here?>>. bob also comments that if Amanda isn't free software, we
  4723. shouldn't mention it..}
  4724. When the archive is being created to @file{/dev/null}, @GNUTAR{}
  4725. tries to minimize input and output operations. The
  4726. Amanda backup system, when used with @GNUTAR{}, has
  4727. an initial sizing pass which uses this feature.
  4728. @node Selecting Archive Members
  4729. @section Selecting Archive Members
  4730. @cindex Specifying files to act on
  4731. @cindex Specifying archive members
  4732. @dfn{File Name arguments} specify which files in the file system
  4733. @command{tar} operates on, when creating or adding to an archive, or which
  4734. archive members @command{tar} operates on, when reading or deleting from
  4735. an archive. @xref{Operations}.
  4736. To specify file names, you can include them as the last arguments on
  4737. the command line, as follows:
  4738. @smallexample
  4739. @kbd{tar} @var{operation} [@var{option1} @var{option2} @dots{}] [@var{file name-1} @var{file name-2} @dots{}]
  4740. @end smallexample
  4741. If a file name begins with dash (@samp{-}), preceede it with
  4742. @option{--add-file} option to preventit from being treated as an
  4743. option.
  4744. If you specify a directory name as a file name argument, all the files
  4745. in that directory are operated on by @command{tar}.
  4746. If you do not specify files when @command{tar} is invoked with
  4747. @option{--create} (@option{-c}), @command{tar} operates on all the non-directory files in
  4748. the working directory. If you specify either @option{--list} (@option{-t}) or
  4749. @option{--extract} (@option{--get}, @option{-x}), @command{tar} operates on all the archive members in the
  4750. archive. If you specify any operation other than one of these three,
  4751. @command{tar} does nothing.
  4752. By default, @command{tar} takes file names from the command line. However,
  4753. there are other ways to specify file or member names, or to modify the
  4754. manner in which @command{tar} selects the files or members upon which to
  4755. operate. @FIXME{add xref here}In general, these methods work both for
  4756. specifying the names of files and archive members.
  4757. @node files
  4758. @section Reading Names from a File
  4759. @cindex Reading file names from a file
  4760. @cindex Lists of file names
  4761. @cindex File Name arguments, alternatives
  4762. Instead of giving the names of files or archive members on the command
  4763. line, you can put the names into a file, and then use the
  4764. @option{--files-from=@var{file-of-names}} (@option{-T @var{file-of-names}}) option to @command{tar}. Give the name of the file
  4765. which contains the list of files to include as the argument to
  4766. @option{--files-from}. In the list, the file names should be separated by
  4767. newlines. You will frequently use this option when you have generated
  4768. the list of files to archive with the @command{find} utility.
  4769. @table @option
  4770. @opindex files-from
  4771. @item --files-from=@var{file name}
  4772. @itemx -T @var{file name}
  4773. Get names to extract or create from file @var{file name}.
  4774. @end table
  4775. If you give a single dash as a file name for @option{--files-from}, (i.e.,
  4776. you specify either @code{--files-from=-} or @code{-T -}), then the file
  4777. names are read from standard input.
  4778. Unless you are running @command{tar} with @option{--create}, you can not use
  4779. both @code{--files-from=-} and @code{--file=-} (@code{-f -}) in the same
  4780. command.
  4781. Any number of @option{-T} options can be given in the command line.
  4782. @FIXME{add bob's example, from his message on 2-10-97}
  4783. The following example shows how to use @command{find} to generate a list of
  4784. files smaller than 400K in length and put that list into a file
  4785. called @file{small-files}. You can then use the @option{-T} option to
  4786. @command{tar} to specify the files from that file, @file{small-files}, to
  4787. create the archive @file{little.tgz}. (The @option{-z} option to
  4788. @command{tar} compresses the archive with @command{gzip}; @pxref{gzip} for
  4789. more information.)
  4790. @smallexample
  4791. $ @kbd{find . -size -400 -print > small-files}
  4792. $ @kbd{tar -c -v -z -T small-files -f little.tgz}
  4793. @end smallexample
  4794. @noindent
  4795. In the file list given by @option{-T} option, any file name beginning
  4796. with @samp{-} character is considered a @command{tar} option and is
  4797. processed accordingly.@footnote{Versions of @GNUTAR{} up to 1.15.1
  4798. recognized only @option{-C} option in file lists, and only if the
  4799. option and its argument occupied two consecutive lines.} For example,
  4800. the common use of this feature is to change to another directory by
  4801. specifying @option{-C} option:
  4802. @smallexample
  4803. @group
  4804. $ @kbd{cat list}
  4805. -C/etc
  4806. passwd
  4807. hosts
  4808. -C/lib
  4809. libc.a
  4810. $ @kbd{tar -c -f foo.tar --files-from list}
  4811. @end group
  4812. @end smallexample
  4813. @noindent
  4814. In this example, @command{tar} will first switch to @file{/etc}
  4815. directory and add files @file{passwd} and @file{hosts} to the
  4816. archive. Then it will change to @file{/lib} directory and will archive
  4817. the file @file{libc.a}. Thus, the resulting archive @file{foo.tar} will
  4818. contain:
  4819. @smallexample
  4820. @group
  4821. $ @kbd{tar tf foo.tar}
  4822. passwd
  4823. hosts
  4824. libc.a
  4825. @end group
  4826. @end smallexample
  4827. @noindent
  4828. @opindex directory, using in @option{--files-from} argument
  4829. Notice that the option parsing algorithm used with @option{-T} is
  4830. stricter than the one used by shell. Namely, when specifying option
  4831. arguments, you should observe the following rules:
  4832. @itemize @bullet
  4833. @item
  4834. When using short (single-letter) option form, its argument must
  4835. immediately follow the option letter, without any intervening
  4836. whitespace. For example: @code{-Cdir}.
  4837. @item
  4838. When using long option form, the option argument must be separated
  4839. from the option by a single equal sign. No whitespace is allowed on
  4840. any side of the equal sign. For example: @code{--directory=dir}.
  4841. @item
  4842. For both short and long option forms, the option argument can be given
  4843. on the next line after the option name, e.g.:
  4844. @smallexample
  4845. @group
  4846. --directory
  4847. dir
  4848. @end group
  4849. @end smallexample
  4850. @noindent
  4851. and
  4852. @smallexample
  4853. @group
  4854. -C
  4855. dir
  4856. @end group
  4857. @end smallexample
  4858. @end itemize
  4859. @opindex add-file
  4860. If you happen to have a file whose name starts with @samp{-},
  4861. precede it with @option{--add-file} option to prevent it from
  4862. being recognized as an option. For example: @code{--add-file --my-file}.
  4863. @menu
  4864. * nul::
  4865. @end menu
  4866. @node nul
  4867. @subsection @code{NUL} Terminated File Names
  4868. @cindex File names, terminated by @code{NUL}
  4869. @cindex @code{NUL} terminated file names
  4870. The @option{--null} option causes @option{--files-from=@var{file-of-names}} (@option{-T @var{file-of-names}}) to read file
  4871. names terminated by a @code{NUL} instead of a newline, so files whose
  4872. names contain newlines can be archived using @option{--files-from}.
  4873. @table @option
  4874. @opindex null
  4875. @item --null
  4876. Only consider @code{NUL} terminated file names, instead of files that
  4877. terminate in a newline.
  4878. @end table
  4879. The @option{--null} option is just like the one in @acronym{GNU}
  4880. @command{xargs} and @command{cpio}, and is useful with the
  4881. @option{-print0} predicate of @acronym{GNU} @command{find}. In
  4882. @command{tar}, @option{--null} also disables special handling for
  4883. file names that begin with dash.
  4884. This example shows how to use @command{find} to generate a list of files
  4885. larger than 800K in length and put that list into a file called
  4886. @file{long-files}. The @option{-print0} option to @command{find} is just
  4887. like @option{-print}, except that it separates files with a @code{NUL}
  4888. rather than with a newline. You can then run @command{tar} with both the
  4889. @option{--null} and @option{-T} options to specify that @command{tar} get the
  4890. files from that file, @file{long-files}, to create the archive
  4891. @file{big.tgz}. The @option{--null} option to @command{tar} will cause
  4892. @command{tar} to recognize the @code{NUL} separator between files.
  4893. @smallexample
  4894. $ @kbd{find . -size +800 -print0 > long-files}
  4895. $ @kbd{tar -c -v --null --files-from=long-files --file=big.tar}
  4896. @end smallexample
  4897. @FIXME{say anything else here to conclude the section?}
  4898. @node exclude
  4899. @section Excluding Some Files
  4900. @UNREVISED
  4901. @cindex File names, excluding files by
  4902. @cindex Excluding files by name and pattern
  4903. @cindex Excluding files by file system
  4904. To avoid operating on files whose names match a particular pattern,
  4905. use the @option{--exclude} or @option{--exclude-from} options.
  4906. @table @option
  4907. @opindex exclude
  4908. @item --exclude=@var{pattern}
  4909. Causes @command{tar} to ignore files that match the @var{pattern}.
  4910. @end table
  4911. @findex exclude
  4912. The @option{--exclude=@var{pattern}} option prevents any file or member whose name
  4913. matches the shell wildcard (@var{pattern}) from being operated on.
  4914. For example, to create an archive with all the contents of the directory
  4915. @file{src} except for files whose names end in @file{.o}, use the
  4916. command @samp{tar -cf src.tar --exclude='*.o' src}.
  4917. You may give multiple @option{--exclude} options.
  4918. @table @option
  4919. @opindex exclude-from
  4920. @item --exclude-from=@var{file}
  4921. @itemx -X @var{file}
  4922. Causes @command{tar} to ignore files that match the patterns listed in
  4923. @var{file}.
  4924. @end table
  4925. @findex exclude-from
  4926. Use the @option{--exclude-from} option to read a
  4927. list of patterns, one per line, from @var{file}; @command{tar} will
  4928. ignore files matching those patterns. Thus if @command{tar} is
  4929. called as @w{@samp{tar -c -X foo .}} and the file @file{foo} contains a
  4930. single line @file{*.o}, no files whose names end in @file{.o} will be
  4931. added to the archive.
  4932. @FIXME{do the exclude options files need to have stuff separated by
  4933. newlines the same as the files-from option does?}
  4934. @table @option
  4935. @opindex exclude-caches
  4936. @item --exclude-caches
  4937. Causes @command{tar} to ignore directories containing a cache directory tag.
  4938. @end table
  4939. @findex exclude-caches
  4940. When creating an archive, the @option{--exclude-caches} option causes
  4941. @command{tar} to exclude all directories that contain a @dfn{cache
  4942. directory tag}. A cache directory tag is a short file with the
  4943. well-known name @file{CACHEDIR.TAG} and having a standard header
  4944. specified in @url{http://www.brynosaurus.com/cachedir/spec.html}.
  4945. Various applications write cache directory tags into directories they
  4946. use to hold regenerable, non-precious data, so that such data can be
  4947. more easily excluded from backups.
  4948. @menu
  4949. * controlling pattern-matching with exclude::
  4950. * problems with exclude::
  4951. @end menu
  4952. @node controlling pattern-matching with exclude
  4953. @unnumberedsubsec Controlling Pattern-Matching with the @code{exclude} Options
  4954. Normally, a pattern matches a name if an initial subsequence of the
  4955. name's components matches the pattern, where @samp{*}, @samp{?}, and
  4956. @samp{[...]} are the usual shell wildcards, @samp{\} escapes wildcards,
  4957. and wildcards can match @samp{/}.
  4958. Other than optionally stripping leading @samp{/} from names
  4959. (@pxref{absolute}), patterns and names are used as-is. For
  4960. example, trailing @samp{/} is not trimmed from a user-specified name
  4961. before deciding whether to exclude it.
  4962. However, this matching procedure can be altered by the options listed
  4963. below. These options accumulate. For example:
  4964. @smallexample
  4965. --ignore-case --exclude='makefile' --no-ignore-case ---exclude='readme'
  4966. @end smallexample
  4967. ignores case when excluding @samp{makefile}, but not when excluding
  4968. @samp{readme}.
  4969. @table @option
  4970. @opindex anchored
  4971. @opindex no-anchored
  4972. @item --anchored
  4973. @itemx --no-anchored
  4974. If anchored, a pattern must match an initial subsequence
  4975. of the name's components. Otherwise, the pattern can match any
  4976. subsequence. Default is @option{--no-anchored}.
  4977. @opindex ignore-case
  4978. @opindex no-ignore-case
  4979. @item --ignore-case
  4980. @itemx --no-ignore-case
  4981. When ignoring case, upper-case patterns match lower-case names and vice versa.
  4982. When not ignoring case (the default), matching is case-sensitive.
  4983. @opindex wildcards
  4984. @opindex no-wildcards
  4985. @item --wildcards
  4986. @itemx --no-wildcards
  4987. When using wildcards (the default), @samp{*}, @samp{?}, and @samp{[...]}
  4988. are the usual shell wildcards, and @samp{\} escapes wildcards.
  4989. Otherwise, none of these characters are special, and patterns must match
  4990. names literally.
  4991. @opindex wildcards-match-slash
  4992. @opindex no-wildcards-match-slash
  4993. @item --wildcards-match-slash
  4994. @itemx --no-wildcards-match-slash
  4995. When wildcards match slash (the default), a wildcard like @samp{*} in
  4996. the pattern can match a @samp{/} in the name. Otherwise, @samp{/} is
  4997. matched only by @samp{/}.
  4998. @end table
  4999. The @option{--recursion} and @option{--no-recursion} options
  5000. (@pxref{recurse}) also affect how exclude patterns are interpreted. If
  5001. recursion is in effect, a pattern excludes a name if it matches any of
  5002. the name's parent directories.
  5003. @node problems with exclude
  5004. @unnumberedsubsec Problems with Using the @code{exclude} Options
  5005. @opindex exclude, potential problems with
  5006. Some users find @samp{exclude} options confusing. Here are some common
  5007. pitfalls:
  5008. @itemize @bullet
  5009. @item
  5010. The main operating mode of @command{tar} does not act on a path name
  5011. explicitly listed on the command line if one of its file name
  5012. components is excluded. In the example above, if
  5013. you create an archive and exclude files that end with @samp{*.o}, but
  5014. explicitly name the file @samp{dir.o/foo} after all the options have been
  5015. listed, @samp{dir.o/foo} will be excluded from the archive.
  5016. @item
  5017. You can sometimes confuse the meanings of @option{--exclude} and
  5018. @option{--exclude-from}. Be careful: use @option{--exclude} when files
  5019. to be excluded are given as a pattern on the command line. Use
  5020. @option{--exclude-from} to introduce the name of a file which contains
  5021. a list of patterns, one per line; each of these patterns can exclude
  5022. zero, one, or many files.
  5023. @item
  5024. When you use @option{--exclude=@var{pattern}}, be sure to quote the @var{pattern}
  5025. parameter, so @GNUTAR{} sees wildcard characters
  5026. like @samp{*}. If you do not do this, the shell might expand the
  5027. @samp{*} itself using files at hand, so @command{tar} might receive a
  5028. list of files instead of one pattern, or none at all, making the
  5029. command somewhat illegal. This might not correspond to what you want.
  5030. For example, write:
  5031. @smallexample
  5032. $ @kbd{tar -c -f @var{archive.tar} --exclude '*.o' @var{directory}}
  5033. @end smallexample
  5034. @noindent
  5035. rather than:
  5036. @smallexample
  5037. $ @kbd{tar -c -f @var{archive.tar} --exclude *.o @var{directory}}
  5038. @end smallexample
  5039. @item
  5040. You must use use shell syntax, or globbing, rather than @code{regexp}
  5041. syntax, when using exclude options in @command{tar}. If you try to use
  5042. @code{regexp} syntax to describe files to be excluded, your command
  5043. might fail.
  5044. @item
  5045. In earlier versions of @command{tar}, what is now the
  5046. @option{--exclude-from} option was called @option{--exclude} instead.
  5047. Now, @option{--exclude} applies to patterns listed on the command
  5048. line and @option{--exclude-from} applies to patterns listed in a
  5049. file.
  5050. @end itemize
  5051. @node Wildcards
  5052. @section Wildcards Patterns and Matching
  5053. @dfn{Globbing} is the operation by which @dfn{wildcard} characters,
  5054. @samp{*} or @samp{?} for example, are replaced and expanded into all
  5055. existing files matching the given pattern. However, @command{tar} often
  5056. uses wildcard patterns for matching (or globbing) archive members instead
  5057. of actual files in the file system. Wildcard patterns are also used for
  5058. verifying volume labels of @command{tar} archives. This section has the
  5059. purpose of explaining wildcard syntax for @command{tar}.
  5060. @FIXME{the next few paragraphs need work.}
  5061. A @var{pattern} should be written according to shell syntax, using wildcard
  5062. characters to effect globbing. Most characters in the pattern stand
  5063. for themselves in the matched string, and case is significant: @samp{a}
  5064. will match only @samp{a}, and not @samp{A}. The character @samp{?} in the
  5065. pattern matches any single character in the matched string. The character
  5066. @samp{*} in the pattern matches zero, one, or more single characters in
  5067. the matched string. The character @samp{\} says to take the following
  5068. character of the pattern @emph{literally}; it is useful when one needs to
  5069. match the @samp{?}, @samp{*}, @samp{[} or @samp{\} characters, themselves.
  5070. The character @samp{[}, up to the matching @samp{]}, introduces a character
  5071. class. A @dfn{character class} is a list of acceptable characters
  5072. for the next single character of the matched string. For example,
  5073. @samp{[abcde]} would match any of the first five letters of the alphabet.
  5074. Note that within a character class, all of the ``special characters''
  5075. listed above other than @samp{\} lose their special meaning; for example,
  5076. @samp{[-\\[*?]]} would match any of the characters, @samp{-}, @samp{\},
  5077. @samp{[}, @samp{*}, @samp{?}, or @samp{]}. (Due to parsing constraints,
  5078. the characters @samp{-} and @samp{]} must either come @emph{first} or
  5079. @emph{last} in a character class.)
  5080. @cindex Excluding characters from a character class
  5081. @cindex Character class, excluding characters from
  5082. If the first character of the class after the opening @samp{[}
  5083. is @samp{!} or @samp{^}, then the meaning of the class is reversed.
  5084. Rather than listing character to match, it lists those characters which
  5085. are @emph{forbidden} as the next single character of the matched string.
  5086. Other characters of the class stand for themselves. The special
  5087. construction @samp{[@var{a}-@var{e}]}, using an hyphen between two
  5088. letters, is meant to represent all characters between @var{a} and
  5089. @var{e}, inclusive.
  5090. @FIXME{need to add a sentence or so here to make this clear for those
  5091. who don't have dan around.}
  5092. Periods (@samp{.}) or forward slashes (@samp{/}) are not considered
  5093. special for wildcard matches. However, if a pattern completely matches
  5094. a directory prefix of a matched string, then it matches the full matched
  5095. string: excluding a directory also excludes all the files beneath it.
  5096. @node after
  5097. @section Operating Only on New Files
  5098. @UNREVISED
  5099. @cindex Excluding file by age
  5100. @cindex Data Modification time, excluding files by
  5101. @cindex Modification time, excluding files by
  5102. @cindex Age, excluding files by
  5103. The @option{--after-date=@var{date}} (@option{--newer=@var{date}},
  5104. @option{-N @var{date}}) option causes @command{tar} to only work on
  5105. files whose data modification or status change times are newer than
  5106. the @var{date} given. If @var{date} starts with @samp{/} or @samp{.},
  5107. it is taken to be a file name; the data modification time of that file
  5108. is used as the date. If you use this option when creating or appending
  5109. to an archive, the archive will only include new files. If you use
  5110. @option{--after-date} when extracting an archive, @command{tar} will
  5111. only extract files newer than the @var{date} you specify.
  5112. If you only want @command{tar} to make the date comparison based on
  5113. modification of the file's data (rather than status
  5114. changes), then use the @option{--newer-mtime=@var{date}} option.
  5115. You may use these options with any operation. Note that these options
  5116. differ from the @option{--update} (@option{-u}) operation in that they
  5117. allow you to specify a particular date against which @command{tar} can
  5118. compare when deciding whether or not to archive the files.
  5119. @table @option
  5120. @opindex after-date
  5121. @opindex newer
  5122. @item --after-date=@var{date}
  5123. @itemx --newer=@var{date}
  5124. @itemx -N @var{date}
  5125. Only store files newer than @var{date}.
  5126. Acts on files only if their data modification or status change times are
  5127. later than @var{date}. Use in conjunction with any operation.
  5128. If @var{date} starts with @samp{/} or @samp{.}, it is taken to be a file
  5129. name; the data modification time of that file is used as the date.
  5130. @opindex newer-mtime
  5131. @item --newer-mtime=@var{date}
  5132. Acts like @option{--after-date}, but only looks at data modification times.
  5133. @end table
  5134. These options limit @command{tar} to operate only on files which have
  5135. been modified after the date specified. A file's status is considered to have
  5136. changed if its contents have been modified, or if its owner,
  5137. permissions, and so forth, have been changed. (For more information on
  5138. how to specify a date, see @ref{Date input formats}; remember that the
  5139. entire date argument must be quoted if it contains any spaces.)
  5140. Gurus would say that @option{--after-date} tests both the data
  5141. modification time (@code{mtime}, the time the contents of the file
  5142. were last modified) and the status change time (@code{ctime}, the time
  5143. the file's status was last changed: owner, permissions, etc.@:)
  5144. fields, while @option{--newer-mtime} tests only the @code{mtime}
  5145. field.
  5146. To be precise, @option{--after-date} checks @emph{both} @code{mtime} and
  5147. @code{ctime} and processes the file if either one is more recent than
  5148. @var{date}, while @option{--newer-mtime} only checks @code{mtime} and
  5149. disregards @code{ctime}. Neither does it use @code{atime} (the last time the
  5150. contents of the file were looked at).
  5151. Date specifiers can have embedded spaces. Because of this, you may need
  5152. to quote date arguments to keep the shell from parsing them as separate
  5153. arguments.
  5154. @FIXME{Need example of --newer-mtime with quoted argument.}
  5155. @quotation
  5156. @strong{Please Note:} @option{--after-date} and @option{--newer-mtime}
  5157. should not be used for incremental backups. Some files (such as those
  5158. in renamed directories) are not selected properly by these options.
  5159. @xref{Incremental Dumps}.
  5160. @end quotation
  5161. @noindent
  5162. @FIXME{which tells -- need to fill this in!}
  5163. @node recurse
  5164. @section Descending into Directories
  5165. @UNREVISED
  5166. @cindex Avoiding recursion in directories
  5167. @cindex Descending directories, avoiding
  5168. @cindex Directories, avoiding recursion
  5169. @cindex Recursion in directories, avoiding
  5170. @FIXME{arrggh! this is still somewhat confusing to me. :-< }
  5171. @FIXME{show dan bob's comments, from 2-10-97}
  5172. Usually, @command{tar} will recursively explore all directories (either
  5173. those given on the command line or through the @option{--files-from}
  5174. option) for the various files they contain. However, you may not always
  5175. want @command{tar} to act this way.
  5176. @opindex no-recursion
  5177. The @option{--no-recursion} option inhibits @command{tar}'s recursive descent
  5178. into specified directories. If you specify @option{--no-recursion}, you can
  5179. use the @command{find} utility for hunting through levels of directories to
  5180. construct a list of file names which you could then pass to @command{tar}.
  5181. @command{find} allows you to be more selective when choosing which files to
  5182. archive; see @ref{files} for more information on using @command{find} with
  5183. @command{tar}, or look.
  5184. @table @option
  5185. @item --no-recursion
  5186. Prevents @command{tar} from recursively descending directories.
  5187. @opindex recursion
  5188. @item --recursion
  5189. Requires @command{tar} to recursively descend directories.
  5190. This is the default.
  5191. @end table
  5192. When you use @option{--no-recursion}, @GNUTAR{} grabs
  5193. directory entries themselves, but does not descend on them
  5194. recursively. Many people use @command{find} for locating files they
  5195. want to back up, and since @command{tar} @emph{usually} recursively
  5196. descends on directories, they have to use the @samp{@w{! -d}} option
  5197. to @command{find} @FIXME{needs more explanation or a cite to another
  5198. info file}as they usually do not want all the files in a directory.
  5199. They then use the @option{--files-from} option to archive the files
  5200. located via @command{find}.
  5201. The problem when restoring files archived in this manner is that the
  5202. directories themselves are not in the archive; so the
  5203. @option{--same-permissions} (@option{--preserve-permissions},
  5204. @option{-p}) option does not affect them---while users might really
  5205. like it to. Specifying @option{--no-recursion} is a way to tell
  5206. @command{tar} to grab only the directory entries given to it, adding
  5207. no new files on its own.
  5208. The @option{--no-recursion} option also applies when extracting: it
  5209. causes @command{tar} to extract only the matched directory entries, not
  5210. the files under those directories.
  5211. The @option{--no-recursion} option also affects how exclude patterns
  5212. are interpreted (@pxref{controlling pattern-matching with exclude}).
  5213. The @option{--no-recursion} and @option{--recursion} options apply to
  5214. later options and operands, and can be overridden by later occurrences
  5215. of @option{--no-recursion} and @option{--recursion}. For example:
  5216. @smallexample
  5217. $ @kbd{tar -cf jams.tar --no-recursion grape --recursion grape/concord}
  5218. @end smallexample
  5219. @noindent
  5220. creates an archive with one entry for @file{grape}, and the recursive
  5221. contents of @file{grape/concord}, but no entries under @file{grape}
  5222. other than @file{grape/concord}.
  5223. @node one
  5224. @section Crossing File System Boundaries
  5225. @cindex File system boundaries, not crossing
  5226. @UNREVISED
  5227. @command{tar} will normally automatically cross file system boundaries in
  5228. order to archive files which are part of a directory tree. You can
  5229. change this behavior by running @command{tar} and specifying
  5230. @option{--one-file-system} (@option{-l}). This option only affects files that are
  5231. archived because they are in a directory that is being archived;
  5232. @command{tar} will still archive files explicitly named on the command line
  5233. or through @option{--files-from}, regardless of where they reside.
  5234. @table @option
  5235. @opindex one-file-system
  5236. @item --one-file-system
  5237. @itemx -l
  5238. Prevents @command{tar} from crossing file system boundaries when
  5239. archiving. Use in conjunction with any write operation.
  5240. @end table
  5241. The @option{--one-file-system} option causes @command{tar} to modify its
  5242. normal behavior in archiving the contents of directories. If a file in
  5243. a directory is not on the same file system as the directory itself, then
  5244. @command{tar} will not archive that file. If the file is a directory
  5245. itself, @command{tar} will not archive anything beneath it; in other words,
  5246. @command{tar} will not cross mount points.
  5247. It is reported that using this option, the mount point is is archived,
  5248. but nothing under it.
  5249. This option is useful for making full or incremental archival backups of
  5250. a file system. If this option is used in conjunction with
  5251. @option{--verbose} (@option{-v}), files that are excluded are mentioned by name on the
  5252. standard error.
  5253. @menu
  5254. * directory:: Changing Directory
  5255. * absolute:: Absolute File Names
  5256. @end menu
  5257. @node directory
  5258. @subsection Changing the Working Directory
  5259. @UNREVISED
  5260. @FIXME{need to read over this node now for continuity; i've switched
  5261. things around some.}
  5262. @cindex Changing directory mid-stream
  5263. @cindex Directory, changing mid-stream
  5264. @cindex Working directory, specifying
  5265. To change the working directory in the middle of a list of file names,
  5266. either on the command line or in a file specified using
  5267. @option{--files-from} (@option{-T}), use @option{--directory} (@option{-C}).
  5268. This will change the working directory to the specified directory
  5269. after that point in the list.
  5270. @table @option
  5271. @opindex directory
  5272. @item --directory=@var{directory}
  5273. @itemx -C @var{directory}
  5274. Changes the working directory in the middle of a command line.
  5275. @end table
  5276. For example,
  5277. @smallexample
  5278. $ @kbd{tar -c -f jams.tar grape prune -C food cherry}
  5279. @end smallexample
  5280. @noindent
  5281. will place the files @file{grape} and @file{prune} from the current
  5282. directory into the archive @file{jams.tar}, followed by the file
  5283. @file{cherry} from the directory @file{food}. This option is especially
  5284. useful when you have several widely separated files that you want to
  5285. store in the same archive.
  5286. Note that the file @file{cherry} is recorded in the archive under the
  5287. precise name @file{cherry}, @emph{not} @file{food/cherry}. Thus, the
  5288. archive will contain three files that all appear to have come from the
  5289. same directory; if the archive is extracted with plain @samp{tar
  5290. --extract}, all three files will be written in the current directory.
  5291. Contrast this with the command,
  5292. @smallexample
  5293. $ @kbd{tar -c -f jams.tar grape prune -C food red/cherry}
  5294. @end smallexample
  5295. @noindent
  5296. which records the third file in the archive under the name
  5297. @file{red/cherry} so that, if the archive is extracted using
  5298. @samp{tar --extract}, the third file will be written in a subdirectory
  5299. named @file{orange-colored}.
  5300. You can use the @option{--directory} option to make the archive
  5301. independent of the original name of the directory holding the files.
  5302. The following command places the files @file{/etc/passwd},
  5303. @file{/etc/hosts}, and @file{/lib/libc.a} into the archive
  5304. @file{foo.tar}:
  5305. @smallexample
  5306. $ @kbd{tar -c -f foo.tar -C /etc passwd hosts -C /lib libc.a}
  5307. @end smallexample
  5308. @noindent
  5309. However, the names of the archive members will be exactly what they were
  5310. on the command line: @file{passwd}, @file{hosts}, and @file{libc.a}.
  5311. They will not appear to be related by file name to the original
  5312. directories where those files were located.
  5313. Note that @option{--directory} options are interpreted consecutively. If
  5314. @option{--directory} specifies a relative file name, it is interpreted
  5315. relative to the then current directory, which might not be the same as
  5316. the original current working directory of @command{tar}, due to a previous
  5317. @option{--directory} option.
  5318. When using @option{--files-from} (@pxref{files}), you can put various
  5319. @command{tar} options (including @option{-C}) in the file list. Notice,
  5320. however, that in this case the option and its argument may not be
  5321. separated by whitespace. If you use short option, its argument must
  5322. either follow the option letter immediately, without any intervening
  5323. whitespace, or occupy the next line. Otherwise, if you use long
  5324. option, separate its argument by an equal sign.
  5325. For instance, the file list for the above example will be:
  5326. @smallexample
  5327. @group
  5328. -C
  5329. /etc
  5330. passwd
  5331. hosts
  5332. -C
  5333. /lib
  5334. libc.a
  5335. @end group
  5336. @end smallexample
  5337. @noindent
  5338. To use it, you would invoke @command{tar} as follows:
  5339. @smallexample
  5340. $ @kbd{tar -c -f foo.tar --files-from list}
  5341. @end smallexample
  5342. Notice also that you can only use the short option variant in the file
  5343. list, i.e., always use @option{-C}, not @option{--directory}.
  5344. The interpretation of @option{--directory} is disabled by
  5345. @option{--null} option.
  5346. @node absolute
  5347. @subsection Absolute File Names
  5348. @UNREVISED
  5349. @table @option
  5350. @opindex absolute-names
  5351. @item --absolute-names
  5352. @itemx -P
  5353. Do not strip leading slashes from file names, and permit file names
  5354. containing a @file{..} file name component.
  5355. @end table
  5356. By default, @GNUTAR{} drops a leading @samp{/} on
  5357. input or output, and complains about file names containing a @file{..}
  5358. component. This option turns off this behavior.
  5359. When @command{tar} extracts archive members from an archive, it strips any
  5360. leading slashes (@samp{/}) from the member name. This causes absolute
  5361. member names in the archive to be treated as relative file names. This
  5362. allows you to have such members extracted wherever you want, instead of
  5363. being restricted to extracting the member in the exact directory named
  5364. in the archive. For example, if the archive member has the name
  5365. @file{/etc/passwd}, @command{tar} will extract it as if the name were
  5366. really @file{etc/passwd}.
  5367. File names containing @file{..} can cause problems when extracting, so
  5368. @command{tar} normally warns you about such files when creating an
  5369. archive, and rejects attempts to extracts such files.
  5370. Other @command{tar} programs do not do this. As a result, if you
  5371. create an archive whose member names start with a slash, they will be
  5372. difficult for other people with a non-@GNUTAR{}
  5373. program to use. Therefore, @GNUTAR{} also strips
  5374. leading slashes from member names when putting members into the
  5375. archive. For example, if you ask @command{tar} to add the file
  5376. @file{/bin/ls} to an archive, it will do so, but the member name will
  5377. be @file{bin/ls}.@footnote{A side effect of this is that when
  5378. @option{--create} is used with @option{--verbose} the resulting output
  5379. is not, generally speaking, the same as the one you'd get running
  5380. @kbd{tar --list} command. This may be important if you use some
  5381. scripts for comparing both outputs. @xref{listing member and file names},
  5382. for the information on how to handle this case.}
  5383. If you use the @option{--absolute-names} (@option{-P}) option,
  5384. @command{tar} will do none of these transformations.
  5385. To archive or extract files relative to the root directory, specify
  5386. the @option{--absolute-names} (@option{-P}) option.
  5387. Normally, @command{tar} acts on files relative to the working
  5388. directory---ignoring superior directory names when archiving, and
  5389. ignoring leading slashes when extracting.
  5390. When you specify @option{--absolute-names} (@option{-P}),
  5391. @command{tar} stores file names including all superior directory
  5392. names, and preserves leading slashes. If you only invoked
  5393. @command{tar} from the root directory you would never need the
  5394. @option{--absolute-names} option, but using this option
  5395. may be more convenient than switching to root.
  5396. @FIXME{Should be an example in the tutorial/wizardry section using this
  5397. to transfer files between systems.}
  5398. @FIXME{Is write access an issue?}
  5399. @table @option
  5400. @item --absolute-names
  5401. Preserves full file names (including superior directory names) when
  5402. archiving files. Preserves leading slash when extracting files.
  5403. @end table
  5404. @FIXME{this is still horrible; need to talk with dan on monday.}
  5405. @command{tar} prints out a message about removing the @samp{/} from
  5406. file names. This message appears once per @GNUTAR{}
  5407. invocation. It represents something which ought to be told; ignoring
  5408. what it means can cause very serious surprises, later.
  5409. Some people, nevertheless, do not want to see this message. Wanting to
  5410. play really dangerously, one may of course redirect @command{tar} standard
  5411. error to the sink. For example, under @command{sh}:
  5412. @smallexample
  5413. $ @kbd{tar -c -f archive.tar /home 2> /dev/null}
  5414. @end smallexample
  5415. @noindent
  5416. Another solution, both nicer and simpler, would be to change to
  5417. the @file{/} directory first, and then avoid absolute notation.
  5418. For example:
  5419. @smallexample
  5420. $ @kbd{(cd / && tar -c -f archive.tar home)}
  5421. $ @kbd{tar -c -f archive.tar -C / home}
  5422. @end smallexample
  5423. @include getdate.texi
  5424. @node Formats
  5425. @chapter Controlling the Archive Format
  5426. @cindex Tar archive formats
  5427. Due to historical reasons, there are several formats of tar archives.
  5428. All of them are based on the same principles, but have some subtle
  5429. differences that often make them incompatible with each other.
  5430. GNU tar is able to create and handle archives in a variety of formats.
  5431. The most frequently used formats are (in alphabetical order):
  5432. @table @asis
  5433. @item gnu
  5434. Format used by @GNUTAR{} versions up to 1.13.25. This format derived
  5435. from an early @acronym{POSIX} standard, adding some improvements such as
  5436. sparse file handling and incremental archives. Unfortunately these
  5437. features were implemented in a way incompatible with other archive
  5438. formats.
  5439. Archives in @samp{gnu} format are able to hold pathnames of unlimited
  5440. length.
  5441. @item oldgnu
  5442. Format used by @GNUTAR{} of versions prior to 1.12.
  5443. @item v7
  5444. Archive format, compatible with the V7 implementation of tar. This
  5445. format imposes a number of limitations. The most important of them
  5446. are:
  5447. @enumerate
  5448. @item The maximum length of a file name is limited to 99 characters.
  5449. @item The maximum length of a symbolic link is limited to 99 characters.
  5450. @item It is impossible to store special files (block and character
  5451. devices, fifos etc.)
  5452. @item Maximum value of user or group ID is limited to 2097151 (7777777
  5453. octal)
  5454. @item V7 archives do not contain symbolic ownership information (user
  5455. and group name of the file owner).
  5456. @end enumerate
  5457. This format has traditionally been used by Automake when producing
  5458. Makefiles. This practice will change in the future, in the meantime,
  5459. however this means that projects containing filenames more than 99
  5460. characters long will not be able to use @GNUTAR{} @value{VERSION} and
  5461. Automake prior to 1.9.
  5462. @item ustar
  5463. Archive format defined by @acronym{POSIX.1-1988} specification. It stores
  5464. symbolic ownership information. It is also able to store
  5465. special files. However, it imposes several restrictions as well:
  5466. @enumerate
  5467. @item The maximum length of a file name is limited to 256 characters,
  5468. provided that the filename can be split at directory separator in
  5469. two parts, first of them being at most 155 bytes long. So, in most
  5470. cases the maximum file name length will be shorter than 256
  5471. characters.
  5472. @item The maximum length of a symbolic link name is limited to
  5473. 100 characters.
  5474. @item Maximum size of a file the archive is able to accomodate
  5475. is 8GB
  5476. @item Maximum value of UID/GID is 2097151.
  5477. @item Maximum number of bits in device major and minor numbers is 21.
  5478. @end enumerate
  5479. @item star
  5480. Format used by J@"org Schilling @command{star}
  5481. implementation. @GNUTAR{} is able to read @samp{star} archives but
  5482. currently does not produce them.
  5483. @item posix
  5484. Archive format defined by @acronym{POSIX.1-2001} specification. This is the
  5485. most flexible and feature-rich format. It does not impose any
  5486. restrictions on file sizes or filename lengths. This format is quite
  5487. recent, so not all tar implementations are able to handle it properly.
  5488. However, this format is designed in such a way that any tar
  5489. implementation able to read @samp{ustar} archives will be able to read
  5490. most @samp{posix} archives as well, with the only exception that any
  5491. additional information (such as long file names etc.) will in such
  5492. case be extracted as plain text files along with the files it refers to.
  5493. This archive format will be the default format for future versions
  5494. of @GNUTAR{}.
  5495. @end table
  5496. The following table summarizes the limitations of each of these
  5497. formats:
  5498. @multitable @columnfractions .10 .20 .20 .20 .20
  5499. @headitem Format @tab UID @tab File Size @tab Path Name @tab Devn
  5500. @item gnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
  5501. @item oldgnu @tab 1.8e19 @tab Unlimited @tab Unlimited @tab 63
  5502. @item v7 @tab 2097151 @tab 8GB @tab 99 @tab n/a
  5503. @item ustar @tab 2097151 @tab 8GB @tab 256 @tab 21
  5504. @item posix @tab Unlimited @tab Unlimited @tab Unlimited @tab Unlimited
  5505. @end multitable
  5506. The default format for @GNUTAR{} is defined at compilation
  5507. time. You may check it by running @command{tar --help}, and examining
  5508. the last lines of its output. Usually, @GNUTAR{} is configured
  5509. to create archives in @samp{gnu} format, however, future version will
  5510. switch to @samp{posix}.
  5511. @menu
  5512. * Portability:: Making @command{tar} Archives More Portable
  5513. * Compression:: Using Less Space through Compression
  5514. * Attributes:: Handling File Attributes
  5515. * Standard:: The Standard Format
  5516. * Extensions:: @acronym{GNU} Extensions to the Archive Format
  5517. * cpio:: Comparison of @command{tar} and @command{cpio}
  5518. @end menu
  5519. @node Portability
  5520. @section Making @command{tar} Archives More Portable
  5521. Creating a @command{tar} archive on a particular system that is meant to be
  5522. useful later on many other machines and with other versions of @command{tar}
  5523. is more challenging than you might think. @command{tar} archive formats
  5524. have been evolving since the first versions of Unix. Many such formats
  5525. are around, and are not always compatible with each other. This section
  5526. discusses a few problems, and gives some advice about making @command{tar}
  5527. archives more portable.
  5528. One golden rule is simplicity. For example, limit your @command{tar}
  5529. archives to contain only regular files and directories, avoiding
  5530. other kind of special files. Do not attempt to save sparse files or
  5531. contiguous files as such. Let's discuss a few more problems, in turn.
  5532. @FIXME{Discuss GNU extensions (incremental backups, multi-volume
  5533. archives and archive labels) in GNU and PAX formats.}
  5534. @menu
  5535. * Portable Names:: Portable Names
  5536. * dereference:: Symbolic Links
  5537. * old:: Old V7 Archives
  5538. * ustar:: Ustar Archives
  5539. * gnu:: GNU and old GNU format archives.
  5540. * posix:: @acronym{POSIX} archives
  5541. * Checksumming:: Checksumming Problems
  5542. * Large or Negative Values:: Large files, negative time stamps, etc.
  5543. @end menu
  5544. @node Portable Names
  5545. @subsection Portable Names
  5546. Use portable file and member names. A name is portable if it contains
  5547. only ASCII letters and digits, @samp{/}, @samp{.}, @samp{_}, and
  5548. @samp{-}; it cannot be empty, start with @samp{-} or @samp{//}, or
  5549. contain @samp{/-}. Avoid deep directory nesting. For portability to
  5550. old Unix hosts, limit your file name components to 14 characters or
  5551. less.
  5552. If you intend to have your @command{tar} archives to be read under
  5553. MSDOS, you should not rely on case distinction for file names, and you
  5554. might use the @acronym{GNU} @command{doschk} program for helping you
  5555. further diagnosing illegal MSDOS names, which are even more limited
  5556. than System V's.
  5557. @node dereference
  5558. @subsection Symbolic Links
  5559. @cindex File names, using symbolic links
  5560. @cindex Symbolic link as file name
  5561. @opindex dereference
  5562. Normally, when @command{tar} archives a symbolic link, it writes a
  5563. block to the archive naming the target of the link. In that way, the
  5564. @command{tar} archive is a faithful record of the file system contents.
  5565. @option{--dereference} (@option{-h}) is used with @option{--create} (@option{-c}), and causes
  5566. @command{tar} to archive the files symbolic links point to, instead of
  5567. the links themselves. When this option is used, when @command{tar}
  5568. encounters a symbolic link, it will archive the linked-to file,
  5569. instead of simply recording the presence of a symbolic link.
  5570. The name under which the file is stored in the file system is not
  5571. recorded in the archive. To record both the symbolic link name and
  5572. the file name in the system, archive the file under both names. If
  5573. all links were recorded automatically by @command{tar}, an extracted file
  5574. might be linked to a file name that no longer exists in the file
  5575. system.
  5576. If a linked-to file is encountered again by @command{tar} while creating
  5577. the same archive, an entire second copy of it will be stored. (This
  5578. @emph{might} be considered a bug.)
  5579. So, for portable archives, do not archive symbolic links as such,
  5580. and use @option{--dereference} (@option{-h}): many systems do not support
  5581. symbolic links, and moreover, your distribution might be unusable if
  5582. it contains unresolved symbolic links.
  5583. @node old
  5584. @subsection Old V7 Archives
  5585. @cindex Format, old style
  5586. @cindex Old style format
  5587. @cindex Old style archives
  5588. @cindex v7 archive format
  5589. Certain old versions of @command{tar} cannot handle additional
  5590. information recorded by newer @command{tar} programs. To create an
  5591. archive in V7 format (not ANSI), which can be read by these old
  5592. versions, specify the @option{--format=v7} option in
  5593. conjunction with the @option{--create} (@option{-c}) (@command{tar} also
  5594. accepts @option{--portability} or @samp{op-old-archive} for this
  5595. option). When you specify it,
  5596. @command{tar} leaves out information about directories, pipes, fifos,
  5597. contiguous files, and device files, and specifies file ownership by
  5598. group and user IDs instead of group and user names.
  5599. When updating an archive, do not use @option{--format=v7}
  5600. unless the archive was created using this option.
  5601. In most cases, a @emph{new} format archive can be read by an @emph{old}
  5602. @command{tar} program without serious trouble, so this option should
  5603. seldom be needed. On the other hand, most modern @command{tar}s are
  5604. able to read old format archives, so it might be safer for you to
  5605. always use @option{--format=v7} for your distributions.
  5606. @node ustar
  5607. @subsection Ustar Archive Format
  5608. @cindex ustar archive format
  5609. Archive format defined by @acronym{POSIX}.1-1988 specification is called
  5610. @code{ustar}. Although it is more flexible than the V7 format, it
  5611. still has many restrictions (@xref{Formats,ustar}, for the detailed
  5612. description of @code{ustar} format). Along with V7 format,
  5613. @code{ustar} format is a good choice for archives intended to be read
  5614. with other implementations of @command{tar}.
  5615. To create archive in @code{ustar} format, use @option{--format=ustar}
  5616. option in conjunction with the @option{--create} (@option{-c}).
  5617. @node gnu
  5618. @subsection @acronym{GNU} and old @GNUTAR{} format
  5619. @cindex GNU archive format
  5620. @cindex Old GNU archive format
  5621. @GNUTAR{} was based on an early draft of the
  5622. @acronym{POSIX} 1003.1 @code{ustar} standard. @acronym{GNU} extensions to
  5623. @command{tar}, such as the support for file names longer than 100
  5624. characters, use portions of the @command{tar} header record which were
  5625. specified in that @acronym{POSIX} draft as unused. Subsequent changes in
  5626. @acronym{POSIX} have allocated the same parts of the header record for
  5627. other purposes. As a result, @GNUTAR{} format is
  5628. incompatible with the current @acronym{POSIX} specification, and with
  5629. @command{tar} programs that follow it.
  5630. In the majority of cases, @command{tar} will be configured to create
  5631. this format by default. This will change in the future releases, since
  5632. we plan to make @samp{posix} format the default.
  5633. To force creation a @GNUTAR{} archive, use option
  5634. @option{--format=gnu}.
  5635. @node posix
  5636. @subsection @GNUTAR{} and @acronym{POSIX} @command{tar}
  5637. @cindex POSIX archive format
  5638. @cindex PAX archive format
  5639. The version @value{VERSION} of @GNUTAR{} is able
  5640. to read and create archives conforming to @acronym{POSIX.1-2001} standard.
  5641. A @acronym{POSIX} conformant archive will be created if @command{tar}
  5642. was given @option{--format=posix} option.
  5643. @node Checksumming
  5644. @subsection Checksumming Problems
  5645. SunOS and HP-UX @command{tar} fail to accept archives created using
  5646. @GNUTAR{} and containing non-ASCII file names, that
  5647. is, file names having characters with the eight bit set, because they
  5648. use signed checksums, while @GNUTAR{} uses unsigned
  5649. checksums while creating archives, as per @acronym{POSIX} standards. On
  5650. reading, @GNUTAR{} computes both checksums and
  5651. accept any. It is somewhat worrying that a lot of people may go
  5652. around doing backup of their files using faulty (or at least
  5653. non-standard) software, not learning about it until it's time to
  5654. restore their missing files with an incompatible file extractor, or
  5655. vice versa.
  5656. @GNUTAR{} compute checksums both ways, and accept
  5657. any on read, so @acronym{GNU} tar can read Sun tapes even with their
  5658. wrong checksums. @GNUTAR{} produces the standard
  5659. checksum, however, raising incompatibilities with Sun. That is to
  5660. say, @GNUTAR{} has not been modified to
  5661. @emph{produce} incorrect archives to be read by buggy @command{tar}'s.
  5662. I've been told that more recent Sun @command{tar} now read standard
  5663. archives, so maybe Sun did a similar patch, after all?
  5664. The story seems to be that when Sun first imported @command{tar}
  5665. sources on their system, they recompiled it without realizing that
  5666. the checksums were computed differently, because of a change in
  5667. the default signing of @code{char}'s in their compiler. So they
  5668. started computing checksums wrongly. When they later realized their
  5669. mistake, they merely decided to stay compatible with it, and with
  5670. themselves afterwards. Presumably, but I do not really know, HP-UX
  5671. has chosen that their @command{tar} archives to be compatible with Sun's.
  5672. The current standards do not favor Sun @command{tar} format. In any
  5673. case, it now falls on the shoulders of SunOS and HP-UX users to get
  5674. a @command{tar} able to read the good archives they receive.
  5675. @node Large or Negative Values
  5676. @subsection Large or Negative Values
  5677. @cindex large values
  5678. @cindex future time stamps
  5679. @cindex negative time stamps
  5680. @acronym{POSIX} @command{tar} format uses fixed-sized unsigned octal strings
  5681. to represent numeric values. User and group IDs and device major and
  5682. minor numbers have unsigned 21-bit representations, and file sizes and
  5683. times have unsigned 33-bit representations. @GNUTAR{}
  5684. generates @acronym{POSIX} representations when possible, but for values
  5685. outside the @acronym{POSIX} range it generates two's-complement base-256
  5686. strings: uids, gids, and device numbers have signed 57-bit
  5687. representations, and file sizes and times have signed 89-bit
  5688. representations. These representations are an extension to @acronym{POSIX}
  5689. @command{tar} format, so they are not universally portable.
  5690. The most common portability problems with out-of-range numeric values
  5691. are large files and future or negative time stamps.
  5692. Portable archives should avoid members of 8 GB or larger, as @acronym{POSIX}
  5693. @command{tar} format cannot represent them.
  5694. Portable archives should avoid time stamps from the future. @acronym{POSIX}
  5695. @command{tar} format can represent time stamps in the range 1970-01-01
  5696. 00:00:00 through 2242-03-16 12:56:31 @sc{utc}. However, many current
  5697. hosts use a signed 32-bit @code{time_t}, or internal time stamp format,
  5698. and cannot represent time stamps after 2038-01-19 03:14:07 @sc{utc}; so
  5699. portable archives must avoid these time stamps for many years to come.
  5700. Portable archives should also avoid time stamps before 1970. These time
  5701. stamps are a common @acronym{POSIX} extension but their @code{time_t}
  5702. representations are negative. Many traditional @command{tar}
  5703. implementations generate a two's complement representation for negative
  5704. time stamps that assumes a signed 32-bit @code{time_t}; hence they
  5705. generate archives that are not portable to hosts with differing
  5706. @code{time_t} representations. @GNUTAR{} recognizes this
  5707. situation when it is run on host with a signed 32-bit @code{time_t}, but
  5708. it issues a warning, as these time stamps are nonstandard and unportable.
  5709. @node Compression
  5710. @section Using Less Space through Compression
  5711. @menu
  5712. * gzip:: Creating and Reading Compressed Archives
  5713. * sparse:: Archiving Sparse Files
  5714. @end menu
  5715. @node gzip
  5716. @subsection Creating and Reading Compressed Archives
  5717. @cindex Compressed archives
  5718. @cindex Storing archives in compressed format
  5719. @GNUTAR{} is able to create and read compressed archives. It supports
  5720. @command{gzip} and @command{bzip2} compression programs. For backward
  5721. compatibilty, it also supports @command{compress} command, although
  5722. we strongly recommend against using it, since there is a patent
  5723. covering the algorithm it uses and you could be sued for patent
  5724. infringement merely by running @command{compress}! Besides, it is less
  5725. effective than @command{gzip} and @command{bzip2}.
  5726. Creating a compressed archive is simple: you just specify a
  5727. @dfn{compression option} along with the usual archive creation
  5728. commands. The compression option is @option{-z} (@option{--gzip}) to
  5729. create a @command{gzip} compressed archive, @option{-j}
  5730. (@option{--bzip2}) to create a @command{bzip2} compressed archive, and
  5731. @option{-Z} (@option{--compress}) to use @command{compress} program.
  5732. For example:
  5733. @smallexample
  5734. $ @kbd{tar cfz archive.tar.gz .}
  5735. @end smallexample
  5736. Reading compressed archive is even simpler: you don't need to specify
  5737. any additional options as @GNUTAR{} recognizes its format
  5738. automatically. Thus, the following commands will list and extract the
  5739. archive created in previous example:
  5740. @smallexample
  5741. # List the compressed archive
  5742. $ @kbd{tar tf archive.tar.gz}
  5743. # Extract the compressed archive
  5744. $ @kbd{tar xf archive.tar.gz}
  5745. @end smallexample
  5746. The only case when you have to specify a decompression option while
  5747. reading the archive is when reading from a pipe or from a tape drive
  5748. that does not support random access. However, in this case @GNUTAR{}
  5749. will indicate which option you should use. For example:
  5750. @smallexample
  5751. $ @kbd{cat archive.tar.gz | tar tf -}
  5752. tar: Archive is compressed. Use -z option
  5753. tar: Error is not recoverable: exiting now
  5754. @end smallexample
  5755. If you see such diagnostics, just add the suggested option to the
  5756. invocation of @GNUTAR{}:
  5757. @smallexample
  5758. $ @kbd{cat archive.tar.gz | tar tfz -}
  5759. @end smallexample
  5760. Notice also, that there are several restrictions on operations on
  5761. compressed archives. First of all, compressed archives cannot be
  5762. modified, i.e., you cannot update (@option{--update} (@option{-u})) them or delete
  5763. (@option{--delete}) members from them. Likewise, you cannot append
  5764. another @command{tar} archive to a compressed archive using
  5765. @option{--append} (@option{-r})). Secondly, multi-volume archives cannot be
  5766. compressed.
  5767. The following table summarizes compression options used by @GNUTAR{}.
  5768. @table @option
  5769. @opindex gzip
  5770. @opindex ungzip
  5771. @item -z
  5772. @itemx --gzip
  5773. @itemx --ungzip
  5774. Filter the archive through @command{gzip}.
  5775. You can use @option{--gzip} and @option{--gunzip} on physical devices
  5776. (tape drives, etc.) and remote files as well as on normal files; data
  5777. to or from such devices or remote files is reblocked by another copy
  5778. of the @command{tar} program to enforce the specified (or default) record
  5779. size. The default compression parameters are used; if you need to
  5780. override them, set @env{GZIP} environment variable, e.g.:
  5781. @smallexample
  5782. $ @kbd{GZIP=--best tar cfz archive.tar.gz subdir}
  5783. @end smallexample
  5784. @noindent
  5785. Another way would be to avoid the @option{--gzip} (@option{--gunzip}, @option{--ungzip}, @option{-z}) option and run
  5786. @command{gzip} explicitly:
  5787. @smallexample
  5788. $ @kbd{tar cf - subdir | gzip --best -c - > archive.tar.gz}
  5789. @end smallexample
  5790. @cindex corrupted archives
  5791. About corrupted compressed archives: @command{gzip}'ed files have no
  5792. redundancy, for maximum compression. The adaptive nature of the
  5793. compression scheme means that the compression tables are implicitly
  5794. spread all over the archive. If you lose a few blocks, the dynamic
  5795. construction of the compression tables becomes unsynchronized, and there
  5796. is little chance that you could recover later in the archive.
  5797. There are pending suggestions for having a per-volume or per-file
  5798. compression in @GNUTAR{}. This would allow for viewing the
  5799. contents without decompression, and for resynchronizing decompression at
  5800. every volume or file, in case of corrupted archives. Doing so, we might
  5801. lose some compressibility. But this would have make recovering easier.
  5802. So, there are pros and cons. We'll see!
  5803. @opindex bzip2
  5804. @item -j
  5805. @itemx --bzip2
  5806. Filter the archive through @code{bzip2}. Otherwise like @option{--gzip}.
  5807. @opindex compress
  5808. @opindex uncompress
  5809. @item -Z
  5810. @itemx --compress
  5811. @itemx --uncompress
  5812. Filter the archive through @command{compress}. Otherwise like @option{--gzip}.
  5813. The @acronym{GNU} Project recommends you not use
  5814. @command{compress}, because there is a patent covering the algorithm it
  5815. uses. You could be sued for patent infringement merely by running
  5816. @command{compress}.
  5817. @opindex use-compress-program
  5818. @item --use-compress-program=@var{prog}
  5819. Use external compression program @var{prog}. Use this option if you
  5820. have a compression program that @GNUTAR{} does not support. There
  5821. are two requirements to which @var{prog} should comply:
  5822. First, when called without options, it should read data from standard
  5823. input, compress it and output it on standard output.
  5824. Secondly, if called with @option{-d} argument, it should do exactly
  5825. the opposite, i.e., read the compressed data from the standard input
  5826. and produce uncompressed data on the standard output.
  5827. @end table
  5828. @FIXME{I have one question, or maybe it's a suggestion if there isn't a way
  5829. to do it now. I would like to use @option{--gzip}, but I'd also like
  5830. the output to be fed through a program like @acronym{GNU}
  5831. @command{ecc} (actually, right now that's @samp{exactly} what I'd like
  5832. to use :-)), basically adding ECC protection on top of compression.
  5833. It seems as if this should be quite easy to do, but I can't work out
  5834. exactly how to go about it. Of course, I can pipe the standard output
  5835. of @command{tar} through @command{ecc}, but then I lose (though I
  5836. haven't started using it yet, I confess) the ability to have
  5837. @command{tar} use @command{rmt} for it's I/O (I think).
  5838. I think the most straightforward thing would be to let me specify a
  5839. general set of filters outboard of compression (preferably ordered,
  5840. so the order can be automatically reversed on input operations, and
  5841. with the options they require specifiable), but beggars shouldn't be
  5842. choosers and anything you decide on would be fine with me.
  5843. By the way, I like @command{ecc} but if (as the comments say) it can't
  5844. deal with loss of block sync, I'm tempted to throw some time at adding
  5845. that capability. Supposing I were to actually do such a thing and
  5846. get it (apparently) working, do you accept contributed changes to
  5847. utilities like that? (Leigh Clayton @file{loc@@soliton.com}, May 1995).
  5848. Isn't that exactly the role of the @option{--use-compress-prog=@var{program}} option?
  5849. I never tried it myself, but I suspect you may want to write a
  5850. @var{prog} script or program able to filter stdin to stdout to
  5851. way you want. It should recognize the @option{-d} option, for when
  5852. extraction is needed rather than creation.
  5853. It has been reported that if one writes compressed data (through the
  5854. @option{--gzip} or @option{--compress} options) to a DLT and tries to use
  5855. the DLT compression mode, the data will actually get bigger and one will
  5856. end up with less space on the tape.}
  5857. @node sparse
  5858. @subsection Archiving Sparse Files
  5859. @cindex Sparse Files
  5860. @UNREVISED
  5861. @table @option
  5862. @opindex sparse
  5863. @item -S
  5864. @itemx --sparse
  5865. Handle sparse files efficiently.
  5866. @end table
  5867. This option causes all files to be put in the archive to be tested for
  5868. sparseness, and handled specially if they are. The @option{--sparse}
  5869. (@option{-S}) option is useful when many @code{dbm} files, for example, are being
  5870. backed up. Using this option dramatically decreases the amount of
  5871. space needed to store such a file.
  5872. In later versions, this option may be removed, and the testing and
  5873. treatment of sparse files may be done automatically with any special
  5874. @acronym{GNU} options. For now, it is an option needing to be specified on
  5875. the command line with the creation or updating of an archive.
  5876. Files in the file system occasionally have ``holes.'' A hole in a file
  5877. is a section of the file's contents which was never written. The
  5878. contents of a hole read as all zeros. On many operating systems,
  5879. actual disk storage is not allocated for holes, but they are counted
  5880. in the length of the file. If you archive such a file, @command{tar}
  5881. could create an archive longer than the original. To have @command{tar}
  5882. attempt to recognize the holes in a file, use @option{--sparse} (@option{-S}). When
  5883. you use this option, then, for any file using less disk space than
  5884. would be expected from its length, @command{tar} searches the file for
  5885. consecutive stretches of zeros. It then records in the archive for
  5886. the file where the consecutive stretches of zeros are, and only
  5887. archives the ``real contents'' of the file. On extraction (using
  5888. @option{--sparse} is not needed on extraction) any such
  5889. files have holes created wherever the continuous stretches of zeros
  5890. were found. Thus, if you use @option{--sparse}, @command{tar} archives
  5891. won't take more space than the original.
  5892. A file is sparse if it contains blocks of zeros whose existence is
  5893. recorded, but that have no space allocated on disk. When you specify
  5894. the @option{--sparse} option in conjunction with the @option{--create}
  5895. (@option{-c}) operation, @command{tar} tests all files for sparseness
  5896. while archiving. If @command{tar} finds a file to be sparse, it uses a
  5897. sparse representation of the file in the archive. @xref{create}, for
  5898. more information about creating archives.
  5899. @option{--sparse} is useful when archiving files, such as dbm files,
  5900. likely to contain many nulls. This option dramatically
  5901. decreases the amount of space needed to store such an archive.
  5902. @quotation
  5903. @strong{Please Note:} Always use @option{--sparse} when performing file
  5904. system backups, to avoid archiving the expanded forms of files stored
  5905. sparsely in the system.
  5906. Even if your system has no sparse files currently, some may be
  5907. created in the future. If you use @option{--sparse} while making file
  5908. system backups as a matter of course, you can be assured the archive
  5909. will never take more space on the media than the files take on disk
  5910. (otherwise, archiving a disk filled with sparse files might take
  5911. hundreds of tapes). @FIXME-xref{incremental when node name is set.}
  5912. @end quotation
  5913. @command{tar} ignores the @option{--sparse} option when reading an archive.
  5914. @table @option
  5915. @item --sparse
  5916. @itemx -S
  5917. Files stored sparsely in the file system are represented sparsely in
  5918. the archive. Use in conjunction with write operations.
  5919. @end table
  5920. However, users should be well aware that at archive creation time,
  5921. @GNUTAR{} still has to read whole disk file to
  5922. locate the @dfn{holes}, and so, even if sparse files use little space
  5923. on disk and in the archive, they may sometimes require inordinate
  5924. amount of time for reading and examining all-zero blocks of a file.
  5925. Although it works, it's painfully slow for a large (sparse) file, even
  5926. though the resulting tar archive may be small. (One user reports that
  5927. dumping a @file{core} file of over 400 megabytes, but with only about
  5928. 3 megabytes of actual data, took about 9 minutes on a Sun Sparcstation
  5929. ELC, with full CPU utilization.)
  5930. This reading is required in all cases and is not related to the fact
  5931. the @option{--sparse} option is used or not, so by merely @emph{not}
  5932. using the option, you are not saving time@footnote{Well! We should say
  5933. the whole truth, here. When @option{--sparse} is selected while creating
  5934. an archive, the current @command{tar} algorithm requires sparse files to be
  5935. read twice, not once. We hope to develop a new archive format for saving
  5936. sparse files in which one pass will be sufficient.}.
  5937. Programs like @command{dump} do not have to read the entire file; by
  5938. examining the file system directly, they can determine in advance
  5939. exactly where the holes are and thus avoid reading through them. The
  5940. only data it need read are the actual allocated data blocks.
  5941. @GNUTAR{} uses a more portable and straightforward
  5942. archiving approach, it would be fairly difficult that it does
  5943. otherwise. Elizabeth Zwicky writes to @file{comp.unix.internals}, on
  5944. 1990-12-10:
  5945. @quotation
  5946. What I did say is that you cannot tell the difference between a hole and an
  5947. equivalent number of nulls without reading raw blocks. @code{st_blocks} at
  5948. best tells you how many holes there are; it doesn't tell you @emph{where}.
  5949. Just as programs may, conceivably, care what @code{st_blocks} is (care
  5950. to name one that does?), they may also care where the holes are (I have
  5951. no examples of this one either, but it's equally imaginable).
  5952. I conclude from this that good archivers are not portable. One can
  5953. arguably conclude that if you want a portable program, you can in good
  5954. conscience restore files with as many holes as possible, since you can't
  5955. get it right.
  5956. @end quotation
  5957. @node Attributes
  5958. @section Handling File Attributes
  5959. @UNREVISED
  5960. When @command{tar} reads files, it updates their access times. To
  5961. avoid this, use the @option{--atime-preserve[=METHOD]} option, which can either
  5962. reset the access time retroactively or avoid changing it in the first
  5963. place.
  5964. Handling of file attributes
  5965. @table @option
  5966. @opindex atime-preserve
  5967. @item --atime-preserve
  5968. @itemx --atime-preserve=replace
  5969. @itemx --atime-preserve=system
  5970. Preserve the access times of files that are read. This works only for
  5971. files that you own, unless you have superuser privileges.
  5972. @option{--atime-preserve=replace} works on most systems, but it also
  5973. restores the data modification time and updates the status change
  5974. time. Hence it doesn't interact with incremental dumps nicely
  5975. (@pxref{Backups}), and it can set access or data modification times
  5976. incorrectly if other programs access the file while @command{tar} is
  5977. running.
  5978. @option{--atime-preserve=system} avoids changing the access time in
  5979. the first place, if the operating system supports this.
  5980. Unfortunately, this may or may not work on any given operating system
  5981. or file system. If @command{tar} knows for sure it won't work, it
  5982. complains right away.
  5983. Currently @option{--atime-preserve} with no operand defaults to
  5984. @option{--atime-preserve=replace}, but this is intended to change to
  5985. @option{--atime-preserve=system} when the latter is better-supported.
  5986. @opindex touch
  5987. @item -m
  5988. @itemx --touch
  5989. Do not extract data modification time.
  5990. When this option is used, @command{tar} leaves the data modification times
  5991. of the files it extracts as the times when the files were extracted,
  5992. instead of setting it to the times recorded in the archive.
  5993. This option is meaningless with @option{--list} (@option{-t}).
  5994. @opindex same-owner
  5995. @item --same-owner
  5996. Create extracted files with the same ownership they have in the
  5997. archive.
  5998. This is the default behavior for the superuser,
  5999. so this option is meaningful only for non-root users, when @command{tar}
  6000. is executed on those systems able to give files away. This is
  6001. considered as a security flaw by many people, at least because it
  6002. makes quite difficult to correctly account users for the disk space
  6003. they occupy. Also, the @code{suid} or @code{sgid} attributes of
  6004. files are easily and silently lost when files are given away.
  6005. When writing an archive, @command{tar} writes the user id and user name
  6006. separately. If it can't find a user name (because the user id is not
  6007. in @file{/etc/passwd}), then it does not write one. When restoring,
  6008. and doing a @code{chmod} like when you use @option{--same-permissions},
  6009. @FIXME{same-owner?}it tries to look the name (if one was written)
  6010. up in @file{/etc/passwd}. If it fails, then it uses the user id
  6011. stored in the archive instead.
  6012. @opindex no-same-owner
  6013. @item --no-same-owner
  6014. @itemx -o
  6015. Do not attempt to restore ownership when extracting. This is the
  6016. default behavior for ordinary users, so this option has an effect
  6017. only for the superuser.
  6018. @opindex numeric-owner
  6019. @item --numeric-owner
  6020. The @option{--numeric-owner} option allows (ANSI) archives to be written
  6021. without user/group name information or such information to be ignored
  6022. when extracting. It effectively disables the generation and/or use
  6023. of user/group name information. This option forces extraction using
  6024. the numeric ids from the archive, ignoring the names.
  6025. This is useful in certain circumstances, when restoring a backup from
  6026. an emergency floppy with different passwd/group files for example.
  6027. It is otherwise impossible to extract files with the right ownerships
  6028. if the password file in use during the extraction does not match the
  6029. one belonging to the file system(s) being extracted. This occurs,
  6030. for example, if you are restoring your files after a major crash and
  6031. had booted from an emergency floppy with no password file or put your
  6032. disk into another machine to do the restore.
  6033. The numeric ids are @emph{always} saved into @command{tar} archives.
  6034. The identifying names are added at create time when provided by the
  6035. system, unless @option{--old-archive} (@option{-o}) is used. Numeric ids could be
  6036. used when moving archives between a collection of machines using
  6037. a centralized management for attribution of numeric ids to users
  6038. and groups. This is often made through using the NIS capabilities.
  6039. When making a @command{tar} file for distribution to other sites, it
  6040. is sometimes cleaner to use a single owner for all files in the
  6041. distribution, and nicer to specify the write permission bits of the
  6042. files as stored in the archive independently of their actual value on
  6043. the file system. The way to prepare a clean distribution is usually
  6044. to have some Makefile rule creating a directory, copying all needed
  6045. files in that directory, then setting ownership and permissions as
  6046. wanted (there are a lot of possible schemes), and only then making a
  6047. @command{tar} archive out of this directory, before cleaning
  6048. everything out. Of course, we could add a lot of options to
  6049. @GNUTAR{} for fine tuning permissions and ownership.
  6050. This is not the good way, I think. @GNUTAR{} is
  6051. already crowded with options and moreover, the approach just explained
  6052. gives you a great deal of control already.
  6053. @opindex same-permissions, short description
  6054. @opindex preserve-permissions, short description
  6055. @item -p
  6056. @itemx --same-permissions
  6057. @itemx --preserve-permissions
  6058. Extract all protection information.
  6059. This option causes @command{tar} to set the modes (access permissions) of
  6060. extracted files exactly as recorded in the archive. If this option
  6061. is not used, the current @code{umask} setting limits the permissions
  6062. on extracted files. This option is by default enabled when
  6063. @command{tar} is executed by a superuser.
  6064. This option is meaningless with @option{--list} (@option{-t}).
  6065. @opindex preserve
  6066. @item --preserve
  6067. Same as both @option{--same-permissions} and @option{--same-order}.
  6068. The @option{--preserve} option has no equivalent short option name.
  6069. It is equivalent to @option{--same-permissions} plus @option{--same-order}.
  6070. @FIXME{I do not see the purpose of such an option. (Neither I. FP.)}
  6071. @end table
  6072. @node Standard
  6073. @section Basic Tar Format
  6074. @UNREVISED
  6075. While an archive may contain many files, the archive itself is a
  6076. single ordinary file. Like any other file, an archive file can be
  6077. written to a storage device such as a tape or disk, sent through a
  6078. pipe or over a network, saved on the active file system, or even
  6079. stored in another archive. An archive file is not easy to read or
  6080. manipulate without using the @command{tar} utility or Tar mode in
  6081. @acronym{GNU} Emacs.
  6082. Physically, an archive consists of a series of file entries terminated
  6083. by an end-of-archive entry, which consists of two 512 blocks of zero
  6084. bytes. A file
  6085. entry usually describes one of the files in the archive (an
  6086. @dfn{archive member}), and consists of a file header and the contents
  6087. of the file. File headers contain file names and statistics, checksum
  6088. information which @command{tar} uses to detect file corruption, and
  6089. information about file types.
  6090. Archives are permitted to have more than one member with the same
  6091. member name. One way this situation can occur is if more than one
  6092. version of a file has been stored in the archive. For information
  6093. about adding new versions of a file to an archive, see @ref{update}.
  6094. @FIXME-xref{To learn more about having more than one archive member with the
  6095. same name, see -backup node, when it's written.}
  6096. In addition to entries describing archive members, an archive may
  6097. contain entries which @command{tar} itself uses to store information.
  6098. @xref{label}, for an example of such an archive entry.
  6099. A @command{tar} archive file contains a series of blocks. Each block
  6100. contains @code{BLOCKSIZE} bytes. Although this format may be thought
  6101. of as being on magnetic tape, other media are often used.
  6102. Each file archived is represented by a header block which describes
  6103. the file, followed by zero or more blocks which give the contents
  6104. of the file. At the end of the archive file there are two 512-byte blocks
  6105. filled with binary zeros as an end-of-file marker. A reasonable system
  6106. should write such end-of-file marker at the end of an archive, but
  6107. must not assume that such a block exists when reading an archive. In
  6108. particular @GNUTAR{} always issues a warning if it does not encounter it.
  6109. The blocks may be @dfn{blocked} for physical I/O operations.
  6110. Each record of @var{n} blocks (where @var{n} is set by the
  6111. @option{--blocking-factor=@var{512-size}} (@option{-b @var{512-size}}) option to @command{tar}) is written with a single
  6112. @w{@samp{write ()}} operation. On magnetic tapes, the result of
  6113. such a write is a single record. When writing an archive,
  6114. the last record of blocks should be written at the full size, with
  6115. blocks after the zero block containing all zeros. When reading
  6116. an archive, a reasonable system should properly handle an archive
  6117. whose last record is shorter than the rest, or which contains garbage
  6118. records after a zero block.
  6119. The header block is defined in C as follows. In the @GNUTAR{}
  6120. distribution, this is part of file @file{src/tar.h}:
  6121. @smallexample
  6122. @include header.texi
  6123. @end smallexample
  6124. All characters in header blocks are represented by using 8-bit
  6125. characters in the local variant of ASCII. Each field within the
  6126. structure is contiguous; that is, there is no padding used within
  6127. the structure. Each character on the archive medium is stored
  6128. contiguously.
  6129. Bytes representing the contents of files (after the header block
  6130. of each file) are not translated in any way and are not constrained
  6131. to represent characters in any character set. The @command{tar} format
  6132. does not distinguish text files from binary files, and no translation
  6133. of file contents is performed.
  6134. The @code{name}, @code{linkname}, @code{magic}, @code{uname}, and
  6135. @code{gname} are null-terminated character strings. All other fields
  6136. are zero-filled octal numbers in ASCII. Each numeric field of width
  6137. @var{w} contains @var{w} minus 1 digits, and a null.
  6138. The @code{name} field is the file name of the file, with directory names
  6139. (if any) preceding the file name, separated by slashes.
  6140. @FIXME{how big a name before field overflows?}
  6141. The @code{mode} field provides nine bits specifying file permissions
  6142. and three bits to specify the Set UID, Set GID, and Save Text
  6143. (@dfn{sticky}) modes. Values for these bits are defined above.
  6144. When special permissions are required to create a file with a given
  6145. mode, and the user restoring files from the archive does not hold such
  6146. permissions, the mode bit(s) specifying those special permissions
  6147. are ignored. Modes which are not supported by the operating system
  6148. restoring files from the archive will be ignored. Unsupported modes
  6149. should be faked up when creating or updating an archive; e.g., the
  6150. group permission could be copied from the @emph{other} permission.
  6151. The @code{uid} and @code{gid} fields are the numeric user and group
  6152. ID of the file owners, respectively. If the operating system does
  6153. not support numeric user or group IDs, these fields should be ignored.
  6154. The @code{size} field is the size of the file in bytes; linked files
  6155. are archived with this field specified as zero. @FIXME-xref{Modifiers, in
  6156. particular the @option{--incremental} (@option{-G}) option.}
  6157. The @code{mtime} field is the data modification time of the file at
  6158. the time it was archived. It is the ASCII representation of the octal
  6159. value of the last time the file's contents were modified, represented
  6160. as an integer number of
  6161. seconds since January 1, 1970, 00:00 Coordinated Universal Time.
  6162. The @code{chksum} field is the ASCII representation of the octal value
  6163. of the simple sum of all bytes in the header block. Each 8-bit
  6164. byte in the header is added to an unsigned integer, initialized to
  6165. zero, the precision of which shall be no less than seventeen bits.
  6166. When calculating the checksum, the @code{chksum} field is treated as
  6167. if it were all blanks.
  6168. The @code{typeflag} field specifies the type of file archived. If a
  6169. particular implementation does not recognize or permit the specified
  6170. type, the file will be extracted as if it were a regular file. As this
  6171. action occurs, @command{tar} issues a warning to the standard error.
  6172. The @code{atime} and @code{ctime} fields are used in making incremental
  6173. backups; they store, respectively, the particular file's access and
  6174. status change times.
  6175. The @code{offset} is used by the @option{--multi-volume} (@option{-M}) option, when
  6176. making a multi-volume archive. The offset is number of bytes into
  6177. the file that we need to restart at to continue the file on the next
  6178. tape, i.e., where we store the location that a continued file is
  6179. continued at.
  6180. The following fields were added to deal with sparse files. A file
  6181. is @dfn{sparse} if it takes in unallocated blocks which end up being
  6182. represented as zeros, i.e., no useful data. A test to see if a file
  6183. is sparse is to look at the number blocks allocated for it versus the
  6184. number of characters in the file; if there are fewer blocks allocated
  6185. for the file than would normally be allocated for a file of that
  6186. size, then the file is sparse. This is the method @command{tar} uses to
  6187. detect a sparse file, and once such a file is detected, it is treated
  6188. differently from non-sparse files.
  6189. Sparse files are often @code{dbm} files, or other database-type files
  6190. which have data at some points and emptiness in the greater part of
  6191. the file. Such files can appear to be very large when an @samp{ls
  6192. -l} is done on them, when in truth, there may be a very small amount
  6193. of important data contained in the file. It is thus undesirable
  6194. to have @command{tar} think that it must back up this entire file, as
  6195. great quantities of room are wasted on empty blocks, which can lead
  6196. to running out of room on a tape far earlier than is necessary.
  6197. Thus, sparse files are dealt with so that these empty blocks are
  6198. not written to the tape. Instead, what is written to the tape is a
  6199. description, of sorts, of the sparse file: where the holes are, how
  6200. big the holes are, and how much data is found at the end of the hole.
  6201. This way, the file takes up potentially far less room on the tape,
  6202. and when the file is extracted later on, it will look exactly the way
  6203. it looked beforehand. The following is a description of the fields
  6204. used to handle a sparse file:
  6205. The @code{sp} is an array of @code{struct sparse}. Each @code{struct
  6206. sparse} contains two 12-character strings which represent an offset
  6207. into the file and a number of bytes to be written at that offset.
  6208. The offset is absolute, and not relative to the offset in preceding
  6209. array element.
  6210. The header can hold four of these @code{struct sparse} at the moment;
  6211. if more are needed, they are not stored in the header.
  6212. The @code{isextended} flag is set when an @code{extended_header}
  6213. is needed to deal with a file. Note that this means that this flag
  6214. can only be set when dealing with a sparse file, and it is only set
  6215. in the event that the description of the file will not fit in the
  6216. allotted room for sparse structures in the header. In other words,
  6217. an extended_header is needed.
  6218. The @code{extended_header} structure is used for sparse files which
  6219. need more sparse structures than can fit in the header. The header can
  6220. fit 4 such structures; if more are needed, the flag @code{isextended}
  6221. gets set and the next block is an @code{extended_header}.
  6222. Each @code{extended_header} structure contains an array of 21
  6223. sparse structures, along with a similar @code{isextended} flag
  6224. that the header had. There can be an indeterminate number of such
  6225. @code{extended_header}s to describe a sparse file.
  6226. @table @asis
  6227. @item @code{REGTYPE}
  6228. @itemx @code{AREGTYPE}
  6229. These flags represent a regular file. In order to be compatible
  6230. with older versions of @command{tar}, a @code{typeflag} value of
  6231. @code{AREGTYPE} should be silently recognized as a regular file.
  6232. New archives should be created using @code{REGTYPE}. Also, for
  6233. backward compatibility, @command{tar} treats a regular file whose name
  6234. ends with a slash as a directory.
  6235. @item @code{LNKTYPE}
  6236. This flag represents a file linked to another file, of any type,
  6237. previously archived. Such files are identified in Unix by each
  6238. file having the same device and inode number. The linked-to name is
  6239. specified in the @code{linkname} field with a trailing null.
  6240. @item @code{SYMTYPE}
  6241. This represents a symbolic link to another file. The linked-to name
  6242. is specified in the @code{linkname} field with a trailing null.
  6243. @item @code{CHRTYPE}
  6244. @itemx @code{BLKTYPE}
  6245. These represent character special files and block special files
  6246. respectively. In this case the @code{devmajor} and @code{devminor}
  6247. fields will contain the major and minor device numbers respectively.
  6248. Operating systems may map the device specifications to their own
  6249. local specification, or may ignore the entry.
  6250. @item @code{DIRTYPE}
  6251. This flag specifies a directory or sub-directory. The directory
  6252. name in the @code{name} field should end with a slash. On systems where
  6253. disk allocation is performed on a directory basis, the @code{size} field
  6254. will contain the maximum number of bytes (which may be rounded to
  6255. the nearest disk block allocation unit) which the directory may
  6256. hold. A @code{size} field of zero indicates no such limiting. Systems
  6257. which do not support limiting in this manner should ignore the
  6258. @code{size} field.
  6259. @item @code{FIFOTYPE}
  6260. This specifies a FIFO special file. Note that the archiving of a
  6261. FIFO file archives the existence of this file and not its contents.
  6262. @item @code{CONTTYPE}
  6263. This specifies a contiguous file, which is the same as a normal
  6264. file except that, in operating systems which support it, all its
  6265. space is allocated contiguously on the disk. Operating systems
  6266. which do not allow contiguous allocation should silently treat this
  6267. type as a normal file.
  6268. @item @code{A} @dots{} @code{Z}
  6269. These are reserved for custom implementations. Some of these are
  6270. used in the @acronym{GNU} modified format, as described below.
  6271. @end table
  6272. Other values are reserved for specification in future revisions of
  6273. the P1003 standard, and should not be used by any @command{tar} program.
  6274. The @code{magic} field indicates that this archive was output in
  6275. the P1003 archive format. If this field contains @code{TMAGIC},
  6276. the @code{uname} and @code{gname} fields will contain the ASCII
  6277. representation of the owner and group of the file respectively.
  6278. If found, the user and group IDs are used rather than the values in
  6279. the @code{uid} and @code{gid} fields.
  6280. For references, see ISO/IEC 9945-1:1990 or IEEE Std 1003.1-1990, pages
  6281. 169-173 (section 10.1) for @cite{Archive/Interchange File Format}; and
  6282. IEEE Std 1003.2-1992, pages 380-388 (section 4.48) and pages 936-940
  6283. (section E.4.48) for @cite{pax - Portable archive interchange}.
  6284. @node Extensions
  6285. @section @acronym{GNU} Extensions to the Archive Format
  6286. @UNREVISED
  6287. The @acronym{GNU} format uses additional file types to describe new types of
  6288. files in an archive. These are listed below.
  6289. @table @code
  6290. @item GNUTYPE_DUMPDIR
  6291. @itemx 'D'
  6292. This represents a directory and a list of files created by the
  6293. @option{--incremental} (@option{-G}) option. The @code{size} field gives the total
  6294. size of the associated list of files. Each file name is preceded by
  6295. either a @samp{Y} (the file should be in this archive) or an @samp{N}.
  6296. (The file is a directory, or is not stored in the archive.) Each file
  6297. name is terminated by a null. There is an additional null after the
  6298. last file name.
  6299. @item GNUTYPE_MULTIVOL
  6300. @itemx 'M'
  6301. This represents a file continued from another volume of a multi-volume
  6302. archive created with the @option{--multi-volume} (@option{-M}) option. The original
  6303. type of the file is not given here. The @code{size} field gives the
  6304. maximum size of this piece of the file (assuming the volume does
  6305. not end before the file is written out). The @code{offset} field
  6306. gives the offset from the beginning of the file where this part of
  6307. the file begins. Thus @code{size} plus @code{offset} should equal
  6308. the original size of the file.
  6309. @item GNUTYPE_SPARSE
  6310. @itemx 'S'
  6311. This flag indicates that we are dealing with a sparse file. Note
  6312. that archiving a sparse file requires special operations to find
  6313. holes in the file, which mark the positions of these holes, along
  6314. with the number of bytes of data to be found after the hole.
  6315. @item GNUTYPE_VOLHDR
  6316. @itemx 'V'
  6317. This file type is used to mark the volume header that was given with
  6318. the @option{--label=@var{archive-label}} (@option{-V @var{archive-label}}) option when the archive was created. The @code{name}
  6319. field contains the @code{name} given after the @option{--label=@var{archive-label}} (@option{-V @var{archive-label}}) option.
  6320. The @code{size} field is zero. Only the first file in each volume
  6321. of an archive should have this type.
  6322. @end table
  6323. You may have trouble reading a @acronym{GNU} format archive on a
  6324. non-@acronym{GNU} system if the options @option{--incremental} (@option{-G}),
  6325. @option{--multi-volume} (@option{-M}), @option{--sparse} (@option{-S}), or @option{--label=@var{archive-label}} (@option{-V @var{archive-label}}) were
  6326. used when writing the archive. In general, if @command{tar} does not
  6327. use the @acronym{GNU}-added fields of the header, other versions of
  6328. @command{tar} should be able to read the archive. Otherwise, the
  6329. @command{tar} program will give an error, the most likely one being a
  6330. checksum error.
  6331. @node cpio
  6332. @section Comparison of @command{tar} and @command{cpio}
  6333. @UNREVISED
  6334. @FIXME{Reorganize the following material}
  6335. The @command{cpio} archive formats, like @command{tar}, do have maximum
  6336. pathname lengths. The binary and old ASCII formats have a max path
  6337. length of 256, and the new ASCII and CRC ASCII formats have a max
  6338. path length of 1024. @acronym{GNU} @command{cpio} can read and write archives
  6339. with arbitrary pathname lengths, but other @command{cpio} implementations
  6340. may crash unexplainedly trying to read them.
  6341. @command{tar} handles symbolic links in the form in which it comes in BSD;
  6342. @command{cpio} doesn't handle symbolic links in the form in which it comes
  6343. in System V prior to SVR4, and some vendors may have added symlinks
  6344. to their system without enhancing @command{cpio} to know about them.
  6345. Others may have enhanced it in a way other than the way I did it
  6346. at Sun, and which was adopted by AT&T (and which is, I think, also
  6347. present in the @command{cpio} that Berkeley picked up from AT&T and put
  6348. into a later BSD release---I think I gave them my changes).
  6349. (SVR4 does some funny stuff with @command{tar}; basically, its @command{cpio}
  6350. can handle @command{tar} format input, and write it on output, and it
  6351. probably handles symbolic links. They may not have bothered doing
  6352. anything to enhance @command{tar} as a result.)
  6353. @command{cpio} handles special files; traditional @command{tar} doesn't.
  6354. @command{tar} comes with V7, System III, System V, and BSD source;
  6355. @command{cpio} comes only with System III, System V, and later BSD
  6356. (4.3-tahoe and later).
  6357. @command{tar}'s way of handling multiple hard links to a file can handle
  6358. file systems that support 32-bit inumbers (e.g., the BSD file system);
  6359. @command{cpio}s way requires you to play some games (in its "binary"
  6360. format, i-numbers are only 16 bits, and in its "portable ASCII" format,
  6361. they're 18 bits---it would have to play games with the "file system ID"
  6362. field of the header to make sure that the file system ID/i-number pairs
  6363. of different files were always different), and I don't know which
  6364. @command{cpio}s, if any, play those games. Those that don't might get
  6365. confused and think two files are the same file when they're not, and
  6366. make hard links between them.
  6367. @command{tar}s way of handling multiple hard links to a file places only
  6368. one copy of the link on the tape, but the name attached to that copy
  6369. is the @emph{only} one you can use to retrieve the file; @command{cpio}s
  6370. way puts one copy for every link, but you can retrieve it using any
  6371. of the names.
  6372. @quotation
  6373. What type of check sum (if any) is used, and how is this calculated.
  6374. @end quotation
  6375. See the attached manual pages for @command{tar} and @command{cpio} format.
  6376. @command{tar} uses a checksum which is the sum of all the bytes in the
  6377. @command{tar} header for a file; @command{cpio} uses no checksum.
  6378. @quotation
  6379. If anyone knows why @command{cpio} was made when @command{tar} was present
  6380. at the unix scene,
  6381. @end quotation
  6382. It wasn't. @command{cpio} first showed up in PWB/UNIX 1.0; no
  6383. generally-available version of UNIX had @command{tar} at the time. I don't
  6384. know whether any version that was generally available @emph{within AT&T}
  6385. had @command{tar}, or, if so, whether the people within AT&T who did
  6386. @command{cpio} knew about it.
  6387. On restore, if there is a corruption on a tape @command{tar} will stop at
  6388. that point, while @command{cpio} will skip over it and try to restore the
  6389. rest of the files.
  6390. The main difference is just in the command syntax and header format.
  6391. @command{tar} is a little more tape-oriented in that everything is blocked
  6392. to start on a record boundary.
  6393. @quotation
  6394. Is there any differences between the ability to recover crashed
  6395. archives between the two of them. (Is there any chance of recovering
  6396. crashed archives at all.)
  6397. @end quotation
  6398. Theoretically it should be easier under @command{tar} since the blocking
  6399. lets you find a header with some variation of @samp{dd skip=@var{nn}}.
  6400. However, modern @command{cpio}'s and variations have an option to just
  6401. search for the next file header after an error with a reasonable chance
  6402. of resyncing. However, lots of tape driver software won't allow you to
  6403. continue past a media error which should be the only reason for getting
  6404. out of sync unless a file changed sizes while you were writing the
  6405. archive.
  6406. @quotation
  6407. If anyone knows why @command{cpio} was made when @command{tar} was present
  6408. at the unix scene, please tell me about this too.
  6409. @end quotation
  6410. Probably because it is more media efficient (by not blocking everything
  6411. and using only the space needed for the headers where @command{tar}
  6412. always uses 512 bytes per file header) and it knows how to archive
  6413. special files.
  6414. You might want to look at the freely available alternatives. The
  6415. major ones are @command{afio}, @GNUTAR{}, and
  6416. @command{pax}, each of which have their own extensions with some
  6417. backwards compatibility.
  6418. Sparse files were @command{tar}red as sparse files (which you can
  6419. easily test, because the resulting archive gets smaller, and
  6420. @acronym{GNU} @command{cpio} can no longer read it).
  6421. @node Media
  6422. @chapter Tapes and Other Archive Media
  6423. @UNREVISED
  6424. A few special cases about tape handling warrant more detailed
  6425. description. These special cases are discussed below.
  6426. Many complexities surround the use of @command{tar} on tape drives. Since
  6427. the creation and manipulation of archives located on magnetic tape was
  6428. the original purpose of @command{tar}, it contains many features making
  6429. such manipulation easier.
  6430. Archives are usually written on dismountable media---tape cartridges,
  6431. mag tapes, or floppy disks.
  6432. The amount of data a tape or disk holds depends not only on its size,
  6433. but also on how it is formatted. A 2400 foot long reel of mag tape
  6434. holds 40 megabytes of data when formatted at 1600 bits per inch. The
  6435. physically smaller EXABYTE tape cartridge holds 2.3 gigabytes.
  6436. Magnetic media are re-usable---once the archive on a tape is no longer
  6437. needed, the archive can be erased and the tape or disk used over.
  6438. Media quality does deteriorate with use, however. Most tapes or disks
  6439. should be discarded when they begin to produce data errors. EXABYTE
  6440. tape cartridges should be discarded when they generate an @dfn{error
  6441. count} (number of non-usable bits) of more than 10k.
  6442. Magnetic media are written and erased using magnetic fields, and
  6443. should be protected from such fields to avoid damage to stored data.
  6444. Sticking a floppy disk to a filing cabinet using a magnet is probably
  6445. not a good idea.
  6446. @menu
  6447. * Device:: Device selection and switching
  6448. * Remote Tape Server::
  6449. * Common Problems and Solutions::
  6450. * Blocking:: Blocking
  6451. * Many:: Many archives on one tape
  6452. * Using Multiple Tapes:: Using Multiple Tapes
  6453. * label:: Including a Label in the Archive
  6454. * verify::
  6455. * Write Protection::
  6456. @end menu
  6457. @node Device
  6458. @section Device Selection and Switching
  6459. @UNREVISED
  6460. @table @option
  6461. @item -f [@var{hostname}:]@var{file}
  6462. @itemx --file=[@var{hostname}:]@var{file}
  6463. Use archive file or device @var{file} on @var{hostname}.
  6464. @end table
  6465. This option is used to specify the file name of the archive @command{tar}
  6466. works on.
  6467. If the file name is @samp{-}, @command{tar} reads the archive from standard
  6468. input (when listing or extracting), or writes it to standard output
  6469. (when creating). If the @samp{-} file name is given when updating an
  6470. archive, @command{tar} will read the original archive from its standard
  6471. input, and will write the entire new archive to its standard output.
  6472. If the file name contains a @samp{:}, it is interpreted as
  6473. @samp{hostname:file name}. If the @var{hostname} contains an @dfn{at}
  6474. sign (@samp{@@}), it is treated as @samp{user@@hostname:file name}. In
  6475. either case, @command{tar} will invoke the command @command{rsh} (or
  6476. @command{remsh}) to start up an @command{/usr/libexec/rmt} on the remote
  6477. machine. If you give an alternate login name, it will be given to the
  6478. @command{rsh}.
  6479. Naturally, the remote machine must have an executable
  6480. @command{/usr/libexec/rmt}. This program is free software from the
  6481. University of California, and a copy of the source code can be found
  6482. with the sources for @command{tar}; it's compiled and installed by default.
  6483. The exact path to this utility is determined when configuring the package.
  6484. It is @file{@var{prefix}/libexec/rmt}, where @var{prefix} stands for
  6485. your installation prefix. This location may also be overridden at
  6486. runtime by using @option{rmt-command=@var{command}} option (@xref{Option Summary,
  6487. ---rmt-command}, for detailed description of this option. @xref{Remote
  6488. Tape Server}, for the description of @command{rmt} command).
  6489. If this option is not given, but the environment variable @env{TAPE}
  6490. is set, its value is used; otherwise, old versions of @command{tar}
  6491. used a default archive name (which was picked when @command{tar} was
  6492. compiled). The default is normally set up to be the @dfn{first} tape
  6493. drive or other transportable I/O medium on the system.
  6494. Starting with version 1.11.5, @GNUTAR{} uses
  6495. standard input and standard output as the default device, and I will
  6496. not try anymore supporting automatic device detection at installation
  6497. time. This was failing really in too many cases, it was hopeless.
  6498. This is now completely left to the installer to override standard
  6499. input and standard output for default device, if this seems
  6500. preferable. Further, I think @emph{most} actual usages of
  6501. @command{tar} are done with pipes or disks, not really tapes,
  6502. cartridges or diskettes.
  6503. Some users think that using standard input and output is running
  6504. after trouble. This could lead to a nasty surprise on your screen if
  6505. you forget to specify an output file name---especially if you are going
  6506. through a network or terminal server capable of buffering large amounts
  6507. of output. We had so many bug reports in that area of configuring
  6508. default tapes automatically, and so many contradicting requests, that
  6509. we finally consider the problem to be portably intractable. We could
  6510. of course use something like @samp{/dev/tape} as a default, but this
  6511. is @emph{also} running after various kind of trouble, going from hung
  6512. processes to accidental destruction of real tapes. After having seen
  6513. all this mess, using standard input and output as a default really
  6514. sounds like the only clean choice left, and a very useful one too.
  6515. @GNUTAR{} reads and writes archive in records, I
  6516. suspect this is the main reason why block devices are preferred over
  6517. character devices. Most probably, block devices are more efficient
  6518. too. The installer could also check for @samp{DEFTAPE} in
  6519. @file{<sys/mtio.h>}.
  6520. @table @option
  6521. @opindex force-local, short description
  6522. @item --force-local
  6523. Archive file is local even if it contains a colon.
  6524. @opindex rsh-command
  6525. @item --rsh-command=@var{command}
  6526. Use remote @var{command} instead of @command{rsh}. This option exists
  6527. so that people who use something other than the standard @command{rsh}
  6528. (e.g., a Kerberized @command{rsh}) can access a remote device.
  6529. When this command is not used, the shell command found when
  6530. the @command{tar} program was installed is used instead. This is
  6531. the first found of @file{/usr/ucb/rsh}, @file{/usr/bin/remsh},
  6532. @file{/usr/bin/rsh}, @file{/usr/bsd/rsh} or @file{/usr/bin/nsh}.
  6533. The installer may have overridden this by defining the environment
  6534. variable @env{RSH} @emph{at installation time}.
  6535. @item -[0-7][lmh]
  6536. Specify drive and density.
  6537. @opindex multi-volume, short description
  6538. @item -M
  6539. @itemx --multi-volume
  6540. Create/list/extract multi-volume archive.
  6541. This option causes @command{tar} to write a @dfn{multi-volume} archive---one
  6542. that may be larger than will fit on the medium used to hold it.
  6543. @xref{Multi-Volume Archives}.
  6544. @opindex tape-length, short description
  6545. @item -L @var{num}
  6546. @itemx --tape-length=@var{num}
  6547. Change tape after writing @var{num} x 1024 bytes.
  6548. This option might be useful when your tape drivers do not properly
  6549. detect end of physical tapes. By being slightly conservative on the
  6550. maximum tape length, you might avoid the problem entirely.
  6551. @opindex info-script, short description
  6552. @opindex new-volume-script, short description
  6553. @item -F @var{file}
  6554. @itemx --info-script=@var{file}
  6555. @itemx --new-volume-script=@var{file}
  6556. Execute @file{file} at end of each tape. This implies
  6557. @option{--multi-volume} (@option{-M}). @xref{info-script}, for a detailed
  6558. description of this option.
  6559. @end table
  6560. @node Remote Tape Server
  6561. @section The Remote Tape Server
  6562. @cindex remote tape drive
  6563. @pindex rmt
  6564. In order to access the tape drive on a remote machine, @command{tar}
  6565. uses the remote tape server written at the University of California at
  6566. Berkeley. The remote tape server must be installed as
  6567. @file{@var{prefix}/libexec/rmt} on any machine whose tape drive you
  6568. want to use. @command{tar} calls @command{rmt} by running an
  6569. @command{rsh} or @command{remsh} to the remote machine, optionally
  6570. using a different login name if one is supplied.
  6571. A copy of the source for the remote tape server is provided. It is
  6572. Copyright @copyright{} 1983 by the Regents of the University of
  6573. California, but can be freely distributed. It is compiled and
  6574. installed by default.
  6575. @cindex absolute file names
  6576. Unless you use the @option{--absolute-names} (@option{-P}) option,
  6577. @GNUTAR{} will not allow you to create an archive that contains
  6578. absolute file names (a file name beginning with @samp{/}.) If you try,
  6579. @command{tar} will automatically remove the leading @samp{/} from the
  6580. file names it stores in the archive. It will also type a warning
  6581. message telling you what it is doing.
  6582. When reading an archive that was created with a different
  6583. @command{tar} program, @GNUTAR{} automatically
  6584. extracts entries in the archive which have absolute file names as if
  6585. the file names were not absolute. This is an important feature. A
  6586. visitor here once gave a @command{tar} tape to an operator to restore;
  6587. the operator used Sun @command{tar} instead of @GNUTAR{},
  6588. and the result was that it replaced large portions of
  6589. our @file{/bin} and friends with versions from the tape; needless to
  6590. say, we were unhappy about having to recover the file system from
  6591. backup tapes.
  6592. For example, if the archive contained a file @file{/usr/bin/computoy},
  6593. @GNUTAR{} would extract the file to @file{usr/bin/computoy},
  6594. relative to the current directory. If you want to extract the files in
  6595. an archive to the same absolute names that they had when the archive
  6596. was created, you should do a @samp{cd /} before extracting the files
  6597. from the archive, or you should either use the @option{--absolute-names}
  6598. option, or use the command @samp{tar -C / @dots{}}.
  6599. @cindex Ultrix 3.1 and write failure
  6600. Some versions of Unix (Ultrix 3.1 is known to have this problem),
  6601. can claim that a short write near the end of a tape succeeded,
  6602. when it actually failed. This will result in the -M option not
  6603. working correctly. The best workaround at the moment is to use a
  6604. significantly larger blocking factor than the default 20.
  6605. In order to update an archive, @command{tar} must be able to backspace the
  6606. archive in order to reread or rewrite a record that was just read (or
  6607. written). This is currently possible only on two kinds of files: normal
  6608. disk files (or any other file that can be backspaced with @samp{lseek}),
  6609. and industry-standard 9-track magnetic tape (or any other kind of tape
  6610. that can be backspaced with the @code{MTIOCTOP} @code{ioctl}.
  6611. This means that the @option{--append}, @option{--concatenate}, and
  6612. @option{--delete} commands will not work on any other kind of file.
  6613. Some media simply cannot be backspaced, which means these commands and
  6614. options will never be able to work on them. These non-backspacing
  6615. media include pipes and cartridge tape drives.
  6616. Some other media can be backspaced, and @command{tar} will work on them
  6617. once @command{tar} is modified to do so.
  6618. Archives created with the @option{--multi-volume}, @option{--label}, and
  6619. @option{--incremental} (@option{-G}) options may not be readable by other version
  6620. of @command{tar}. In particular, restoring a file that was split over
  6621. a volume boundary will require some careful work with @command{dd}, if
  6622. it can be done at all. Other versions of @command{tar} may also create
  6623. an empty file whose name is that of the volume header. Some versions
  6624. of @command{tar} may create normal files instead of directories archived
  6625. with the @option{--incremental} (@option{-G}) option.
  6626. @node Common Problems and Solutions
  6627. @section Some Common Problems and their Solutions
  6628. @ifclear PUBLISH
  6629. @format
  6630. errors from system:
  6631. permission denied
  6632. no such file or directory
  6633. not owner
  6634. errors from @command{tar}:
  6635. directory checksum error
  6636. header format error
  6637. errors from media/system:
  6638. i/o error
  6639. device busy
  6640. @end format
  6641. @end ifclear
  6642. @node Blocking
  6643. @section Blocking
  6644. @UNREVISED
  6645. @dfn{Block} and @dfn{record} terminology is rather confused, and it
  6646. is also confusing to the expert reader. On the other hand, readers
  6647. who are new to the field have a fresh mind, and they may safely skip
  6648. the next two paragraphs, as the remainder of this manual uses those
  6649. two terms in a quite consistent way.
  6650. John Gilmore, the writer of the public domain @command{tar} from which
  6651. @GNUTAR{} was originally derived, wrote (June 1995):
  6652. @quotation
  6653. The nomenclature of tape drives comes from IBM, where I believe
  6654. they were invented for the IBM 650 or so. On IBM mainframes, what
  6655. is recorded on tape are tape blocks. The logical organization of
  6656. data is into records. There are various ways of putting records into
  6657. blocks, including @code{F} (fixed sized records), @code{V} (variable
  6658. sized records), @code{FB} (fixed blocked: fixed size records, @var{n}
  6659. to a block), @code{VB} (variable size records, @var{n} to a block),
  6660. @code{VSB} (variable spanned blocked: variable sized records that can
  6661. occupy more than one block), etc. The @code{JCL} @samp{DD RECFORM=}
  6662. parameter specified this to the operating system.
  6663. The Unix man page on @command{tar} was totally confused about this.
  6664. When I wrote @code{PD TAR}, I used the historically correct terminology
  6665. (@command{tar} writes data records, which are grouped into blocks).
  6666. It appears that the bogus terminology made it into @acronym{POSIX} (no surprise
  6667. here), and now Fran@,{c}ois has migrated that terminology back
  6668. into the source code too.
  6669. @end quotation
  6670. The term @dfn{physical block} means the basic transfer chunk from or
  6671. to a device, after which reading or writing may stop without anything
  6672. being lost. In this manual, the term @dfn{block} usually refers to
  6673. a disk physical block, @emph{assuming} that each disk block is 512
  6674. bytes in length. It is true that some disk devices have different
  6675. physical blocks, but @command{tar} ignore these differences in its own
  6676. format, which is meant to be portable, so a @command{tar} block is always
  6677. 512 bytes in length, and @dfn{block} always mean a @command{tar} block.
  6678. The term @dfn{logical block} often represents the basic chunk of
  6679. allocation of many disk blocks as a single entity, which the operating
  6680. system treats somewhat atomically; this concept is only barely used
  6681. in @GNUTAR{}.
  6682. The term @dfn{physical record} is another way to speak of a physical
  6683. block, those two terms are somewhat interchangeable. In this manual,
  6684. the term @dfn{record} usually refers to a tape physical block,
  6685. @emph{assuming} that the @command{tar} archive is kept on magnetic tape.
  6686. It is true that archives may be put on disk or used with pipes,
  6687. but nevertheless, @command{tar} tries to read and write the archive one
  6688. @dfn{record} at a time, whatever the medium in use. One record is made
  6689. up of an integral number of blocks, and this operation of putting many
  6690. disk blocks into a single tape block is called @dfn{reblocking}, or
  6691. more simply, @dfn{blocking}. The term @dfn{logical record} refers to
  6692. the logical organization of many characters into something meaningful
  6693. to the application. The term @dfn{unit record} describes a small set
  6694. of characters which are transmitted whole to or by the application,
  6695. and often refers to a line of text. Those two last terms are unrelated
  6696. to what we call a @dfn{record} in @GNUTAR{}.
  6697. When writing to tapes, @command{tar} writes the contents of the archive
  6698. in chunks known as @dfn{records}. To change the default blocking
  6699. factor, use the @option{--blocking-factor=@var{512-size}} (@option{-b
  6700. @var{512-size}}) option. Each record will then be composed of
  6701. @var{512-size} blocks. (Each @command{tar} block is 512 bytes.
  6702. @xref{Standard}.) Each file written to the archive uses at least one
  6703. full record. As a result, using a larger record size can result in
  6704. more wasted space for small files. On the other hand, a larger record
  6705. size can often be read and written much more efficiently.
  6706. Further complicating the problem is that some tape drives ignore the
  6707. blocking entirely. For these, a larger record size can still improve
  6708. performance (because the software layers above the tape drive still
  6709. honor the blocking), but not as dramatically as on tape drives that
  6710. honor blocking.
  6711. When reading an archive, @command{tar} can usually figure out the
  6712. record size on itself. When this is the case, and a non-standard
  6713. record size was used when the archive was created, @command{tar} will
  6714. print a message about a non-standard blocking factor, and then operate
  6715. normally. On some tape devices, however, @command{tar} cannot figure
  6716. out the record size itself. On most of those, you can specify a
  6717. blocking factor (with @option{--blocking-factor}) larger than the
  6718. actual blocking factor, and then use the @option{--read-full-records}
  6719. (@option{-B}) option. (If you specify a blocking factor with
  6720. @option{--blocking-factor} and don't use the
  6721. @option{--read-full-records} option, then @command{tar} will not
  6722. attempt to figure out the recording size itself.) On some devices,
  6723. you must always specify the record size exactly with
  6724. @option{--blocking-factor} when reading, because @command{tar} cannot
  6725. figure it out. In any case, use @option{--list} (@option{-t}) before
  6726. doing any extractions to see whether @command{tar} is reading the archive
  6727. correctly.
  6728. @command{tar} blocks are all fixed size (512 bytes), and its scheme for
  6729. putting them into records is to put a whole number of them (one or
  6730. more) into each record. @command{tar} records are all the same size;
  6731. at the end of the file there's a block containing all zeros, which
  6732. is how you tell that the remainder of the last record(s) are garbage.
  6733. In a standard @command{tar} file (no options), the block size is 512
  6734. and the record size is 10240, for a blocking factor of 20. What the
  6735. @option{--blocking-factor} option does is sets the blocking factor,
  6736. changing the record size while leaving the block size at 512 bytes.
  6737. 20 was fine for ancient 800 or 1600 bpi reel-to-reel tape drives;
  6738. most tape drives these days prefer much bigger records in order to
  6739. stream and not waste tape. When writing tapes for myself, some tend
  6740. to use a factor of the order of 2048, say, giving a record size of
  6741. around one megabyte.
  6742. If you use a blocking factor larger than 20, older @command{tar}
  6743. programs might not be able to read the archive, so we recommend this
  6744. as a limit to use in practice. @GNUTAR{}, however,
  6745. will support arbitrarily large record sizes, limited only by the
  6746. amount of virtual memory or the physical characteristics of the tape
  6747. device.
  6748. @menu
  6749. * Format Variations:: Format Variations
  6750. * Blocking Factor:: The Blocking Factor of an Archive
  6751. @end menu
  6752. @node Format Variations
  6753. @subsection Format Variations
  6754. @cindex Format Parameters
  6755. @cindex Format Options
  6756. @cindex Options, archive format specifying
  6757. @cindex Options, format specifying
  6758. @UNREVISED
  6759. Format parameters specify how an archive is written on the archive
  6760. media. The best choice of format parameters will vary depending on
  6761. the type and number of files being archived, and on the media used to
  6762. store the archive.
  6763. To specify format parameters when accessing or creating an archive,
  6764. you can use the options described in the following sections.
  6765. If you do not specify any format parameters, @command{tar} uses
  6766. default parameters. You cannot modify a compressed archive.
  6767. If you create an archive with the @option{--blocking-factor} option
  6768. specified (@pxref{Blocking Factor}), you must specify that
  6769. blocking-factor when operating on the archive. @xref{Formats}, for other
  6770. examples of format parameter considerations.
  6771. @node Blocking Factor
  6772. @subsection The Blocking Factor of an Archive
  6773. @cindex Blocking Factor
  6774. @cindex Record Size
  6775. @cindex Number of blocks per record
  6776. @cindex Number of bytes per record
  6777. @cindex Bytes per record
  6778. @cindex Blocks per record
  6779. @UNREVISED
  6780. @opindex blocking-factor
  6781. The data in an archive is grouped into blocks, which are 512 bytes.
  6782. Blocks are read and written in whole number multiples called
  6783. @dfn{records}. The number of blocks in a record (ie. the size of a
  6784. record in units of 512 bytes) is called the @dfn{blocking factor}.
  6785. The @option{--blocking-factor=@var{512-size}} (@option{-b
  6786. @var{512-size}}) option specifies the blocking factor of an archive.
  6787. The default blocking factor is typically 20 (i.e., 10240 bytes), but
  6788. can be specified at installation. To find out the blocking factor of
  6789. an existing archive, use @samp{tar --list --file=@var{archive-name}}.
  6790. This may not work on some devices.
  6791. Records are separated by gaps, which waste space on the archive media.
  6792. If you are archiving on magnetic tape, using a larger blocking factor
  6793. (and therefore larger records) provides faster throughput and allows you
  6794. to fit more data on a tape (because there are fewer gaps). If you are
  6795. archiving on cartridge, a very large blocking factor (say 126 or more)
  6796. greatly increases performance. A smaller blocking factor, on the other
  6797. hand, may be useful when archiving small files, to avoid archiving lots
  6798. of nulls as @command{tar} fills out the archive to the end of the record.
  6799. In general, the ideal record size depends on the size of the
  6800. inter-record gaps on the tape you are using, and the average size of the
  6801. files you are archiving. @xref{create}, for information on
  6802. writing archives.
  6803. @FIXME{Need example of using a cartridge with blocking factor=126 or more.}
  6804. Archives with blocking factors larger than 20 cannot be read
  6805. by very old versions of @command{tar}, or by some newer versions
  6806. of @command{tar} running on old machines with small address spaces.
  6807. With @GNUTAR{}, the blocking factor of an archive is limited
  6808. only by the maximum record size of the device containing the archive,
  6809. or by the amount of available virtual memory.
  6810. Also, on some systems, not using adequate blocking factors, as sometimes
  6811. imposed by the device drivers, may yield unexpected diagnostics. For
  6812. example, this has been reported:
  6813. @smallexample
  6814. Cannot write to /dev/dlt: Invalid argument
  6815. @end smallexample
  6816. @noindent
  6817. In such cases, it sometimes happen that the @command{tar} bundled by
  6818. the system is aware of block size idiosyncrasies, while @GNUTAR{}
  6819. requires an explicit specification for the block size,
  6820. which it cannot guess. This yields some people to consider
  6821. @GNUTAR{} is misbehaving, because by comparison,
  6822. @cite{the bundle @command{tar} works OK}. Adding @w{@kbd{-b 256}},
  6823. for example, might resolve the problem.
  6824. If you use a non-default blocking factor when you create an archive, you
  6825. must specify the same blocking factor when you modify that archive. Some
  6826. archive devices will also require you to specify the blocking factor when
  6827. reading that archive, however this is not typically the case. Usually, you
  6828. can use @option{--list} (@option{-t}) without specifying a blocking factor---@command{tar}
  6829. reports a non-default record size and then lists the archive members as
  6830. it would normally. To extract files from an archive with a non-standard
  6831. blocking factor (particularly if you're not sure what the blocking factor
  6832. is), you can usually use the @option{--read-full-records} (@option{-B}) option while
  6833. specifying a blocking factor larger then the blocking factor of the archive
  6834. (ie. @samp{tar --extract --read-full-records --blocking-factor=300}.
  6835. @xref{list}, for more information on the @option{--list} (@option{-t})
  6836. operation. @xref{Reading}, for a more detailed explanation of that option.
  6837. @table @option
  6838. @item --blocking-factor=@var{number}
  6839. @itemx -b @var{number}
  6840. Specifies the blocking factor of an archive. Can be used with any
  6841. operation, but is usually not necessary with @option{--list} (@option{-t}).
  6842. @end table
  6843. Device blocking
  6844. @table @option
  6845. @item -b @var{blocks}
  6846. @itemx --blocking-factor=@var{blocks}
  6847. Set record size to @math{@var{blocks} * 512} bytes.
  6848. This option is used to specify a @dfn{blocking factor} for the archive.
  6849. When reading or writing the archive, @command{tar}, will do reads and writes
  6850. of the archive in records of @math{@var{block}*512} bytes. This is true
  6851. even when the archive is compressed. Some devices requires that all
  6852. write operations be a multiple of a certain size, and so, @command{tar}
  6853. pads the archive out to the next record boundary.
  6854. The default blocking factor is set when @command{tar} is compiled, and is
  6855. typically 20. Blocking factors larger than 20 cannot be read by very
  6856. old versions of @command{tar}, or by some newer versions of @command{tar}
  6857. running on old machines with small address spaces.
  6858. With a magnetic tape, larger records give faster throughput and fit
  6859. more data on a tape (because there are fewer inter-record gaps).
  6860. If the archive is in a disk file or a pipe, you may want to specify
  6861. a smaller blocking factor, since a large one will result in a large
  6862. number of null bytes at the end of the archive.
  6863. When writing cartridge or other streaming tapes, a much larger
  6864. blocking factor (say 126 or more) will greatly increase performance.
  6865. However, you must specify the same blocking factor when reading or
  6866. updating the archive.
  6867. Apparently, Exabyte drives have a physical block size of 8K bytes.
  6868. If we choose our blocksize as a multiple of 8k bytes, then the problem
  6869. seems to disappear. Id est, we are using block size of 112 right
  6870. now, and we haven't had the problem since we switched@dots{}
  6871. With @GNUTAR{} the blocking factor is limited only
  6872. by the maximum record size of the device containing the archive, or by
  6873. the amount of available virtual memory.
  6874. However, deblocking or reblocking is virtually avoided in a special
  6875. case which often occurs in practice, but which requires all the
  6876. following conditions to be simultaneously true:
  6877. @itemize @bullet
  6878. @item
  6879. the archive is subject to a compression option,
  6880. @item
  6881. the archive is not handled through standard input or output, nor
  6882. redirected nor piped,
  6883. @item
  6884. the archive is directly handled to a local disk, instead of any special
  6885. device,
  6886. @item
  6887. @option{--blocking-factor} is not explicitly specified on the @command{tar}
  6888. invocation.
  6889. @end itemize
  6890. If the output goes directly to a local disk, and not through
  6891. stdout, then the last write is not extended to a full record size.
  6892. Otherwise, reblocking occurs. Here are a few other remarks on this
  6893. topic:
  6894. @itemize @bullet
  6895. @item
  6896. @command{gzip} will complain about trailing garbage if asked to
  6897. uncompress a compressed archive on tape, there is an option to turn
  6898. the message off, but it breaks the regularity of simply having to use
  6899. @samp{@var{prog} -d} for decompression. It would be nice if gzip was
  6900. silently ignoring any number of trailing zeros. I'll ask Jean-loup
  6901. Gailly, by sending a copy of this message to him.
  6902. @item
  6903. @command{compress} does not show this problem, but as Jean-loup pointed
  6904. out to Michael, @samp{compress -d} silently adds garbage after
  6905. the result of decompression, which tar ignores because it already
  6906. recognized its end-of-file indicator. So this bug may be safely
  6907. ignored.
  6908. @item
  6909. @samp{gzip -d -q} will be silent about the trailing zeros indeed,
  6910. but will still return an exit status of 2 which tar reports in turn.
  6911. @command{tar} might ignore the exit status returned, but I hate doing
  6912. that, as it weakens the protection @command{tar} offers users against
  6913. other possible problems at decompression time. If @command{gzip} was
  6914. silently skipping trailing zeros @emph{and} also avoiding setting the
  6915. exit status in this innocuous case, that would solve this situation.
  6916. @item
  6917. @command{tar} should become more solid at not stopping to read a pipe at
  6918. the first null block encountered. This inelegantly breaks the pipe.
  6919. @command{tar} should rather drain the pipe out before exiting itself.
  6920. @end itemize
  6921. @opindex ignore-zeros, short description
  6922. @item -i
  6923. @itemx --ignore-zeros
  6924. Ignore blocks of zeros in archive (means EOF).
  6925. The @option{--ignore-zeros} (@option{-i}) option causes @command{tar} to ignore blocks
  6926. of zeros in the archive. Normally a block of zeros indicates the
  6927. end of the archive, but when reading a damaged archive, or one which
  6928. was created by concatenating several archives together, this option
  6929. allows @command{tar} to read the entire archive. This option is not on
  6930. by default because many versions of @command{tar} write garbage after
  6931. the zeroed blocks.
  6932. Note that this option causes @command{tar} to read to the end of the
  6933. archive file, which may sometimes avoid problems when multiple files
  6934. are stored on a single physical tape.
  6935. @opindex read-full-records, short description
  6936. @item -B
  6937. @itemx --read-full-records
  6938. Reblock as we read (for reading 4.2BSD pipes).
  6939. If @option{--read-full-records} is used, @command{tar}
  6940. will not panic if an attempt to read a record from the archive does
  6941. not return a full record. Instead, @command{tar} will keep reading
  6942. until it has obtained a full
  6943. record.
  6944. This option is turned on by default when @command{tar} is reading
  6945. an archive from standard input, or from a remote machine. This is
  6946. because on BSD Unix systems, a read of a pipe will return however
  6947. much happens to be in the pipe, even if it is less than @command{tar}
  6948. requested. If this option was not used, @command{tar} would fail as
  6949. soon as it read an incomplete record from the pipe.
  6950. This option is also useful with the commands for updating an archive.
  6951. @end table
  6952. Tape blocking
  6953. @FIXME{Appropriate options should be moved here from elsewhere.}
  6954. @cindex blocking factor
  6955. @cindex tape blocking
  6956. When handling various tapes or cartridges, you have to take care of
  6957. selecting a proper blocking, that is, the number of disk blocks you
  6958. put together as a single tape block on the tape, without intervening
  6959. tape gaps. A @dfn{tape gap} is a small landing area on the tape
  6960. with no information on it, used for decelerating the tape to a
  6961. full stop, and for later regaining the reading or writing speed.
  6962. When the tape driver starts reading a record, the record has to
  6963. be read whole without stopping, as a tape gap is needed to stop the
  6964. tape motion without loosing information.
  6965. @cindex Exabyte blocking
  6966. @cindex DAT blocking
  6967. Using higher blocking (putting more disk blocks per tape block) will use
  6968. the tape more efficiently as there will be less tape gaps. But reading
  6969. such tapes may be more difficult for the system, as more memory will be
  6970. required to receive at once the whole record. Further, if there is a
  6971. reading error on a huge record, this is less likely that the system will
  6972. succeed in recovering the information. So, blocking should not be too
  6973. low, nor it should be too high. @command{tar} uses by default a blocking of
  6974. 20 for historical reasons, and it does not really matter when reading or
  6975. writing to disk. Current tape technology would easily accommodate higher
  6976. blockings. Sun recommends a blocking of 126 for Exabytes and 96 for DATs.
  6977. We were told that for some DLT drives, the blocking should be a multiple
  6978. of 4Kb, preferably 64Kb (@w{@kbd{-b 128}}) or 256 for decent performance.
  6979. Other manufacturers may use different recommendations for the same tapes.
  6980. This might also depends of the buffering techniques used inside modern
  6981. tape controllers. Some imposes a minimum blocking, or a maximum blocking.
  6982. Others request blocking to be some exponent of two.
  6983. So, there is no fixed rule for blocking. But blocking at read time
  6984. should ideally be the same as blocking used at write time. At one place
  6985. I know, with a wide variety of equipment, they found it best to use a
  6986. blocking of 32 to guarantee that their tapes are fully interchangeable.
  6987. I was also told that, for recycled tapes, prior erasure (by the same
  6988. drive unit that will be used to create the archives) sometimes lowers
  6989. the error rates observed at rewriting time.
  6990. I might also use @option{--number-blocks} instead of
  6991. @option{--block-number}, so @option{--block} will then expand to
  6992. @option{--blocking-factor} unambiguously.
  6993. @node Many
  6994. @section Many Archives on One Tape
  6995. @FIXME{Appropriate options should be moved here from elsewhere.}
  6996. @findex ntape @r{device}
  6997. Most tape devices have two entries in the @file{/dev} directory, or
  6998. entries that come in pairs, which differ only in the minor number for
  6999. this device. Let's take for example @file{/dev/tape}, which often
  7000. points to the only or usual tape device of a given system. There might
  7001. be a corresponding @file{/dev/nrtape} or @file{/dev/ntape}. The simpler
  7002. name is the @emph{rewinding} version of the device, while the name
  7003. having @samp{nr} in it is the @emph{no rewinding} version of the same
  7004. device.
  7005. A rewinding tape device will bring back the tape to its beginning point
  7006. automatically when this device is opened or closed. Since @command{tar}
  7007. opens the archive file before using it and closes it afterwards, this
  7008. means that a simple:
  7009. @smallexample
  7010. $ @kbd{tar cf /dev/tape @var{directory}}
  7011. @end smallexample
  7012. @noindent
  7013. will reposition the tape to its beginning both prior and after saving
  7014. @var{directory} contents to it, thus erasing prior tape contents and
  7015. making it so that any subsequent write operation will destroy what has
  7016. just been saved.
  7017. @cindex tape positioning
  7018. So, a rewinding device is normally meant to hold one and only one file.
  7019. If you want to put more than one @command{tar} archive on a given tape, you
  7020. will need to avoid using the rewinding version of the tape device. You
  7021. will also have to pay special attention to tape positioning. Errors in
  7022. positioning may overwrite the valuable data already on your tape. Many
  7023. people, burnt by past experiences, will only use rewinding devices and
  7024. limit themselves to one file per tape, precisely to avoid the risk of
  7025. such errors. Be fully aware that writing at the wrong position on a
  7026. tape loses all information past this point and most probably until the
  7027. end of the tape, and this destroyed information @emph{cannot} be
  7028. recovered.
  7029. To save @var{directory-1} as a first archive at the beginning of a
  7030. tape, and leave that tape ready for a second archive, you should use:
  7031. @smallexample
  7032. $ @kbd{mt -f /dev/nrtape rewind}
  7033. $ @kbd{tar cf /dev/nrtape @var{directory-1}}
  7034. @end smallexample
  7035. @cindex tape marks
  7036. @dfn{Tape marks} are special magnetic patterns written on the tape
  7037. media, which are later recognizable by the reading hardware. These
  7038. marks are used after each file, when there are many on a single tape.
  7039. An empty file (that is to say, two tape marks in a row) signal the
  7040. logical end of the tape, after which no file exist. Usually,
  7041. non-rewinding tape device drivers will react to the close request issued
  7042. by @command{tar} by first writing two tape marks after your archive, and by
  7043. backspacing over one of these. So, if you remove the tape at that time
  7044. from the tape drive, it is properly terminated. But if you write
  7045. another file at the current position, the second tape mark will be
  7046. erased by the new information, leaving only one tape mark between files.
  7047. So, you may now save @var{directory-2} as a second archive after the
  7048. first on the same tape by issuing the command:
  7049. @smallexample
  7050. $ @kbd{tar cf /dev/nrtape @var{directory-2}}
  7051. @end smallexample
  7052. @noindent
  7053. and so on for all the archives you want to put on the same tape.
  7054. Another usual case is that you do not write all the archives the same
  7055. day, and you need to remove and store the tape between two archive
  7056. sessions. In general, you must remember how many files are already
  7057. saved on your tape. Suppose your tape already has 16 files on it, and
  7058. that you are ready to write the 17th. You have to take care of skipping
  7059. the first 16 tape marks before saving @var{directory-17}, say, by using
  7060. these commands:
  7061. @smallexample
  7062. $ @kbd{mt -f /dev/nrtape rewind}
  7063. $ @kbd{mt -f /dev/nrtape fsf 16}
  7064. $ @kbd{tar cf /dev/nrtape @var{directory-17}}
  7065. @end smallexample
  7066. In all the previous examples, we put aside blocking considerations, but
  7067. you should do the proper things for that as well. @xref{Blocking}.
  7068. @menu
  7069. * Tape Positioning:: Tape Positions and Tape Marks
  7070. * mt:: The @command{mt} Utility
  7071. @end menu
  7072. @node Tape Positioning
  7073. @subsection Tape Positions and Tape Marks
  7074. @UNREVISED
  7075. Just as archives can store more than one file from the file system,
  7076. tapes can store more than one archive file. To keep track of where
  7077. archive files (or any other type of file stored on tape) begin and
  7078. end, tape archive devices write magnetic @dfn{tape marks} on the
  7079. archive media. Tape drives write one tape mark between files,
  7080. two at the end of all the file entries.
  7081. If you think of data as a series of records "rrrr"'s, and tape marks as
  7082. "*"'s, a tape might look like the following:
  7083. @smallexample
  7084. rrrr*rrrrrr*rrrrr*rr*rrrrr**-------------------------
  7085. @end smallexample
  7086. Tape devices read and write tapes using a read/write @dfn{tape
  7087. head}---a physical part of the device which can only access one
  7088. point on the tape at a time. When you use @command{tar} to read or
  7089. write archive data from a tape device, the device will begin reading
  7090. or writing from wherever on the tape the tape head happens to be,
  7091. regardless of which archive or what part of the archive the tape
  7092. head is on. Before writing an archive, you should make sure that no
  7093. data on the tape will be overwritten (unless it is no longer needed).
  7094. Before reading an archive, you should make sure the tape head is at
  7095. the beginning of the archive you want to read. You can do it manually
  7096. via @code{mt} utility (@pxref{mt}). The @code{restore} script does
  7097. that automatically (@pxref{Scripted Restoration}).
  7098. If you want to add new archive file entries to a tape, you should
  7099. advance the tape to the end of the existing file entries, backspace
  7100. over the last tape mark, and write the new archive file. If you were
  7101. to add two archives to the example above, the tape might look like the
  7102. following:
  7103. @smallexample
  7104. rrrr*rrrrrr*rrrrr*rr*rrrrr*rrr*rrrr**----------------
  7105. @end smallexample
  7106. @node mt
  7107. @subsection The @command{mt} Utility
  7108. @UNREVISED
  7109. @FIXME{Is it true that this only works on non-block devices?
  7110. should explain the difference, (fixed or variable).}
  7111. @xref{Blocking Factor}.
  7112. You can use the @command{mt} utility to advance or rewind a tape past a
  7113. specified number of archive files on the tape. This will allow you
  7114. to move to the beginning of an archive before extracting or reading
  7115. it, or to the end of all the archives before writing a new one.
  7116. @FIXME{Why isn't there an "advance 'til you find two tape marks
  7117. together"?}
  7118. The syntax of the @command{mt} command is:
  7119. @smallexample
  7120. @kbd{mt [-f @var{tapename}] @var{operation} [@var{number}]}
  7121. @end smallexample
  7122. where @var{tapename} is the name of the tape device, @var{number} is
  7123. the number of times an operation is performed (with a default of one),
  7124. and @var{operation} is one of the following:
  7125. @FIXME{is there any use for record operations?}
  7126. @table @option
  7127. @item eof
  7128. @itemx weof
  7129. Writes @var{number} tape marks at the current position on the tape.
  7130. @item fsf
  7131. Moves tape position forward @var{number} files.
  7132. @item bsf
  7133. Moves tape position back @var{number} files.
  7134. @item rewind
  7135. Rewinds the tape. (Ignores @var{number}).
  7136. @item offline
  7137. @itemx rewoff1
  7138. Rewinds the tape and takes the tape device off-line. (Ignores @var{number}).
  7139. @item status
  7140. Prints status information about the tape unit.
  7141. @end table
  7142. @FIXME{Is there a better way to frob the spacing on the list?}
  7143. If you don't specify a @var{tapename}, @command{mt} uses the environment
  7144. variable @env{TAPE}; if @env{TAPE} is not set, @command{mt} uses the device
  7145. @file{/dev/rmt12}.
  7146. @command{mt} returns a 0 exit status when the operation(s) were
  7147. successful, 1 if the command was unrecognized, and 2 if an operation
  7148. failed.
  7149. @node Using Multiple Tapes
  7150. @section Using Multiple Tapes
  7151. @UNREVISED
  7152. Often you might want to write a large archive, one larger than will fit
  7153. on the actual tape you are using. In such a case, you can run multiple
  7154. @command{tar} commands, but this can be inconvenient, particularly if you
  7155. are using options like @option{--exclude=@var{pattern}} or dumping entire file systems.
  7156. Therefore, @command{tar} supports multiple tapes automatically.
  7157. Use @option{--multi-volume} (@option{-M}) on the command line, and
  7158. then @command{tar} will, when it reaches the end of the tape, prompt
  7159. for another tape, and continue the archive. Each tape will have an
  7160. independent archive, and can be read without needing the other. (As
  7161. an exception to this, the file that @command{tar} was archiving when
  7162. it ran out of tape will usually be split between the two archives; in
  7163. this case you need to extract from the first archive, using
  7164. @option{--multi-volume}, and then put in the second tape when
  7165. prompted, so @command{tar} can restore both halves of the file.)
  7166. @GNUTAR{} multi-volume archives do not use a truly portable format.
  7167. You need @GNUTAR{} at both ends to process them properly.
  7168. When prompting for a new tape, @command{tar} accepts any of the following
  7169. responses:
  7170. @table @kbd
  7171. @item ?
  7172. Request @command{tar} to explain possible responses
  7173. @item q
  7174. Request @command{tar} to exit immediately.
  7175. @item n @var{file name}
  7176. Request @command{tar} to write the next volume on the file @var{file name}.
  7177. @item !
  7178. Request @command{tar} to run a subshell. This option can be disabled
  7179. by giving @option{--restrict} command line option to @command{tar}.
  7180. @item y
  7181. Request @command{tar} to begin writing the next volume.
  7182. @end table
  7183. (You should only type @samp{y} after you have changed the tape;
  7184. otherwise @command{tar} will write over the volume it just finished.)
  7185. @cindex End-of-archive info script
  7186. @cindex Info script
  7187. @anchor{info-script}
  7188. @opindex info-script
  7189. @opindex new-volume-script
  7190. If you want more elaborate behavior than this, give @command{tar} the
  7191. @option{--info-script=@var{script-name}}
  7192. (@option{--new-volume-script=@var{script-name}}, @option{-F
  7193. @var{script-name}}) option. The file @var{script-name} is expected to
  7194. be a program (or shell script) to be run instead of the normal
  7195. prompting procedure. It is executed without any command line
  7196. arguments. Additional data is passed to it via the following
  7197. environment variables:
  7198. @table @env
  7199. @vrindex TAR_VERSION, info script environment variable
  7200. @item TAR_VERSION
  7201. @GNUTAR{} version number.
  7202. @vrindex TAR_ARCHIVE, info script environment variable
  7203. @item TAR_ARCHIVE
  7204. The name of the archive @command{tar} is processing.
  7205. @vrindex TAR_VOLUME, info script environment variable
  7206. @item TAR_VOLUME
  7207. Ordinal number of the volume @command{tar} is about to start.
  7208. @vrindex TAR_SUBCOMMAND, info script environment variable
  7209. @item TAR_SUBCOMMAND
  7210. Short option describing the operation @command{tar} is executed.
  7211. @xref{Operations}, for a complete list of subcommand options.
  7212. @vrindex TAR_FORMAT, info script environment variable
  7213. @item TAR_FORMAT
  7214. Format of the archive being processed. @xref{Formats}, for a complete
  7215. list of archive format names.
  7216. @end table
  7217. The info script can instruct @command{tar} to use new archive name,
  7218. by writing in to file descriptor 3 (see below for an
  7219. example).
  7220. If the info script fails, @command{tar} exits; otherwise, it begins
  7221. writing the next volume.
  7222. The method @command{tar} uses to detect end of tape is not perfect, and
  7223. fails on some operating systems or on some devices. You can use the
  7224. @option{--tape-length=@var{size}} (@option{-L @var{size}}) option if
  7225. @command{tar} can't detect the end of the tape itself. This option
  7226. selects @option{--multi-volume} (@option{-M}) automatically. The
  7227. @var{size} argument should then be the usable size of the tape in
  7228. units of 1024 bytes. But for many devices, and floppy disks in
  7229. particular, this option is never required for real, as far as we know.
  7230. @cindex Volume number file
  7231. @cindex volno file
  7232. @anchor{volno-file}
  7233. @opindex volno-file
  7234. The volume number used by @command{tar} in its tape-change prompt
  7235. can be changed; if you give the
  7236. @option{--volno-file=@var{file-of-number}} option, then
  7237. @var{file-of-number} should be an unexisting file to be created, or
  7238. else, a file already containing a decimal number. That number will be
  7239. used as the volume number of the first volume written. When
  7240. @command{tar} is finished, it will rewrite the file with the
  7241. now-current volume number. (This does not change the volume number
  7242. written on a tape label, as per @ref{label}, it @emph{only} affects
  7243. the number used in the prompt.)
  7244. If you want @command{tar} to cycle through a series of files or tape
  7245. drives, there are three approaches to choose from. First of all, you
  7246. can give @command{tar} multiple @option{--file} options. In this case
  7247. the specified files will be used, in sequence, as the successive
  7248. volumes of the archive. Only when the first one in the sequence needs
  7249. to be used again will @command{tar} prompt for a tape change (or run
  7250. the info script). Secondly, you can use the @samp{n} response to the
  7251. tape-change prompt, and, finally, you can use an info script, that
  7252. writes new archive name to file descriptor. The following example
  7253. illustrates this approach:
  7254. @smallexample
  7255. @group
  7256. #! /bin/sh
  7257. echo Preparing volume $TAR_VOLUME of $TAR_ARCHIVE.
  7258. name=`expr $TAR_ARCHIVE : '\(.*\)-.*'`
  7259. case $TAR_SUBCOMMAND in
  7260. -c) ;;
  7261. -d|-x|-t) test -r $@{name:-$TAR_ARCHIVE@}-$TAR_VOLUME || exit 1
  7262. ;;
  7263. *) exit 1
  7264. esac
  7265. echo $@{name:-$TAR_ARCHIVE@}-$TAR_VOLUME >&3
  7266. @end group
  7267. @end smallexample
  7268. Each volume of a multi-volume archive is an independent @command{tar}
  7269. archive, complete in itself. For example, you can list or extract any
  7270. volume alone; just don't specify @option{--multi-volume}
  7271. (@option{-M}). However, if one file in the archive is split across
  7272. volumes, the only way to extract it successfully is with a
  7273. multi-volume extract command @option{--extract --multi-volume}
  7274. (@option{-xM}) starting on or before the volume where the file begins.
  7275. For example, let's presume someone has two tape drives on a system
  7276. named @file{/dev/tape0} and @file{/dev/tape1}. For having @GNUTAR{}
  7277. to switch to the second drive when it needs to write the
  7278. second tape, and then back to the first tape, etc., just do either of:
  7279. @smallexample
  7280. $ @kbd{tar --create --multi-volume --file=/dev/tape0 --file=/dev/tape1 @var{files}}
  7281. $ @kbd{tar cMff /dev/tape0 /dev/tape1 @var{files}}
  7282. @end smallexample
  7283. @menu
  7284. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  7285. * Tape Files:: Tape Files
  7286. * Tarcat:: Concatenate Volumes into a Single Archive
  7287. @end menu
  7288. @node Multi-Volume Archives
  7289. @subsection Archives Longer than One Tape or Disk
  7290. @cindex Multi-volume archives
  7291. @UNREVISED
  7292. @opindex multi-volume
  7293. To create an archive that is larger than will fit on a single unit of
  7294. the media, use the @option{--multi-volume} (@option{-M}) option in conjunction with
  7295. the @option{--create} option (@pxref{create}). A @dfn{multi-volume}
  7296. archive can be manipulated like any other archive (provided the
  7297. @option{--multi-volume} option is specified), but is stored on more
  7298. than one tape or disk.
  7299. When you specify @option{--multi-volume}, @command{tar} does not report an
  7300. error when it comes to the end of an archive volume (when reading), or
  7301. the end of the media (when writing). Instead, it prompts you to load
  7302. a new storage volume. If the archive is on a magnetic tape, you
  7303. should change tapes when you see the prompt; if the archive is on a
  7304. floppy disk, you should change disks; etc.
  7305. You can read each individual volume of a multi-volume archive as if it
  7306. were an archive by itself. For example, to list the contents of one
  7307. volume, use @option{--list}, without @option{--multi-volume} specified.
  7308. To extract an archive member from one volume (assuming it is described
  7309. that volume), use @option{--extract}, again without
  7310. @option{--multi-volume}.
  7311. If an archive member is split across volumes (ie. its entry begins on
  7312. one volume of the media and ends on another), you need to specify
  7313. @option{--multi-volume} to extract it successfully. In this case, you
  7314. should load the volume where the archive member starts, and use
  7315. @samp{tar --extract --multi-volume}---@command{tar} will prompt for later
  7316. volumes as it needs them. @xref{extracting archives}, for more
  7317. information about extracting archives.
  7318. @option{--info-script=@var{script-name}}
  7319. (@option{--new-volume-script=@var{script-name}}, @option{-F
  7320. @var{script-name}}) (@pxref{info-script}) is like
  7321. @option{--multi-volume} (@option{-M}), except that @command{tar} does
  7322. not prompt you directly to change media volumes when a volume is
  7323. full---instead, @command{tar} runs commands you have stored in
  7324. @var{script-name}. For example, this option can be used to eject
  7325. cassettes, or to broadcast messages such as @samp{Someone please come
  7326. change my tape} when performing unattended backups. When
  7327. @var{script-name} is done, @command{tar} will assume that the media
  7328. has been changed.
  7329. Multi-volume archives can be modified like any other archive. To add
  7330. files to a multi-volume archive, you need to only mount the last
  7331. volume of the archive media (and new volumes, if needed). For all
  7332. other operations, you need to use the entire archive.
  7333. If a multi-volume archive was labeled using
  7334. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  7335. (@pxref{label}) when it was created, @command{tar} will not
  7336. automatically label volumes which are added later. To label
  7337. subsequent volumes, specify @option{--label=@var{archive-label}} again
  7338. in conjunction with the @option{--append}, @option{--update} or
  7339. @option{--concatenate} operation.
  7340. @cindex Labeling multi-volume archives
  7341. @FIXME{example}
  7342. @FIXME{There should be a sample program here, including an exit
  7343. before end. Is the exit status even checked in tar? :-(}
  7344. @table @option
  7345. @item --multi-volume
  7346. @itemx -M
  7347. Creates a multi-volume archive, when used in conjunction with
  7348. @option{--create} (@option{-c}). To perform any other operation on a multi-volume
  7349. archive, specify @option{--multi-volume} in conjunction with that
  7350. operation.
  7351. @item --info-script=@var{program-file}
  7352. @itemx --new-volume-script=@var{program-file}
  7353. @itemx -F @var{program-file}
  7354. Creates a multi-volume archive via a script. Used in conjunction with
  7355. @option{--create} (@option{-c}). @xref{info-script}, dor a detailed discussion.
  7356. @end table
  7357. Beware that there is @emph{no} real standard about the proper way, for
  7358. a @command{tar} archive, to span volume boundaries. If you have a
  7359. multi-volume created by some vendor's @command{tar}, there is almost
  7360. no chance you could read all the volumes with @GNUTAR{}.
  7361. The converse is also true: you may not expect
  7362. multi-volume archives created by @GNUTAR{} to be
  7363. fully recovered by vendor's @command{tar}. Since there is little
  7364. chance that, in mixed system configurations, some vendor's
  7365. @command{tar} will work on another vendor's machine, and there is a
  7366. great chance that @GNUTAR{} will work on most of
  7367. them, your best bet is to install @GNUTAR{} on all
  7368. machines between which you know exchange of files is possible.
  7369. @node Tape Files
  7370. @subsection Tape Files
  7371. @UNREVISED
  7372. To give the archive a name which will be recorded in it, use the
  7373. @option{--label=@var{volume-label}} (@option{-V @var{volume-label}})
  7374. option. This will write a special block identifying
  7375. @var{volume-label} as the name of the archive to the front of the
  7376. archive which will be displayed when the archive is listed with
  7377. @option{--list}. If you are creating a multi-volume archive with
  7378. @option{--multi-volume} (@pxref{Using Multiple Tapes}), then the
  7379. volume label will have @samp{Volume @var{nnn}} appended to the name
  7380. you give, where @var{nnn} is the number of the volume of the archive.
  7381. (If you use the @option{--label=@var{volume-label}}) option when
  7382. reading an archive, it checks to make sure the label on the tape
  7383. matches the one you give. @xref{label}.
  7384. When @command{tar} writes an archive to tape, it creates a single
  7385. tape file. If multiple archives are written to the same tape, one
  7386. after the other, they each get written as separate tape files. When
  7387. extracting, it is necessary to position the tape at the right place
  7388. before running @command{tar}. To do this, use the @command{mt} command.
  7389. For more information on the @command{mt} command and on the organization
  7390. of tapes into a sequence of tape files, see @ref{mt}.
  7391. People seem to often do:
  7392. @smallexample
  7393. @kbd{--label="@var{some-prefix} `date +@var{some-format}`"}
  7394. @end smallexample
  7395. or such, for pushing a common date in all volumes or an archive set.
  7396. @node Tarcat
  7397. @subsection Concatenate Volumes into a Single Archive
  7398. @pindex tarcat
  7399. Sometimes it is necessary to convert existing @GNUTAR{} multi-volume
  7400. archive to a single @command{tar} archive. Simply concatenating all
  7401. volumes into one will not work, since each volume carries an additional
  7402. information at the beginning. @GNUTAR{} is shipped with the shell
  7403. script @command{tarcat} designed for this purpose.
  7404. The script takes a list of files comprising a multi-volume archive
  7405. and creates the resulting archive at the standard output. For example:
  7406. @smallexample
  7407. @kbd{tarcat vol.1 vol.2 vol.3 | tar tf -}
  7408. @end smallexample
  7409. The script implements a simple heuristics to determine the format of
  7410. the first volume file and to decide how to process the rest of the
  7411. files. However, it makes no attempt to verify whether the files are
  7412. given in order or even if they are valid @command{tar} archives.
  7413. It uses @command{dd} and does not filter its standard error, so you
  7414. will usually see lots of spurious messages.
  7415. @FIXME{The script is not installed. Should we install it?}
  7416. @node label
  7417. @section Including a Label in the Archive
  7418. @cindex Labeling an archive
  7419. @cindex Labels on the archive media
  7420. @UNREVISED
  7421. @opindex label
  7422. To avoid problems caused by misplaced paper labels on the archive
  7423. media, you can include a @dfn{label} entry---an archive member which
  7424. contains the name of the archive---in the archive itself. Use the
  7425. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  7426. option in conjunction with the @option{--create} operation to include
  7427. a label entry in the archive as it is being created.
  7428. @table @option
  7429. @item --label=@var{archive-label}
  7430. @itemx -V @var{archive-label}
  7431. Includes an @dfn{archive-label} at the beginning of the archive when
  7432. the archive is being created, when used in conjunction with the
  7433. @option{--create} operation. Checks to make sure the archive label
  7434. matches the one specified (when used in conjunction with any other
  7435. operation.
  7436. @end table
  7437. If you create an archive using both
  7438. @option{--label=@var{archive-label}} (@option{-V @var{archive-label}})
  7439. and @option{--multi-volume} (@option{-M}), each volume of the archive
  7440. will have an archive label of the form @samp{@var{archive-label}
  7441. Volume @var{n}}, where @var{n} is 1 for the first volume, 2 for the
  7442. next, and so on. @xref{Using Multiple Tapes}, for information on
  7443. creating multiple volume archives.
  7444. @cindex Volume label, listing
  7445. @cindex Listing volume label
  7446. The volume label will be displayed by @option{--list} along with
  7447. the file contents. If verbose display is requested, it will also be
  7448. explicitely marked as in the example below:
  7449. @smallexample
  7450. @group
  7451. $ @kbd{tar --verbose --list --file=iamanarchive}
  7452. V--------- 0 0 0 1992-03-07 12:01 iamalabel--Volume Header--
  7453. -rw-r--r-- ringo user 40 1990-05-21 13:30 iamafilename
  7454. @end group
  7455. @end smallexample
  7456. @opindex test-label
  7457. @anchor{--test-label option}
  7458. However, @option{--list} option will cause listing entire
  7459. contents of the archive, which may be undesirable (for example, if the
  7460. archive is stored on a tape). You can request checking only the volume
  7461. by specifying @option{--test-label} option. This option reads only the
  7462. first block of an archive, so it can be used with slow storage
  7463. devices. For example:
  7464. @smallexample
  7465. @group
  7466. $ @kbd{tar --test-label --file=iamanarchive}
  7467. iamalabel
  7468. @end group
  7469. @end smallexample
  7470. If @option{--test-label} is used with a single command line
  7471. argument, @command{tar} compares the volume label with the
  7472. argument. It exits with code 0 if the two strings match, and with code
  7473. 2 otherwise. In this case no output is displayed. For example:
  7474. @smallexample
  7475. @group
  7476. $ @kbd{tar --test-label --file=iamanarchive 'iamalable'}
  7477. @result{} 0
  7478. $ @kbd{tar --test-label --file=iamanarchive 'iamalable' alabel}
  7479. @result{} 1
  7480. @end group
  7481. @end smallexample
  7482. If you request any operation, other than @option{--create}, along
  7483. with using @option{--label} option, @command{tar} will first check if
  7484. the archive label matches the one specified and will refuse to proceed
  7485. if it does not. Use this as a safety precaution to avoid accidentally
  7486. overwriting existing archives. For example, if you wish to add files
  7487. to @file{archive}, presumably labelled with string @samp{My volume},
  7488. you will get:
  7489. @smallexample
  7490. @group
  7491. $ @kbd{tar -rf archive --label 'My volume' .}
  7492. tar: Archive not labeled to match `My volume'
  7493. @end group
  7494. @end smallexample
  7495. @noindent
  7496. in case its label does not match. This will work even if
  7497. @file{archive} is not labelled at all.
  7498. Similarly, @command{tar} will refuse to list or extract the
  7499. archive if its label doesn't match the @var{archive-label}
  7500. specified. In those cases, @var{archive-label} argument is interpreted
  7501. as a globbing-style pattern which must match the actual magnetic
  7502. volume label. @xref{exclude}, for a precise description of how match
  7503. is attempted@footnote{Previous versions of @command{tar} used full
  7504. regular expression matching, or before that, only exact string
  7505. matching, instead of wildcard matchers. We decided for the sake of
  7506. simplicity to use a uniform matching device through
  7507. @command{tar}.}. If the switch @option{--multi-volume} (@option{-M}) is being used,
  7508. the volume label matcher will also suffix @var{archive-label} by
  7509. @w{@samp{ Volume [1-9]*}} if the initial match fails, before giving
  7510. up. Since the volume numbering is automatically added in labels at
  7511. creation time, it sounded logical to equally help the user taking care
  7512. of it when the archive is being read.
  7513. The @option{--label} was once called @option{--volume}, but is not
  7514. available under that name anymore.
  7515. You can also use @option{--label} to get a common information on
  7516. all tapes of a series. For having this information different in each
  7517. series created through a single script used on a regular basis, just
  7518. manage to get some date string as part of the label. For example:
  7519. @smallexample
  7520. @group
  7521. $ @kbd{tar cfMV /dev/tape "Daily backup for `date +%Y-%m-%d`"}
  7522. $ @kbd{tar --create --file=/dev/tape --multi-volume \
  7523. --volume="Daily backup for `date +%Y-%m-%d`"}
  7524. @end group
  7525. @end smallexample
  7526. Also note that each label has its own date and time, which corresponds
  7527. to when @GNUTAR{} initially attempted to write it,
  7528. often soon after the operator launches @command{tar} or types the
  7529. carriage return telling that the next tape is ready. Comparing date
  7530. labels does give an idea of tape throughput only if the delays for
  7531. rewinding tapes and the operator switching them were negligible, which
  7532. is usually not the case.
  7533. @node verify
  7534. @section Verifying Data as It is Stored
  7535. @cindex Verifying a write operation
  7536. @cindex Double-checking a write operation
  7537. @table @option
  7538. @item -W
  7539. @itemx --verify
  7540. @opindex verify, short description
  7541. Attempt to verify the archive after writing.
  7542. @end table
  7543. This option causes @command{tar} to verify the archive after writing it.
  7544. Each volume is checked after it is written, and any discrepancies
  7545. are recorded on the standard error output.
  7546. Verification requires that the archive be on a back-space-able medium.
  7547. This means pipes, some cartridge tape drives, and some other devices
  7548. cannot be verified.
  7549. You can insure the accuracy of an archive by comparing files in the
  7550. system with archive members. @command{tar} can compare an archive to the
  7551. file system as the archive is being written, to verify a write
  7552. operation, or can compare a previously written archive, to insure that
  7553. it is up to date.
  7554. @opindex verify, using with @option{--create}
  7555. @opindex create, using with @option{--verify}
  7556. To check for discrepancies in an archive immediately after it is
  7557. written, use the @option{--verify} (@option{-W}) option in conjunction with
  7558. the @option{--create} operation. When this option is
  7559. specified, @command{tar} checks archive members against their counterparts
  7560. in the file system, and reports discrepancies on the standard error.
  7561. To verify an archive, you must be able to read it from before the end
  7562. of the last written entry. This option is useful for detecting data
  7563. errors on some tapes. Archives written to pipes, some cartridge tape
  7564. drives, and some other devices cannot be verified.
  7565. One can explicitly compare an already made archive with the file
  7566. system by using the @option{--compare} (@option{--diff}, @option{-d})
  7567. option, instead of using the more automatic @option{--verify} option.
  7568. @xref{compare}.
  7569. Note that these two options have a slightly different intent. The
  7570. @option{--compare} option checks how identical are the logical contents of some
  7571. archive with what is on your disks, while the @option{--verify} option is
  7572. really for checking if the physical contents agree and if the recording
  7573. media itself is of dependable quality. So, for the @option{--verify}
  7574. operation, @command{tar} tries to defeat all in-memory cache pertaining to
  7575. the archive, while it lets the speed optimization undisturbed for the
  7576. @option{--compare} option. If you nevertheless use @option{--compare} for
  7577. media verification, you may have to defeat the in-memory cache yourself,
  7578. maybe by opening and reclosing the door latch of your recording unit,
  7579. forcing some doubt in your operating system about the fact this is really
  7580. the same volume as the one just written or read.
  7581. The @option{--verify} option would not be necessary if drivers were indeed
  7582. able to detect dependably all write failures. This sometimes require many
  7583. magnetic heads, some able to read after the writes occurred. One would
  7584. not say that drivers unable to detect all cases are necessarily flawed,
  7585. as long as programming is concerned.
  7586. The @option{--verify} (@option{-W}) option will not work in
  7587. conjunction with the @option{--multi-volume} (@option{-M}) option or
  7588. the @option{--append} (@option{-r}), @option{--update} (@option{-u})
  7589. and @option{--delete} operations. @xref{Operations}, for more
  7590. information on these operations.
  7591. Also, since @command{tar} normally strips leading @samp{/} from file
  7592. names (@pxref{absolute}), a command like @samp{tar --verify -cf
  7593. /tmp/foo.tar /etc} will work as desired only if the working directory is
  7594. @file{/}, as @command{tar} uses the archive's relative member names
  7595. (e.g., @file{etc/motd}) when verifying the archive.
  7596. @node Write Protection
  7597. @section Write Protection
  7598. Almost all tapes and diskettes, and in a few rare cases, even disks can
  7599. be @dfn{write protected}, to protect data on them from being changed.
  7600. Once an archive is written, you should write protect the media to prevent
  7601. the archive from being accidentally overwritten or deleted. (This will
  7602. protect the archive from being changed with a tape or floppy drive---it
  7603. will not protect it from magnet fields or other physical hazards).
  7604. The write protection device itself is usually an integral part of the
  7605. physical media, and can be a two position (write enabled/write
  7606. disabled) switch, a notch which can be popped out or covered, a ring
  7607. which can be removed from the center of a tape reel, or some other
  7608. changeable feature.
  7609. @node Free Software Needs Free Documentation
  7610. @appendix Free Software Needs Free Documentation
  7611. @include freemanuals.texi
  7612. @node Genfile
  7613. @appendix Genfile
  7614. @include genfile.texi
  7615. @node Snapshot Files
  7616. @appendix Format of the Incremental Snapshot Files
  7617. @include snapshot.texi
  7618. @node Copying This Manual
  7619. @appendix Copying This Manual
  7620. @menu
  7621. * GNU Free Documentation License:: License for copying this manual
  7622. @end menu
  7623. @include fdl.texi
  7624. @node Index of Command Line Options
  7625. @appendix Index of Command Line Options
  7626. This appendix contains an index of all @GNUTAR{} long command line
  7627. options. The options are listed without the preceeding double-dash.
  7628. @FIXME{@itemize
  7629. @item Make sure @emph{all} options are indexed.
  7630. @item Provide an index of short options
  7631. @end itemize}
  7632. @printindex op
  7633. @node Index
  7634. @appendix Index
  7635. @printindex cp
  7636. @summarycontents
  7637. @contents
  7638. @bye
  7639. @c Local variables:
  7640. @c texinfo-column-for-description: 32
  7641. @c End: