tar.texi 337 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542
  1. \input texinfo @c -*-texinfo-*-
  2. @comment %**start of header
  3. @setfilename tar.info
  4. @include version.texi
  5. @settitle GNU tar @value{VERSION}
  6. @setchapternewpage odd
  7. @finalout
  8. @smallbook
  9. @c %**end of header
  10. @c ======================================================================
  11. @c This document has three levels of rendition: PUBLISH, DISTRIB or PROOF,
  12. @c as decided by @set symbols. The PUBLISH rendition does not show
  13. @c notes or marks asking for revision. Most users will prefer having more
  14. @c information, even if this information is not fully revised for adequacy,
  15. @c so DISTRIB is the default for tar distributions. The PROOF rendition
  16. @c show all marks to the point of ugliness, but is nevertheless useful to
  17. @c those working on the manual itself.
  18. @c ======================================================================
  19. @ifclear PUBLISH
  20. @ifclear DISTRIB
  21. @ifclear PROOF
  22. @set DISTRIB
  23. @end ifclear
  24. @end ifclear
  25. @end ifclear
  26. @ifset PUBLISH
  27. @set RENDITION The book, version
  28. @end ifset
  29. @ifset DISTRIB
  30. @set RENDITION FTP release, version
  31. @end ifset
  32. @ifset PROOF
  33. @set RENDITION Proof reading version
  34. @end ifset
  35. @c ---------------------------------------------------------------------
  36. @c The @FIXME's, @UNREVISED and @c comments are part Fran@,{c}ois's work
  37. @c plan. These annotations are somewhat precious to him; he asks that I
  38. @c do not alter them inconsiderately. Much work is needed for GNU tar
  39. @c internals (the sources, the programs themselves). Revising the
  40. @c adequacy of the manual while revising the sources, and cleaning them
  41. @c both at the same time, seems to him like a good way to proceed.
  42. @c ---------------------------------------------------------------------
  43. @c Output marks for nodes needing revision, but not in PUBLISH rendition.
  44. @macro UNREVISED
  45. @ifclear PUBLISH
  46. @quotation
  47. @emph{(This message will disappear, once this node revised.)}
  48. @end quotation
  49. @end ifclear
  50. @end macro
  51. @c Output various FIXME information only in PROOF rendition.
  52. @macro FIXME{string}
  53. @allow-recursion
  54. @quote-arg
  55. @ifset PROOF
  56. @strong{<FIXME>} \string\ @strong{</>}
  57. @end ifset
  58. @end macro
  59. @macro FIXME-ref{string}
  60. @quote-arg
  61. @ifset PROOF
  62. @strong{<REF>} \string\ @strong{</>}
  63. @end ifset
  64. @end macro
  65. @macro FIXME-pxref{string}
  66. @quote-arg
  67. @ifset PROOF
  68. @strong{<PXREF>} \string\ @strong{</>}
  69. @end ifset
  70. @end macro
  71. @macro FIXME-xref{string}
  72. @quote-arg
  73. @ifset PROOF
  74. @strong{<XREF>} \string\ @strong{</>}
  75. @end ifset
  76. @end macro
  77. @c @macro option{entry}
  78. @c @quote-arg
  79. @c @opindex{--\entry\}
  80. @c @value{\entry\}
  81. @c @end macro
  82. @set op-absolute-names @kbd{--absolute-names} (@kbd{-P})
  83. @set ref-absolute-names @ref{absolute}
  84. @set xref-absolute-names @xref{absolute}
  85. @set pxref-absolute-names @pxref{absolute}
  86. @set op-after-date @kbd{--after-date=@var{date}} (@kbd{--newer=@var{date}}, @kbd{-N @var{date}})
  87. @set ref-after-date @ref{after}
  88. @set xref-after-date @xref{after}
  89. @set pxref-after-date @pxref{after}
  90. @set op-append @kbd{--append} (@kbd{-r})
  91. @set ref-append @ref{add}
  92. @set xref-append @xref{add}
  93. @set pxref-append @pxref{add}
  94. @set op-atime-preserve @kbd{--atime-preserve}
  95. @set ref-atime-preserve @ref{Attributes}
  96. @set xref-atime-preserve @xref{Attributes}
  97. @set pxref-atime-preserve @pxref{Attributes}
  98. @set op-backup @kbd{--backup}
  99. @set ref-backup @ref{Backup options}
  100. @set xref-backup @xref{Backup options}
  101. @set pxref-backup @pxref{Backup options}
  102. @set op-block-number @kbd{--block-number} (@kbd{-R})
  103. @set ref-block-number @ref{verbose}
  104. @set xref-block-number @xref{verbose}
  105. @set pxref-block-number @pxref{verbose}
  106. @set op-blocking-factor @kbd{--blocking-factor=@var{512-size}} (@kbd{-b @var{512-size}})
  107. @set ref-blocking-factor @ref{Blocking Factor}
  108. @set xref-blocking-factor @xref{Blocking Factor}
  109. @set pxref-blocking-factor @pxref{Blocking Factor}
  110. @set op-bzip2 @kbd{--bzip2} (@kbd{-j})
  111. @set ref-bzip2 @ref{gzip}
  112. @set xref-bzip2 @xref{gzip}
  113. @set pxref-bzip2 @pxref{gzip}
  114. @set op-checkpoint @kbd{--checkpoint}
  115. @set ref-checkpoint @ref{verbose}
  116. @set xref-checkpoint @xref{verbose}
  117. @set pxref-checkpoint @pxref{verbose}
  118. @set op-check-links @kbd{--check-links}
  119. @set op-compare @kbd{--compare} (@kbd{--diff}, @kbd{-d})
  120. @set ref-compare @ref{compare}
  121. @set xref-compare @xref{compare}
  122. @set pxref-compare @pxref{compare}
  123. @set op-compress @kbd{--compress} (@kbd{--uncompress}, @kbd{-Z})
  124. @set ref-compress @ref{gzip}
  125. @set xref-compress @xref{gzip}
  126. @set pxref-compress @pxref{gzip}
  127. @set op-concatenate @kbd{--concatenate} (@kbd{--catenate}, @kbd{-A})
  128. @set ref-concatenate @ref{concatenate}
  129. @set xref-concatenate @xref{concatenate}
  130. @set pxref-concatenate @pxref{concatenate}
  131. @set op-create @kbd{--create} (@kbd{-c})
  132. @set ref-create @ref{create}
  133. @set xref-create @xref{create}
  134. @set pxref-create @pxref{create}
  135. @set op-delete @kbd{--delete}
  136. @set ref-delete @ref{delete}
  137. @set xref-delete @xref{delete}
  138. @set pxref-delete @pxref{delete}
  139. @set op-dereference @kbd{--dereference} (@kbd{-h})
  140. @set ref-dereference @ref{dereference}
  141. @set xref-dereference @xref{dereference}
  142. @set pxref-dereference @pxref{dereference}
  143. @set op-directory @kbd{--directory=@var{directory}} (@kbd{-C @var{directory}})
  144. @set ref-directory @ref{directory}
  145. @set xref-directory @xref{directory}
  146. @set pxref-directory @pxref{directory}
  147. @set op-exclude @kbd{--exclude=@var{pattern}}
  148. @set ref-exclude @ref{exclude}
  149. @set xref-exclude @xref{exclude}
  150. @set pxref-exclude @pxref{exclude}
  151. @set op-exclude-from @kbd{--exclude-from=@var{file-of-patterns}} (@kbd{-X @var{file-of-patterns}})
  152. @set ref-exclude-from @ref{exclude}
  153. @set xref-exclude-from @xref{exclude}
  154. @set pxref-exclude-from @pxref{exclude}
  155. @set op-extract @kbd{--extract} (@kbd{--get}, @kbd{-x})
  156. @set ref-extract @ref{extract}
  157. @set xref-extract @xref{extract}
  158. @set pxref-extract @pxref{extract}
  159. @set op-file @kbd{--file=@var{archive-name}} (@kbd{-f @var{archive-name}})
  160. @set ref-file @ref{file}
  161. @set xref-file @xref{file}
  162. @set pxref-file @pxref{file}
  163. @set op-files-from @kbd{--files-from=@var{file-of-names}} (@kbd{-T @var{file-of-names}})
  164. @set ref-files-from @ref{files}
  165. @set xref-files-from @xref{files}
  166. @set pxref-files-from @pxref{files}
  167. @set op-force-local @kbd{--force-local}
  168. @set ref-force-local @ref{file}
  169. @set xref-force-local @xref{file}
  170. @set pxref-force-local @pxref{file}
  171. @set op-group @kbd{--group=@var{group}}
  172. @set ref-group @ref{Option Summary}
  173. @set xref-group @xref{Option Summary}
  174. @set pxref-group @pxref{Option Summary}
  175. @set op-gzip @kbd{--gzip} (@kbd{--gunzip}, @kbd{--ungzip}, @kbd{-z})
  176. @set ref-gzip @ref{gzip}
  177. @set xref-gzip @xref{gzip}
  178. @set pxref-gzip @pxref{gzip}
  179. @set op-help @kbd{--help}
  180. @set ref-help @ref{help}
  181. @set xref-help @xref{help}
  182. @set pxref-help @pxref{help}
  183. @set op-ignore-failed-read @kbd{--ignore-failed-read}
  184. @set ref-ignore-failed-read @ref{create options}
  185. @set xref-ignore-failed-read @xref{create options}
  186. @set pxref-ignore-failed-read @pxref{create options}
  187. @set op-ignore-zeros @kbd{--ignore-zeros} (@kbd{-i})
  188. @set ref-ignore-zeros @ref{Reading}
  189. @set xref-ignore-zeros @xref{Reading}
  190. @set pxref-ignore-zeros @pxref{Reading}
  191. @set op-incremental @kbd{--incremental} (@kbd{-G})
  192. @set ref-incremental @ref{Inc Dumps}
  193. @set xref-incremental @xref{Inc Dumps}
  194. @set pxref-incremental @pxref{Inc Dumps}
  195. @set op-info-script @kbd{--info-script=@var{script-name}} (@kbd{--new-volume-script=@var{script-name}}, @kbd{-F @var{script-name}})
  196. @set ref-info-script @ref{Multi-Volume Archives}
  197. @set xref-info-script @xref{Multi-Volume Archives}
  198. @set pxref-info-script @pxref{Multi-Volume Archives}
  199. @set op-interactive @kbd{--interactive} (@kbd{-w})
  200. @set ref-interactive @ref{interactive}
  201. @set xref-interactive @xref{interactive}
  202. @set pxref-interactive @pxref{interactive}
  203. @set op-keep-old-files @kbd{--keep-old-files} (@kbd{-k})
  204. @set ref-keep-old-files @ref{Writing}
  205. @set xref-keep-old-files @xref{Writing}
  206. @set pxref-keep-old-files @pxref{Writing}
  207. @set op-label @kbd{--label=@var{archive-label}} (@kbd{-V @var{archive-label}})
  208. @set ref-label @ref{label}
  209. @set xref-label @xref{label}
  210. @set pxref-label @pxref{label}
  211. @set op-list @kbd{--list} (@kbd{-t})
  212. @set ref-list @ref{list}
  213. @set xref-list @xref{list}
  214. @set pxref-list @pxref{list}
  215. @set op-listed-incremental @kbd{--listed-incremental=@var{snapshot-file}} (@kbd{-g @var{snapshot-file}})
  216. @set ref-listed-incremental @ref{Inc Dumps}
  217. @set xref-listed-incremental @xref{Inc Dumps}
  218. @set pxref-listed-incremental @pxref{Inc Dumps}
  219. @set op-mode @kbd{--mode=@var{permissions}}
  220. @set ref-mode @ref{Option Summary}
  221. @set xref-mode @xref{Option Summary}
  222. @set pxref-mode @pxref{Option Summary}
  223. @set op-multi-volume @kbd{--multi-volume} (@kbd{-M})
  224. @set ref-multi-volume @ref{Multi-Volume Archives}
  225. @set xref-multi-volume @xref{Multi-Volume Archives}
  226. @set pxref-multi-volume @pxref{Multi-Volume Archives}
  227. @set op-newer-mtime @kbd{--newer-mtime=@var{date}}
  228. @set ref-newer-mtime @ref{after}
  229. @set xref-newer-mtime @xref{after}
  230. @set pxref-newer-mtime @pxref{after}
  231. @set op-no-recursion @kbd{--no-recursion}
  232. @set ref-no-recursion @ref{recurse}
  233. @set xref-no-recursion @xref{recurse}
  234. @set pxref-no-recursion @pxref{recurse}
  235. @set op-no-same-owner @kbd{--no-same-owner}
  236. @set ref-no-same-owner @ref{Attributes}
  237. @set xref-no-same-owner @xref{Attributes}
  238. @set pxref-no-same-owner @pxref{Attributes}
  239. @set op-no-same-permissions @kbd{--no-same-permissions}
  240. @set ref-no-same-permissions @ref{Attributes}
  241. @set xref-no-same-permissions @xref{Attributes}
  242. @set pxref-no-same-permissions @pxref{Attributes}
  243. @set op-null @kbd{--null}
  244. @set ref-null @ref{files}
  245. @set xref-null @xref{files}
  246. @set pxref-null @pxref{files}
  247. @set op-numeric-owner @kbd{--numeric-owner}
  248. @set ref-numeric-owner @ref{Attributes}
  249. @set xref-numeric-owner @xref{Attributes}
  250. @set pxref-numeric-owner @pxref{Attributes}
  251. @set op-old-archive @kbd{--old-archive} (@kbd{-o})
  252. @set ref-old-archive @ref{old}
  253. @set xref-old-archive @xref{old}
  254. @set pxref-old-archive @pxref{old}
  255. @set op-one-file-system @kbd{--one-file-system} (@kbd{-l})
  256. @set ref-one-file-system @ref{one}
  257. @set xref-one-file-system @xref{one}
  258. @set pxref-one-file-system @pxref{one}
  259. @set op-overwrite @kbd{--overwrite}
  260. @set ref-overwrite @ref{Overwrite Old Files}
  261. @set xref-overwrite @xref{Overwrite Old Files}
  262. @set pxref-overwrite @pxref{Overwrite Old Files}
  263. @set op-owner @kbd{--owner=@var{user}}
  264. @set ref-owner @ref{Option Summary}
  265. @set xref-owner @xref{Option Summary}
  266. @set pxref-owner @pxref{Option Summary}
  267. @set op-posix @kbd{--posix}
  268. @set ref-posix @ref{posix}
  269. @set xref-posix @xref{posix}
  270. @set pxref-posix @pxref{posix}
  271. @set op-preserve @kbd{--preserve}
  272. @set ref-preserve @ref{Attributes}
  273. @set xref-preserve @xref{Attributes}
  274. @set pxref-preserve @pxref{Attributes}
  275. @set op-record-size @kbd{--record-size=@var{size}}
  276. @set ref-record-size @ref{Blocking}
  277. @set xref-record-size @xref{Blocking}
  278. @set pxref-record-size @pxref{Blocking}
  279. @set op-recursive-unlink @kbd{--recursive-unlink}
  280. @set ref-recursive-unlink @ref{Writing}
  281. @set xref-recursive-unlink @xref{Writing}
  282. @set pxref-recursive-unlink @pxref{Writing}
  283. @set op-read-full-records @kbd{--read-full-records} (@kbd{-B})
  284. @set ref-read-full-records @ref{Blocking}
  285. @set xref-read-full-records @xref{Blocking}
  286. @set pxref-read-full-records @pxref{Blocking}
  287. @c FIXME: or should it be Reading, or Blocking Factor
  288. @set op-remove-files @kbd{--remove-files}
  289. @set ref-remove-files @ref{Writing}
  290. @set xref-remove-files @xref{Writing}
  291. @set pxref-remove-files @pxref{Writing}
  292. @set op-rsh-command @kbd{rsh-command=@var{command}}
  293. @set op-same-order @kbd{--same-order} (@kbd{--preserve-order}, @kbd{-s})
  294. @set ref-same-order @ref{Scarce}
  295. @set xref-same-order @xref{Scarce}
  296. @set pxref-same-order @pxref{Scarce}
  297. @c FIXME: or should it be Reading, or Attributes?
  298. @set op-same-owner @kbd{--same-owner}
  299. @set ref-same-owner @ref{Attributes}
  300. @set xref-same-owner @xref{Attributes}
  301. @set pxref-same-owner @pxref{Attributes}
  302. @set op-same-permissions @kbd{--same-permissions} (@kbd{--preserve-permissions}, @kbd{-p})
  303. @set ref-same-permissions @ref{Attributes}
  304. @set xref-same-permissions @xref{Attributes}
  305. @set pxref-same-permissions @pxref{Attributes}
  306. @c FIXME: or should it be Writing?
  307. @set op-show-omitted-dirs @kbd{--show-omitted-dirs}
  308. @set ref-show-omitted-dirs @ref{verbose}
  309. @set xref-show-omitted-dirs @xref{verbose}
  310. @set pxref-show-omitted-dirs @pxref{verbose}
  311. @set op-sparse @kbd{--sparse} (@kbd{-S})
  312. @set ref-sparse @ref{sparse}
  313. @set xref-sparse @xref{sparse}
  314. @set pxref-sparse @pxref{sparse}
  315. @set op-starting-file @kbd{--starting-file=@var{name}} (@kbd{-K @var{name}})
  316. @set ref-starting-file @ref{Scarce}
  317. @set xref-starting-file @xref{Scarce}
  318. @set pxref-starting-file @pxref{Scarce}
  319. @set op-suffix @kbd{--suffix=@var{suffix}}
  320. @set ref-suffix @ref{Backup options}
  321. @set xref-suffix @xref{Backup options}
  322. @set pxref-suffix @pxref{Backup options}
  323. @set op-tape-length @kbd{--tape-length=@var{1024-size}} (@kbd{-L @var{1024-size}})
  324. @set ref-tape-length @ref{Using Multiple Tapes}
  325. @set xref-tape-length @xref{Using Multiple Tapes}
  326. @set pxref-tape-length @pxref{Using Multiple Tapes}
  327. @set op-to-stdout @kbd{--to-stdout} (@kbd{-O})
  328. @set ref-to-stdout @ref{Writing}
  329. @set xref-to-stdout @xref{Writing}
  330. @set pxref-to-stdout @pxref{Writing}
  331. @set op-totals @kbd{--totals}
  332. @set ref-totals @ref{verbose}
  333. @set xref-totals @xref{verbose}
  334. @set pxref-totals @pxref{verbose}
  335. @set op-touch @kbd{--touch} (@kbd{-m})
  336. @set ref-touch @ref{Writing}
  337. @set xref-touch @xref{Writing}
  338. @set pxref-touch @pxref{Writing}
  339. @set op-unlink-first @kbd{--unlink-first} (@kbd{-U})
  340. @set ref-unlink-first @ref{Writing}
  341. @set xref-unlink-first @xref{Writing}
  342. @set pxref-unlink-first @pxref{Writing}
  343. @set op-update @kbd{--update} (@kbd{-u})
  344. @set ref-update @ref{update}
  345. @set xref-update @xref{update}
  346. @set pxref-update @pxref{update}
  347. @set op-use-compress-prog @kbd{--use-compress-prog=@var{program}}
  348. @set ref-use-compress-prog @ref{gzip}
  349. @set xref-use-compress-prog @xref{gzip}
  350. @set pxref-use-compress-prog @pxref{gzip}
  351. @set op-verbose @kbd{--verbose} (@kbd{-v})
  352. @set ref-verbose @ref{verbose}
  353. @set xref-verbose @xref{verbose}
  354. @set pxref-verbose @pxref{verbose}
  355. @set op-verify @kbd{--verify} (@kbd{-W})
  356. @set ref-verify @ref{verify}
  357. @set xref-verify @xref{verify}
  358. @set pxref-verify @pxref{verify}
  359. @set op-version @kbd{--version}
  360. @set ref-version @ref{help}
  361. @set xref-version @xref{help}
  362. @set pxref-version @pxref{help}
  363. @set op-volno-file @kbd{--volno-file=@var{file-of-number}}
  364. @set ref-volno-file @ref{Using Multiple Tapes}
  365. @set xref-volno-file @xref{Using Multiple Tapes}
  366. @set pxref-volno-file @pxref{Using Multiple Tapes}
  367. @c Put everything in one index (arbitrarily chosen to be the concept index).
  368. @syncodeindex fn cp
  369. @syncodeindex ky cp
  370. @syncodeindex pg cp
  371. @syncodeindex vr cp
  372. @defindex op
  373. @syncodeindex op cp
  374. @copying
  375. This manual is for @acronym{GNU} @command{tar} (version
  376. @value{VERSION}, @value{UPDATED}), which creates and extracts files
  377. from archives.
  378. Copyright @copyright{} 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2001,
  379. 2003 Free Software Foundation, Inc.
  380. @quotation
  381. Permission is granted to copy, distribute and/or modify this document
  382. under the terms of the GNU Free Documentation License, Version 1.1 or
  383. any later version published by the Free Software Foundation; with the
  384. Invariant Sections being "GNU General Public License", with the
  385. Front-Cover Texts being ``A GNU Manual,'' and with the Back-Cover Texts
  386. as in (a) below. A copy of the license is included in the section
  387. entitled "GNU Free Documentation License".
  388. (a) The FSF's Back-Cover Text is: ``You are free to copy and modify
  389. this GNU Manual. Buying copies from GNU Press supports the FSF in
  390. developing GNU and promoting software freedom.''
  391. @end quotation
  392. @end copying
  393. @dircategory Archiving
  394. @direntry
  395. * Tar: (tar). Making tape (or disk) archives.
  396. @end direntry
  397. @dircategory Individual utilities
  398. @direntry
  399. * tar: (tar)tar invocation. Invoking @acronym{GNU} @command{tar}
  400. @end direntry
  401. @shorttitlepage @acronym{GNU} @command{tar}
  402. @titlepage
  403. @title @acronym{GNU} tar: an archiver tool
  404. @subtitle @value{RENDITION} @value{VERSION}, @value{UPDATED}
  405. @author Melissa Weisshaus, Jay Fenlason,
  406. @author Thomas Bushnell, n/BSG, Amy Gorin
  407. @c he said to remove it: Fran@,{c}ois Pinard
  408. @c i'm thinking about how the author page *should* look. -mew 2may96
  409. @page
  410. @vskip 0pt plus 1filll
  411. @insertcopying
  412. @end titlepage
  413. @ifnottex
  414. @node Top
  415. @top @acronym{GNU} tar: an archiver tool
  416. @insertcopying
  417. @cindex file archival
  418. @cindex archiving files
  419. The first part of this master menu lists the major nodes in this Info
  420. document. The rest of the menu lists all the lower level nodes.
  421. @end ifnottex
  422. @c The master menu, created with texinfo-master-menu, goes here.
  423. @c (However, getdate.texi's menu is interpolated by hand.)
  424. @menu
  425. * Introduction::
  426. * Tutorial::
  427. * tar invocation::
  428. * operations::
  429. * Backups::
  430. * Choosing::
  431. * Date input formats::
  432. * Formats::
  433. * Media::
  434. * Free Software Needs Free Documentation::
  435. * Copying This Manual::
  436. * Index::
  437. @detailmenu
  438. --- The Detailed Node Listing ---
  439. Introduction
  440. * Book Contents:: What this Book Contains
  441. * Definitions:: Some Definitions
  442. * What tar Does:: What @command{tar} Does
  443. * Naming tar Archives:: How @command{tar} Archives are Named
  444. * posix compliance::
  445. * Authors:: @acronym{GNU} @command{tar} Authors
  446. * Reports:: Reporting bugs or suggestions
  447. Tutorial Introduction to @command{tar}
  448. * assumptions::
  449. * stylistic conventions::
  450. * basic tar options:: Basic @command{tar} Operations and Options
  451. * frequent operations::
  452. * Two Frequent Options::
  453. * create:: How to Create Archives
  454. * list:: How to List Archives
  455. * extract:: How to Extract Members from an Archive
  456. * going further::
  457. Two Frequently Used Options
  458. * file tutorial::
  459. * verbose tutorial::
  460. * help tutorial::
  461. How to Create Archives
  462. * prepare for examples::
  463. * Creating the archive::
  464. * create verbose::
  465. * short create::
  466. * create dir::
  467. How to List Archives
  468. * list dir::
  469. How to Extract Members from an Archive
  470. * extracting archives::
  471. * extracting files::
  472. * extract dir::
  473. * failing commands::
  474. Invoking @acronym{GNU} @command{tar}
  475. * Synopsis::
  476. * using tar options::
  477. * Styles::
  478. * All Options::
  479. * help::
  480. * verbose::
  481. * interactive::
  482. The Three Option Styles
  483. * Mnemonic Options:: Mnemonic Option Style
  484. * Short Options:: Short Option Style
  485. * Old Options:: Old Option Style
  486. * Mixing:: Mixing Option Styles
  487. All @command{tar} Options
  488. * Operation Summary::
  489. * Option Summary::
  490. * Short Option Summary::
  491. @acronym{GNU} @command{tar} Operations
  492. * Basic tar::
  493. * Advanced tar::
  494. * create options::
  495. * extract options::
  496. * backup::
  497. * Applications::
  498. * looking ahead::
  499. Advanced @acronym{GNU} @command{tar} Operations
  500. * Operations::
  501. * append::
  502. * update::
  503. * concatenate::
  504. * delete::
  505. * compare::
  506. How to Add Files to Existing Archives: @code{--append}
  507. * appending files:: Appending Files to an Archive
  508. * multiple::
  509. Updating an Archive
  510. * how to update::
  511. Options Used by @code{--create}
  512. * Ignore Failed Read::
  513. Options Used by @code{--extract}
  514. * Reading:: Options to Help Read Archives
  515. * Writing:: Changing How @command{tar} Writes Files
  516. * Scarce:: Coping with Scarce Resources
  517. Options to Help Read Archives
  518. * read full records::
  519. * Ignore Zeros::
  520. Changing How @command{tar} Writes Files
  521. * Dealing with Old Files::
  522. * Overwrite Old Files::
  523. * Keep Old Files::
  524. * Unlink First::
  525. * Recursive Unlink::
  526. * Modification Times::
  527. * Setting Access Permissions::
  528. * Writing to Standard Output::
  529. * remove files::
  530. Coping with Scarce Resources
  531. * Starting File::
  532. * Same Order::
  533. Performing Backups and Restoring Files
  534. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  535. * Inc Dumps:: Using @command{tar} to Perform Incremental Dumps
  536. * incremental and listed-incremental:: The Incremental Options
  537. * Backup Levels:: Levels of Backups
  538. * Backup Parameters:: Setting Parameters for Backups and Restoration
  539. * Scripted Backups:: Using the Backup Scripts
  540. * Scripted Restoration:: Using the Restore Script
  541. Setting Parameters for Backups and Restoration
  542. * backup-specs example:: An Example Text of @file{Backup-specs}
  543. * Script Syntax:: Syntax for @file{Backup-specs}
  544. Choosing Files and Names for @command{tar}
  545. * file:: Choosing the Archive's Name
  546. * Selecting Archive Members::
  547. * files:: Reading Names from a File
  548. * exclude:: Excluding Some Files
  549. * Wildcards::
  550. * after:: Operating Only on New Files
  551. * recurse:: Descending into Directories
  552. * one:: Crossing Filesystem Boundaries
  553. Reading Names from a File
  554. * nul::
  555. Excluding Some Files
  556. * controlling pattern-patching with exclude::
  557. * problems with exclude::
  558. Crossing Filesystem Boundaries
  559. * directory:: Changing Directory
  560. * absolute:: Absolute File Names
  561. Date input formats
  562. * General date syntax:: Common rules.
  563. * Calendar date items:: 19 Dec 1994.
  564. * Time of day items:: 9:20pm.
  565. * Time zone items:: @sc{est}, @sc{pdt}, @sc{gmt}, ...
  566. * Day of week items:: Monday and others.
  567. * Relative items in date strings:: next tuesday, 2 years ago.
  568. * Pure numbers in date strings:: 19931219, 1440.
  569. * Authors of getdate:: Bellovin, Eggert, Salz, Berets, et al.
  570. Controlling the Archive Format
  571. * Portability:: Making @command{tar} Archives More Portable
  572. * Compression:: Using Less Space through Compression
  573. * Attributes:: Handling File Attributes
  574. * Standard:: The Standard Format
  575. * Extensions:: @acronym{GNU} Extensions to the Archive Format
  576. * cpio:: Comparison of @command{tar} and @command{cpio}
  577. Making @command{tar} Archives More Portable
  578. * Portable Names:: Portable Names
  579. * dereference:: Symbolic Links
  580. * old:: Old V7 Archives
  581. * posix:: @sc{posix} archives
  582. * Checksumming:: Checksumming Problems
  583. * Large or Negative Values:: Large files, negative time stamps, etc.
  584. Using Less Space through Compression
  585. * gzip:: Creating and Reading Compressed Archives
  586. * sparse:: Archiving Sparse Files
  587. Tapes and Other Archive Media
  588. * Device:: Device selection and switching
  589. * Remote Tape Server::
  590. * Common Problems and Solutions::
  591. * Blocking:: Blocking
  592. * Many:: Many archives on one tape
  593. * Using Multiple Tapes:: Using Multiple Tapes
  594. * label:: Including a Label in the Archive
  595. * verify::
  596. * Write Protection::
  597. Blocking
  598. * Format Variations:: Format Variations
  599. * Blocking Factor:: The Blocking Factor of an Archive
  600. Many Archives on One Tape
  601. * Tape Positioning:: Tape Positions and Tape Marks
  602. * mt:: The @command{mt} Utility
  603. Using Multiple Tapes
  604. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  605. * Tape Files:: Tape Files
  606. Copying This Manual
  607. * GNU Free Documentation License:: License for copying this manual
  608. @end detailmenu
  609. @end menu
  610. @node Introduction
  611. @chapter Introduction
  612. @acronym{GNU} @command{tar} creates
  613. and manipulates (@dfn{archives}) which are actually collections of
  614. many other files; the program provides users with an organized and
  615. systematic method for controlling a large amount of data.
  616. The name ``tar'' originally came from the phrase ``Tape ARchive'', but
  617. archives need not (and these days, typically do not) reside on tapes.
  618. @menu
  619. * Book Contents:: What this Book Contains
  620. * Definitions:: Some Definitions
  621. * What tar Does:: What @command{tar} Does
  622. * Naming tar Archives:: How @command{tar} Archives are Named
  623. * posix compliance::
  624. * Authors:: @acronym{GNU} @command{tar} Authors
  625. * Reports:: Reporting bugs or suggestions
  626. @end menu
  627. @node Book Contents
  628. @section What this Book Contains
  629. The first part of this chapter introduces you to various terms that will
  630. recur throughout the book. It also tells you who has worked on @acronym{GNU}
  631. @command{tar} and its documentation, and where you should send bug reports
  632. or comments.
  633. The second chapter is a tutorial (@pxref{Tutorial}) which provides a
  634. gentle introduction for people who are new to using @command{tar}. It is
  635. meant to be self contained, not requiring any reading from subsequent
  636. chapters to make sense. It moves from topic to topic in a logical,
  637. progressive order, building on information already explained.
  638. Although the tutorial is paced and structured to allow beginners to
  639. learn how to use @command{tar}, it is not intended solely for beginners.
  640. The tutorial explains how to use the three most frequently used
  641. operations (@samp{create}, @samp{list}, and @samp{extract}) as well as
  642. two frequently used options (@samp{file} and @samp{verbose}). The other
  643. chapters do not refer to the tutorial frequently; however, if a section
  644. discusses something which is a complex variant of a basic concept, there
  645. may be a cross reference to that basic concept. (The entire book,
  646. including the tutorial, assumes that the reader understands some basic
  647. concepts of using a Unix-type operating system; @pxref{Tutorial}.)
  648. The third chapter presents the remaining five operations, and
  649. information about using @command{tar} options and option syntax.
  650. @FIXME{this sounds more like a @acronym{GNU} Project Manuals Concept [tm] more
  651. than the reality. should think about whether this makes sense to say
  652. here, or not.} The other chapters are meant to be used as a
  653. reference. Each chapter presents everything that needs to be said
  654. about a specific topic.
  655. One of the chapters (@pxref{Date input formats}) exists in its
  656. entirety in other @acronym{GNU} manuals, and is mostly self-contained.
  657. In addition, one section of this manual (@pxref{Standard}) contains a
  658. big quote which is taken directly from @command{tar} sources.
  659. In general, we give both the long and short (abbreviated) option names
  660. at least once in each section where the relevant option is covered, so
  661. that novice readers will become familiar with both styles. (A few
  662. options have no short versions, and the relevant sections will
  663. indicate this.)
  664. @node Definitions
  665. @section Some Definitions
  666. @cindex archive
  667. @cindex tar archive
  668. The @command{tar} program is used to create and manipulate @command{tar}
  669. archives. An @dfn{archive} is a single file which contains the contents
  670. of many files, while still identifying the names of the files, their
  671. owner(s), and so forth. (In addition, archives record access
  672. permissions, user and group, size in bytes, and last modification time.
  673. Some archives also record the file names in each archived directory, as
  674. well as other file and directory information.) You can use @command{tar}
  675. to @dfn{create} a new archive in a specified directory.
  676. @cindex member
  677. @cindex archive member
  678. @cindex file name
  679. @cindex member name
  680. The files inside an archive are called @dfn{members}. Within this
  681. manual, we use the term @dfn{file} to refer only to files accessible in
  682. the normal ways (by @command{ls}, @command{cat}, and so forth), and the term
  683. @dfn{member} to refer only to the members of an archive. Similarly, a
  684. @dfn{file name} is the name of a file, as it resides in the filesystem,
  685. and a @dfn{member name} is the name of an archive member within the
  686. archive.
  687. @cindex extraction
  688. @cindex unpacking
  689. The term @dfn{extraction} refers to the process of copying an archive
  690. member (or multiple members) into a file in the filesystem. Extracting
  691. all the members of an archive is often called @dfn{extracting the
  692. archive}. The term @dfn{unpack} can also be used to refer to the
  693. extraction of many or all the members of an archive. Extracting an
  694. archive does not destroy the archive's structure, just as creating an
  695. archive does not destroy the copies of the files that exist outside of
  696. the archive. You may also @dfn{list} the members in a given archive
  697. (this is often thought of as ``printing'' them to the standard output,
  698. or the command line), or @dfn{append} members to a pre-existing archive.
  699. All of these operations can be performed using @command{tar}.
  700. @node What tar Does
  701. @section What @command{tar} Does
  702. @cindex tar
  703. The @command{tar} program provides the ability to create @command{tar}
  704. archives, as well as various other kinds of manipulation. For example,
  705. you can use @command{tar} on previously created archives to extract files,
  706. to store additional files, or to update or list files which were already
  707. stored.
  708. Initially, @command{tar} archives were used to store files conveniently on
  709. magnetic tape. The name @command{tar} comes from this use; it stands for
  710. @code{t}ape @code{ar}chiver. Despite the utility's name, @command{tar} can
  711. direct its output to available devices, files, or other programs (using
  712. pipes). @command{tar} may even access remote devices or files (as archives).
  713. @FIXME{the following table entries need a bit of work..}
  714. You can use @command{tar} archives in many ways. We want to stress a few
  715. of them: storage, backup, and transportation.
  716. @table @asis
  717. @item Storage
  718. Often, @command{tar} archives are used to store related files for
  719. convenient file transfer over a network. For example, the
  720. @acronym{GNU} Project distributes its software bundled into
  721. @command{tar} archives, so that all the files relating to a particular
  722. program (or set of related programs) can be transferred as a single
  723. unit.
  724. A magnetic tape can store several files in sequence. However, the tape
  725. has no names for these files; it only knows their relative position on
  726. the tape. One way to store several files on one tape and retain their
  727. names is by creating a @command{tar} archive. Even when the basic transfer
  728. mechanism can keep track of names, as FTP can, the nuisance of handling
  729. multiple files, directories, and multiple links makes @command{tar}
  730. archives useful.
  731. Archive files are also used for long-term storage. You can think of
  732. this as transportation from the present into the future. (It is a
  733. science-fiction idiom that you can move through time as well as in
  734. space; the idea here is that @command{tar} can be used to move archives in
  735. all dimensions, even time!)
  736. @item Backup
  737. Because the archive created by @command{tar} is capable of preserving
  738. file information and directory structure, @command{tar} is commonly
  739. used for performing full and incremental backups of disks. A backup
  740. puts a collection of files (possibly pertaining to many users and
  741. projects) together on a disk or a tape. This guards against
  742. accidental destruction of the information in those files.
  743. @acronym{GNU} @command{tar} has special features that allow it to be
  744. used to make incremental and full dumps of all the files in a
  745. filesystem.
  746. @item Transportation
  747. You can create an archive on one system, transfer it to another system,
  748. and extract the contents there. This allows you to transport a group of
  749. files from one system to another.
  750. @end table
  751. @node Naming tar Archives
  752. @section How @command{tar} Archives are Named
  753. Conventionally, @command{tar} archives are given names ending with
  754. @samp{.tar}. This is not necessary for @command{tar} to operate properly,
  755. but this manual follows that convention in order to accustom readers to
  756. it and to make examples more clear.
  757. @cindex tar file
  758. @cindex entry
  759. @cindex tar entry
  760. Often, people refer to @command{tar} archives as ``@command{tar} files,'' and
  761. archive members as ``files'' or ``entries''. For people familiar with
  762. the operation of @command{tar}, this causes no difficulty. However, in
  763. this manual, we consistently refer to ``archives'' and ``archive
  764. members'' to make learning to use @command{tar} easier for novice users.
  765. @node posix compliance
  766. @section @sc{posix} Compliance
  767. @noindent
  768. @FIXME{must ask franc,ois about this. dan hagerty thinks this might
  769. be an issue, but we're not really sure at this time. dan just tried a
  770. test case of mixing up options' orders while the variable was set, and
  771. there was no problem...}
  772. We make some of our recommendations throughout this book for one
  773. reason in addition to what we think of as ``good sense''. The main
  774. additional reason for a recommendation is to be compliant with the
  775. @sc{posix} standards. If you set the shell environment variable
  776. @env{POSIXLY_CORRECT}, @acronym{GNU} @command{tar} will force you to
  777. adhere to these standards. Therefore, if this variable is set and you
  778. violate one of the @sc{posix} standards in the way you phrase a
  779. command, for example, @acronym{GNU} @command{tar} will not allow the
  780. command and will signal an error message. You would then have to
  781. reorder the options or rephrase the command to comply with the
  782. @sc{posix} standards.
  783. There is a chance in the future that, if you set this environment
  784. variable, your archives will be forced to comply with @sc{posix} standards,
  785. also. No @acronym{GNU} @command{tar} extensions will be allowed.
  786. @node Authors
  787. @section @acronym{GNU} @command{tar} Authors
  788. @acronym{GNU} @command{tar} was originally written by John Gilmore,
  789. and modified by many people. The @acronym{GNU} enhancements were
  790. written by Jay Fenlason, then Joy Kendall, and the whole package has
  791. been further maintained by Thomas Bushnell, n/BSG, and finally
  792. Fran@,{c}ois Pinard, with the help of numerous and kind users.
  793. We wish to stress that @command{tar} is a collective work, and owes much to
  794. all those people who reported problems, offered solutions and other
  795. insights, or shared their thoughts and suggestions. An impressive, yet
  796. partial list of those contributors can be found in the @file{THANKS}
  797. file from the @acronym{GNU} @command{tar} distribution.
  798. @FIXME{i want all of these names mentioned, Absolutely. BUT, i'm not
  799. sure i want to spell out the history in this detail, at least not for
  800. the printed book. i'm just not sure it needs to be said this way.
  801. i'll think about it.}
  802. @FIXME{History is more important, and surely more interesting, than
  803. actual names. Quoting names without history would be meaningless. FP}
  804. Jay Fenlason put together a draft of a @acronym{GNU} @command{tar}
  805. manual, borrowing notes from the original man page from John Gilmore.
  806. This was withdrawn in version 1.11. Thomas Bushnell, n/BSG and Amy
  807. Gorin worked on a tutorial and manual for @acronym{GNU} @command{tar}.
  808. Fran@,{c}ois Pinard put version 1.11.8 of the manual together by
  809. taking information from all these sources and merging them. Melissa
  810. Weisshaus finally edited and redesigned the book to create version
  811. 1.12. @FIXME{update version number as necessary; i'm being
  812. optimistic!} @FIXME{Someone [maybe karl berry? maybe bob chassell?
  813. maybe melissa? maybe julie sussman?] needs to properly index the
  814. thing.}
  815. For version 1.12, Daniel Hagerty contributed a great deal of technical
  816. consulting. In particular, he is the primary author of @ref{Backups}.
  817. @node Reports
  818. @section Reporting bugs or suggestions
  819. @cindex bug reports
  820. @cindex reporting bugs
  821. If you find problems or have suggestions about this program or manual,
  822. please report them to @file{bug-tar@@gnu.org}.
  823. @node Tutorial
  824. @chapter Tutorial Introduction to @command{tar}
  825. This chapter guides you through some basic examples of three @command{tar}
  826. operations: @samp{--create}, @samp{--list}, and @samp{--extract}. If
  827. you already know how to use some other version of @command{tar}, then you
  828. may not need to read this chapter. This chapter omits most complicated
  829. details about how @command{tar} works.
  830. @menu
  831. * assumptions::
  832. * stylistic conventions::
  833. * basic tar options:: Basic @command{tar} Operations and Options
  834. * frequent operations::
  835. * Two Frequent Options::
  836. * create:: How to Create Archives
  837. * list:: How to List Archives
  838. * extract:: How to Extract Members from an Archive
  839. * going further::
  840. @end menu
  841. @node assumptions
  842. @section Assumptions this Tutorial Makes
  843. This chapter is paced to allow beginners to learn about @command{tar}
  844. slowly. At the same time, we will try to cover all the basic aspects of
  845. these three operations. In order to accomplish both of these tasks, we
  846. have made certain assumptions about your knowledge before reading this
  847. manual, and the hardware you will be using:
  848. @itemize @bullet
  849. @item
  850. Before you start to work through this tutorial, you should understand
  851. what the terms ``archive'' and ``archive member'' mean
  852. (@pxref{Definitions}). In addition, you should understand something
  853. about how Unix-type operating systems work, and you should know how to
  854. use some basic utilities. For example, you should know how to create,
  855. list, copy, rename, edit, and delete files and directories; how to
  856. change between directories; and how to figure out where you are in the
  857. filesystem. You should have some basic understanding of directory
  858. structure and how files are named according to which directory they are
  859. in. You should understand concepts such as standard output and standard
  860. input, what various definitions of the term ``argument'' mean, and the
  861. differences between relative and absolute path names. @FIXME{and what
  862. else?}
  863. @item
  864. This manual assumes that you are working from your own home directory
  865. (unless we state otherwise). In this tutorial, you will create a
  866. directory to practice @command{tar} commands in. When we show path names,
  867. we will assume that those paths are relative to your home directory.
  868. For example, my home directory path is @file{/home/fsf/melissa}. All of
  869. my examples are in a subdirectory of the directory named by that path
  870. name; the subdirectory is called @file{practice}.
  871. @item
  872. In general, we show examples of archives which exist on (or can be
  873. written to, or worked with from) a directory on a hard disk. In most
  874. cases, you could write those archives to, or work with them on any other
  875. device, such as a tape drive. However, some of the later examples in
  876. the tutorial and next chapter will not work on tape drives.
  877. Additionally, working with tapes is much more complicated than working
  878. with hard disks. For these reasons, the tutorial does not cover working
  879. with tape drives. @xref{Media}, for complete information on using
  880. @command{tar} archives with tape drives.
  881. @FIXME{this is a cop out. need to add some simple tape drive info.}
  882. @end itemize
  883. @node stylistic conventions
  884. @section Stylistic Conventions
  885. In the examples, @samp{$} represents a typical shell prompt. It
  886. precedes lines you should type; to make this more clear, those lines are
  887. shown in @kbd{this font}, as opposed to lines which represent the
  888. computer's response; those lines are shown in @code{this font}, or
  889. sometimes @samp{like this}. When we have lines which are too long to be
  890. displayed in any other way, we will show them like this:
  891. @smallexample
  892. This is an example of a line which would otherwise not fit in this space.
  893. @end smallexample
  894. @FIXME{how often do we use smallexample?}
  895. @node basic tar options
  896. @section Basic @command{tar} Operations and Options
  897. @command{tar} can take a wide variety of arguments which specify and define
  898. the actions it will have on the particular set of files or the archive.
  899. The main types of arguments to @command{tar} fall into one of two classes:
  900. operations, and options.
  901. Some arguments fall into a class called @dfn{operations}; exactly one of
  902. these is both allowed and required for any instance of using @command{tar};
  903. you may @emph{not} specify more than one. People sometimes speak of
  904. @dfn{operating modes}. You are in a particular operating mode when you
  905. have specified the operation which specifies it; there are eight
  906. operations in total, and thus there are eight operating modes.
  907. The other arguments fall into the class known as @dfn{options}. You are
  908. not required to specify any options, and you are allowed to specify more
  909. than one at a time (depending on the way you are using @command{tar} at
  910. that time). Some options are used so frequently, and are so useful for
  911. helping you type commands more carefully that they are effectively
  912. ``required''. We will discuss them in this chapter.
  913. You can write most of the @command{tar} operations and options in any
  914. of three forms: long (mnemonic) form, short form, and old style. Some
  915. of the operations and options have no short or ``old'' forms; however,
  916. the operations and options which we will cover in this tutorial have
  917. corresponding abbreviations. @FIXME{make sure this is still the case,
  918. at the end}We will indicate those abbreviations appropriately to get
  919. you used to seeing them. (Note that the ``old style'' option forms
  920. exist in @acronym{GNU} @command{tar} for compatibility with Unix
  921. @command{tar}. We present a full discussion of this way of writing
  922. options and operations appears in @ref{Old Options}, and we discuss
  923. the other two styles of writing options in @ref{Mnemonic Options} and
  924. @ref{Short Options}.)
  925. In the examples and in the text of this tutorial, we usually use the
  926. long forms of operations and options; but the ``short'' forms produce
  927. the same result and can make typing long @command{tar} commands easier.
  928. For example, instead of typing
  929. @example
  930. @kbd{tar --create --verbose --file=afiles.tar apple angst aspic}
  931. @end example
  932. @noindent
  933. you can type
  934. @example
  935. @kbd{tar -c -v -f afiles.tar apple angst aspic}
  936. @end example
  937. @noindent
  938. or even
  939. @example
  940. @kbd{tar -cvf afiles.tar apple angst aspic}
  941. @end example
  942. @noindent
  943. For more information on option syntax, see @ref{Advanced tar}. In
  944. discussions in the text, when we name an option by its long form, we
  945. also give the corresponding short option in parentheses.
  946. The term, ``option'', can be confusing at times, since ``operations''
  947. are often lumped in with the actual, @emph{optional} ``options'' in certain
  948. general class statements. For example, we just talked about ``short and
  949. long forms of options and operations''. However, experienced @command{tar}
  950. users often refer to these by shorthand terms such as, ``short and long
  951. options''. This term assumes that the ``operations'' are included, also.
  952. Context will help you determine which definition of ``options'' to use.
  953. Similarly, the term ``command'' can be confusing, as it is often used in
  954. two different ways. People sometimes refer to @command{tar} ``commands''.
  955. A @command{tar} @dfn{command} is the entire command line of user input
  956. which tells @command{tar} what to do --- including the operation, options,
  957. and any arguments (file names, pipes, other commands, etc). However,
  958. you will also sometimes hear the term ``the @command{tar} command''. When
  959. the word ``command'' is used specifically like this, a person is usually
  960. referring to the @command{tar} @emph{operation}, not the whole line.
  961. Again, use context to figure out which of the meanings the speaker
  962. intends.
  963. @node frequent operations
  964. @section The Three Most Frequently Used Operations
  965. Here are the three most frequently used operations (both short and long
  966. forms), as well as a brief description of their meanings. The rest of
  967. this chapter will cover how to use these operations in detail. We will
  968. present the rest of the operations in the next chapter.
  969. @table @kbd
  970. @item --create
  971. @itemx -c
  972. Create a new @command{tar} archive.
  973. @item --list
  974. @itemx -t
  975. List the contents of an archive.
  976. @item --extract
  977. @itemx -x
  978. Extract one or more members from an archive.
  979. @end table
  980. @node Two Frequent Options
  981. @section Two Frequently Used Options
  982. To understand how to run @command{tar} in the three operating modes listed
  983. previously, you also need to understand how to use two of the options to
  984. @command{tar}: @samp{--file} (which takes an archive file as an argument)
  985. and @samp{--verbose}. (You are usually not @emph{required} to specify
  986. either of these options when you run @command{tar}, but they can be very
  987. useful in making things more clear and helping you avoid errors.)
  988. @menu
  989. * file tutorial::
  990. * verbose tutorial::
  991. * help tutorial::
  992. @end menu
  993. @node file tutorial
  994. @unnumberedsubsec The @samp{--file} Option
  995. @table @kbd
  996. @item --file=@var{archive-name}
  997. @itemx -f @var{archive-name}
  998. Specify the name of an archive file.
  999. @end table
  1000. You can specify an argument for the @value{op-file} option whenever you
  1001. use @command{tar}; this option determines the name of the archive file
  1002. that @command{tar} will work on.
  1003. If you don't specify this argument, then @command{tar} will use a
  1004. default, usually some physical tape drive attached to your machine.
  1005. If there is no tape drive attached, or the default is not meaningful,
  1006. then @command{tar} will print an error message. The error message might
  1007. look roughly like one of the following:
  1008. @example
  1009. tar: can't open /dev/rmt8 : No such device or address
  1010. tar: can't open /dev/rsmt0 : I/O error
  1011. @end example
  1012. @noindent
  1013. To avoid confusion, we recommend that you always specify an archive file
  1014. name by using @value{op-file} when writing your @command{tar} commands.
  1015. For more information on using the @value{op-file} option, see
  1016. @ref{file}.
  1017. @node verbose tutorial
  1018. @unnumberedsubsec The @samp{--verbose} Option
  1019. @table @kbd
  1020. @item --verbose
  1021. @itemx -v
  1022. Show the files being worked on as @command{tar} is running.
  1023. @end table
  1024. @value{op-verbose} shows details about the results of running
  1025. @command{tar}. This can be especially useful when the results might not be
  1026. obvious. For example, if you want to see the progress of @command{tar} as
  1027. it writes files into the archive, you can use the @samp{--verbose}
  1028. option. In the beginning, you may find it useful to use
  1029. @samp{--verbose} at all times; when you are more accustomed to
  1030. @command{tar}, you will likely want to use it at certain times but not at
  1031. others. We will use @samp{--verbose} at times to help make something
  1032. clear, and we will give many examples both using and not using
  1033. @samp{--verbose} to show the differences.
  1034. Sometimes, a single instance of @samp{--verbose} on the command line
  1035. will show a full, @samp{ls} style listing of an archive or files,
  1036. @c FIXME: Describe the exact output format, e.g., how hard links are displayed.
  1037. giving sizes, owners, and similar information. Other times,
  1038. @samp{--verbose} will only show files or members that the particular
  1039. operation is operating on at the time. In the latter case, you can
  1040. use @samp{--verbose} twice in a command to get a listing such as that
  1041. in the former case. For example, instead of saying
  1042. @example
  1043. @kbd{tar -cvf afiles.tar apple angst aspic}
  1044. @end example
  1045. @noindent
  1046. above, you might say
  1047. @example
  1048. @kbd{tar -cvvf afiles.tar apple angst aspic}
  1049. @end example
  1050. @noindent
  1051. This works equally well using short or long forms of options. Using
  1052. long forms, you would simply write out the mnemonic form of the option
  1053. twice, like this:
  1054. @example
  1055. $ @kbd{tar --create --verbose --verbose @dots{}}
  1056. @end example
  1057. @noindent
  1058. Note that you must double the hyphens properly each time.
  1059. Later in the tutorial, we will give examples using @w{@samp{--verbose
  1060. --verbose}}.
  1061. @node help tutorial
  1062. @unnumberedsubsec Getting Help: Using the @code{--help} Option
  1063. @table @kbd
  1064. @item --help
  1065. The @samp{--help} option to @command{tar} prints out a very brief list of
  1066. all operations and option available for the current version of
  1067. @command{tar} available on your system.
  1068. @end table
  1069. @node create
  1070. @section How to Create Archives
  1071. @UNREVISED
  1072. One of the basic operations of @command{tar} is @value{op-create}, which
  1073. you use to create a @command{tar} archive. We will explain
  1074. @samp{--create} first because, in order to learn about the other
  1075. operations, you will find it useful to have an archive available to
  1076. practice on.
  1077. To make this easier, in this section you will first create a directory
  1078. containing three files. Then, we will show you how to create an
  1079. @emph{archive} (inside the new directory). Both the directory, and
  1080. the archive are specifically for you to practice on. The rest of this
  1081. chapter and the next chapter will show many examples using this
  1082. directory and the files you will create: some of those files may be
  1083. other directories and other archives.
  1084. The three files you will archive in this example are called
  1085. @file{blues}, @file{folk}, and @file{jazz}. The archive is called
  1086. @file{collection.tar}.
  1087. This section will proceed slowly, detailing how to use @samp{--create}
  1088. in @code{verbose} mode, and showing examples using both short and long
  1089. forms. In the rest of the tutorial, and in the examples in the next
  1090. chapter, we will proceed at a slightly quicker pace. This section
  1091. moves more slowly to allow beginning users to understand how
  1092. @command{tar} works.
  1093. @menu
  1094. * prepare for examples::
  1095. * Creating the archive::
  1096. * create verbose::
  1097. * short create::
  1098. * create dir::
  1099. @end menu
  1100. @node prepare for examples
  1101. @subsection Preparing a Practice Directory for Examples
  1102. To follow along with this and future examples, create a new directory
  1103. called @file{practice} containing files called @file{blues}, @file{folk}
  1104. and @file{jazz}. The files can contain any information you like:
  1105. ideally, they should contain information which relates to their names,
  1106. and be of different lengths. Our examples assume that @file{practice}
  1107. is a subdirectory of your home directory.
  1108. Now @command{cd} to the directory named @file{practice}; @file{practice}
  1109. is now your @dfn{working directory}. (@emph{Please note}: Although
  1110. the full path name of this directory is
  1111. @file{/@var{homedir}/practice}, in our examples we will refer to
  1112. this directory as @file{practice}; the @var{homedir} is presumed.
  1113. In general, you should check that the files to be archived exist where
  1114. you think they do (in the working directory) by running @command{ls}.
  1115. Because you just created the directory and the files and have changed to
  1116. that directory, you probably don't need to do that this time.
  1117. It is very important to make sure there isn't already a file in the
  1118. working directory with the archive name you intend to use (in this case,
  1119. @samp{collection.tar}), or that you don't care about its contents.
  1120. Whenever you use @samp{create}, @command{tar} will erase the current
  1121. contents of the file named by @value{op-file} if it exists. @command{tar}
  1122. will not tell you if you are about to overwrite an archive unless you
  1123. specify an option which does this. @FIXME{xref to the node for
  1124. --backup!}To add files to an existing archive, you need to use a
  1125. different option, such as @value{op-append}; see @ref{append} for
  1126. information on how to do this.
  1127. @node Creating the archive
  1128. @subsection Creating the Archive
  1129. To place the files @file{blues}, @file{folk}, and @file{jazz} into an
  1130. archive named @file{collection.tar}, use the following command:
  1131. @example
  1132. $ @kbd{tar --create --file=collection.tar blues folk jazz}
  1133. @end example
  1134. The order of the arguments is not very important, @emph{when using long
  1135. option forms}. You could also say:
  1136. @example
  1137. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  1138. @end example
  1139. @noindent
  1140. However, you can see that this order is harder to understand; this is
  1141. why we will list the arguments in the order that makes the commands
  1142. easiest to understand (and we encourage you to do the same when you use
  1143. @command{tar}, to avoid errors).
  1144. Note that the part of the command which says,
  1145. @w{@kbd{--file=collection.tar}} is considered to be @emph{one} argument.
  1146. If you substituted any other string of characters for
  1147. @kbd{collection.tar}, then that string would become the name of the
  1148. archive file you create.
  1149. The order of the options becomes more important when you begin to use
  1150. short forms. With short forms, if you type commands in the wrong order
  1151. (even if you type them correctly in all other ways), you may end up with
  1152. results you don't expect. For this reason, it is a good idea to get
  1153. into the habit of typing options in the order that makes inherent sense.
  1154. @xref{short create}, for more information on this.
  1155. In this example, you type the command as shown above: @samp{--create}
  1156. is the operation which creates the new archive
  1157. (@file{collection.tar}), and @samp{--file} is the option which lets
  1158. you give it the name you chose. The files, @file{blues}, @file{folk},
  1159. and @file{jazz}, are now members of the archive, @file{collection.tar}
  1160. (they are @dfn{file name arguments} to the @samp{--create} operation).
  1161. @FIXME{xref here to the discussion of file name args?}Now that they are
  1162. in the archive, they are called @emph{archive members}, not files.
  1163. @FIXME{xref to definitions?}
  1164. When you create an archive, you @emph{must} specify which files you
  1165. want placed in the archive. If you do not specify any archive
  1166. members, @acronym{GNU} @command{tar} will complain.
  1167. If you now list the contents of the working directory (@kbd{ls}), you will
  1168. find the archive file listed as well as the files you saw previously:
  1169. @example
  1170. blues folk jazz collection.tar
  1171. @end example
  1172. @noindent
  1173. Creating the archive @samp{collection.tar} did not destroy the copies of
  1174. the files in the directory.
  1175. Keep in mind that if you don't indicate an operation, @command{tar} will not
  1176. run and will prompt you for one. If you don't name any files, @command{tar}
  1177. will complain. You must have write access to the working directory,
  1178. or else you will not be able to create an archive in that directory.
  1179. @emph{Caution}: Do not attempt to use @value{op-create} to add files to
  1180. an existing archive; it will delete the archive and write a new one.
  1181. Use @value{op-append} instead. @xref{append}.
  1182. @node create verbose
  1183. @subsection Running @samp{--create} with @samp{--verbose}
  1184. If you include the @value{op-verbose} option on the command line,
  1185. @command{tar} will list the files it is acting on as it is working. In
  1186. verbose mode, the @code{create} example above would appear as:
  1187. @example
  1188. $ @kbd{tar --create --verbose --file=collection.tar blues folk jazz}
  1189. blues
  1190. folk
  1191. jazz
  1192. @end example
  1193. This example is just like the example we showed which did not use
  1194. @samp{--verbose}, except that @command{tar} generated the remaining lines
  1195. @iftex
  1196. (note the different font styles).
  1197. @end iftex
  1198. @ifinfo
  1199. .
  1200. @end ifinfo
  1201. In the rest of the examples in this chapter, we will frequently use
  1202. @code{verbose} mode so we can show actions or @command{tar} responses that
  1203. you would otherwise not see, and which are important for you to
  1204. understand.
  1205. @node short create
  1206. @subsection Short Forms with @samp{create}
  1207. As we said before, the @value{op-create} operation is one of the most
  1208. basic uses of @command{tar}, and you will use it countless times.
  1209. Eventually, you will probably want to use abbreviated (or ``short'')
  1210. forms of options. A full discussion of the three different forms that
  1211. options can take appears in @ref{Styles}; for now, here is what the
  1212. previous example (including the @value{op-verbose} option) looks like
  1213. using short option forms:
  1214. @example
  1215. $ @kbd{tar -cvf collection.tar blues folk jazz}
  1216. blues
  1217. folk
  1218. jazz
  1219. @end example
  1220. @noindent
  1221. As you can see, the system responds the same no matter whether you use
  1222. long or short option forms.
  1223. @FIXME{i don't like how this is worded:} One difference between using
  1224. short and long option forms is that, although the exact placement of
  1225. arguments following options is no more specific when using short forms,
  1226. it is easier to become confused and make a mistake when using short
  1227. forms. For example, suppose you attempted the above example in the
  1228. following way:
  1229. @example
  1230. $ @kbd{tar -cfv collection.tar blues folk jazz}
  1231. @end example
  1232. @noindent
  1233. In this case, @command{tar} will make an archive file called @file{v},
  1234. containing the files @file{blues}, @file{folk}, and @file{jazz}, because
  1235. the @samp{v} is the closest ``file name'' to the @samp{-f} option, and
  1236. is thus taken to be the chosen archive file name. @command{tar} will try
  1237. to add a file called @file{collection.tar} to the @file{v} archive file;
  1238. if the file @file{collection.tar} did not already exist, @command{tar} will
  1239. report an error indicating that this file does not exist. If the file
  1240. @file{collection.tar} does already exist (e.g., from a previous command
  1241. you may have run), then @command{tar} will add this file to the archive.
  1242. Because the @samp{-v} option did not get registered, @command{tar} will not
  1243. run under @samp{verbose} mode, and will not report its progress.
  1244. The end result is that you may be quite confused about what happened,
  1245. and possibly overwrite a file. To illustrate this further, we will show
  1246. you how an example we showed previously would look using short forms.
  1247. This example,
  1248. @example
  1249. $ @kbd{tar blues --create folk --file=collection.tar jazz}
  1250. @end example
  1251. @noindent
  1252. is confusing as it is. When shown using short forms, however, it
  1253. becomes much more so:
  1254. @example
  1255. $ @kbd{tar blues -c folk -f collection.tar jazz}
  1256. @end example
  1257. @noindent
  1258. It would be very easy to put the wrong string of characters
  1259. immediately following the @samp{-f}, but doing that could sacrifice
  1260. valuable data.
  1261. For this reason, we recommend that you pay very careful attention to
  1262. the order of options and placement of file and archive names,
  1263. especially when using short option forms. Not having the option name
  1264. written out mnemonically can affect how well you remember which option
  1265. does what, and therefore where different names have to be placed.
  1266. (Placing options in an unusual order can also cause @command{tar} to
  1267. report an error if you have set the shell environment variable
  1268. @env{POSIXLY_CORRECT}; @pxref{posix compliance} for more information
  1269. on this.)
  1270. @node create dir
  1271. @subsection Archiving Directories
  1272. @cindex Archiving Directories
  1273. @cindex Directories, Archiving
  1274. You can archive a directory by specifying its directory name as a
  1275. file name argument to @command{tar}. The files in the directory will be
  1276. archived relative to the working directory, and the directory will be
  1277. re-created along with its contents when the archive is extracted.
  1278. To archive a directory, first move to its superior directory. If you
  1279. have followed the previous instructions in this tutorial, you should
  1280. type:
  1281. @example
  1282. $ @kbd{cd ..}
  1283. $
  1284. @end example
  1285. @noindent
  1286. This will put you into the directory which contains @file{practice},
  1287. i.e. your home directory. Once in the superior directory, you can
  1288. specify the subdirectory, @file{practice}, as a file name argument. To
  1289. store @file{practice} in the new archive file @file{music.tar}, type:
  1290. @example
  1291. $ @kbd{tar --create --verbose --file=music.tar practice}
  1292. @end example
  1293. @noindent
  1294. @command{tar} should output:
  1295. @example
  1296. practice/
  1297. practice/blues
  1298. practice/folk
  1299. practice/jazz
  1300. practice/collection.tar
  1301. @end example
  1302. Note that the archive thus created is not in the subdirectory
  1303. @file{practice}, but rather in the current working directory---the
  1304. directory from which @command{tar} was invoked. Before trying to archive a
  1305. directory from its superior directory, you should make sure you have
  1306. write access to the superior directory itself, not only the directory
  1307. you are trying archive with @command{tar}. For example, you will probably
  1308. not be able to store your home directory in an archive by invoking
  1309. @command{tar} from the root directory; @value{xref-absolute-names}. (Note
  1310. also that @file{collection.tar}, the original archive file, has itself
  1311. been archived. @command{tar} will accept any file as a file to be
  1312. archived, regardless of its content. When @file{music.tar} is
  1313. extracted, the archive file @file{collection.tar} will be re-written
  1314. into the file system).
  1315. If you give @command{tar} a command such as
  1316. @example
  1317. $ @kbd{tar --create --file=foo.tar .}
  1318. @end example
  1319. @noindent
  1320. @command{tar} will report @samp{tar: ./foo.tar is the archive; not
  1321. dumped}. This happens because @command{tar} creates the archive
  1322. @file{foo.tar} in the current directory before putting any files into
  1323. it. Then, when @command{tar} attempts to add all the files in the
  1324. directory @file{.} to the archive, it notices that the file
  1325. @file{./foo.tar} is the same as the archive @file{foo.tar}, and skips
  1326. it. (It makes no sense to put an archive into itself.) @acronym{GNU}
  1327. @command{tar} will continue in this case, and create the archive
  1328. normally, except for the exclusion of that one file. (@emph{Please
  1329. note:} Other versions of @command{tar} are not so clever; they will
  1330. enter an infinite loop when this happens, so you should not depend on
  1331. this behavior unless you are certain you are running @acronym{GNU}
  1332. @command{tar}.) @FIXME{bob doesn't like this sentence, since he does
  1333. it all the time, and we've been doing it in the editing passes for
  1334. this manual: In general, make sure that the archive is not inside a
  1335. directory being dumped.}
  1336. @node list
  1337. @section How to List Archives
  1338. Frequently, you will find yourself wanting to determine exactly what a
  1339. particular archive contains. You can use the @value{op-list} operation
  1340. to get the member names as they currently appear in the archive, as well
  1341. as various attributes of the files at the time they were archived. For
  1342. example, you can examine the archive @file{collection.tar} that you
  1343. created in the last section with the command,
  1344. @example
  1345. $ @kbd{tar --list --file=collection.tar}
  1346. @end example
  1347. @noindent
  1348. The output of @command{tar} would then be:
  1349. @example
  1350. blues
  1351. folk
  1352. jazz
  1353. @end example
  1354. @FIXME{we hope this will change. if it doesn't, need to show the
  1355. creation of bfiles somewhere above!!! : }
  1356. @noindent
  1357. The archive @file{bfiles.tar} would list as follows:
  1358. @example
  1359. ./birds
  1360. baboon
  1361. ./box
  1362. @end example
  1363. @noindent
  1364. Be sure to use a @value{op-file} option just as with @value{op-create}
  1365. to specify the name of the archive.
  1366. If you use the @value{op-verbose} option with @samp{--list}, then
  1367. @command{tar} will print out a listing reminiscent of @w{@samp{ls -l}},
  1368. showing owner, file size, and so forth.
  1369. If you had used @value{op-verbose} mode, the example above would look
  1370. like:
  1371. @example
  1372. $ @kbd{tar --list --verbose --file=collection.tar folk}
  1373. -rw-rw-rw- myself user 62 1990-05-23 10:55 folk
  1374. @end example
  1375. @cindex File name arguments, using @code{--list} with
  1376. @cindex @code{--list} with file name arguments
  1377. You can specify one or more individual member names as arguments when
  1378. using @samp{list}. In this case, @command{tar} will only list the
  1379. names of members you identify. For example, @w{@kbd{tar --list
  1380. --file=afiles.tar apple}} would only print @file{apple}.
  1381. @FIXME{we hope the relevant aspects of this will change:}Because
  1382. @command{tar} preserves paths, file names must be specified as they appear
  1383. in the archive (ie., relative to the directory from which the archive
  1384. was created). Therefore, it is essential when specifying member names
  1385. to @command{tar} that you give the exact member names. For example,
  1386. @w{@kbd{tar --list --file=bfiles birds}} would produce an error message
  1387. something like @samp{tar: birds: Not found in archive}, because there is
  1388. no member named @file{birds}, only one named @file{./birds}. While the
  1389. names @file{birds} and @file{./birds} name the same file, @emph{member}
  1390. names are compared using a simplistic name comparison, in which an exact
  1391. match is necessary. @xref{absolute}.
  1392. However, @w{@kbd{tar --list --file=collection.tar folk}} would respond
  1393. with @file{folk}, because @file{folk} is in the archive file
  1394. @file{collection.tar}. If you are not sure of the exact file name, try
  1395. listing all the files in the archive and searching for the one you
  1396. expect to find; remember that if you use @samp{--list} with no file
  1397. names as arguments, @command{tar} will print the names of all the members
  1398. stored in the specified archive.
  1399. @menu
  1400. * list dir::
  1401. @end menu
  1402. @node list dir
  1403. @unnumberedsubsec Listing the Contents of a Stored Directory
  1404. @UNREVISED
  1405. @FIXME{i changed the order of these nodes around and haven't had a
  1406. chance to play around with this node's example, yet. i have to play
  1407. with it and see what it actually does for my own satisfaction, even if
  1408. what it says *is* correct..}
  1409. To get information about the contents of an archived directory,
  1410. use the directory name as a file name argument in conjunction with
  1411. @value{op-list}. To find out file attributes, include the
  1412. @value{op-verbose} option.
  1413. For example, to find out about files in the directory @file{practice}, in
  1414. the archive file @file{music.tar}, type:
  1415. @example
  1416. $ @kbd{tar --list --verbose --file=music.tar practice}
  1417. @end example
  1418. @command{tar} responds:
  1419. @example
  1420. drwxrwxrwx myself user 0 1990-05-31 21:49 practice/
  1421. -rw-rw-rw- myself user 42 1990-05-21 13:29 practice/blues
  1422. -rw-rw-rw- myself user 62 1990-05-23 10:55 practice/folk
  1423. -rw-rw-rw- myself user 40 1990-05-21 13:30 practice/jazz
  1424. -rw-rw-rw- myself user 10240 1990-05-31 21:49 practice/collection.tar
  1425. @end example
  1426. When you use a directory name as a file name argument, @command{tar} acts on
  1427. all the files (including sub-directories) in that directory.
  1428. @node extract
  1429. @section How to Extract Members from an Archive
  1430. @UNREVISED
  1431. @cindex Extraction
  1432. @cindex Retrieving files from an archive
  1433. @cindex Resurrecting files from an archive
  1434. Creating an archive is only half the job---there is no point in storing
  1435. files in an archive if you can't retrieve them. The act of retrieving
  1436. members from an archive so they can be used and manipulated as
  1437. unarchived files again is called @dfn{extraction}. To extract files
  1438. from an archive, use the @value{op-extract} operation. As with
  1439. @value{op-create}, specify the name of the archive with @value{op-file}.
  1440. Extracting an archive does not modify the archive in any way; you can
  1441. extract it multiple times if you want or need to.
  1442. Using @samp{--extract}, you can extract an entire archive, or specific
  1443. files. The files can be directories containing other files, or not. As
  1444. with @value{op-create} and @value{op-list}, you may use the short or the
  1445. long form of the operation without affecting the performance.
  1446. @menu
  1447. * extracting archives::
  1448. * extracting files::
  1449. * extract dir::
  1450. * failing commands::
  1451. @end menu
  1452. @node extracting archives
  1453. @subsection Extracting an Entire Archive
  1454. To extract an entire archive, specify the archive file name only, with
  1455. no individual file names as arguments. For example,
  1456. @example
  1457. $ @kbd{tar -xvf collection.tar}
  1458. @end example
  1459. @noindent
  1460. produces this:
  1461. @example
  1462. -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
  1463. -rw-rw-rw- me user 21 1996-09-23 16:44 blues
  1464. -rw-rw-rw- me user 20 1996-09-23 16:44 folk
  1465. @end example
  1466. @node extracting files
  1467. @subsection Extracting Specific Files
  1468. To extract specific archive members, give their exact member names as
  1469. arguments, as printed by @value{op-list}. If you had mistakenly deleted
  1470. one of the files you had placed in the archive @file{collection.tar}
  1471. earlier (say, @file{blues}), you can extract it from the archive without
  1472. changing the archive's structure. It will be identical to the original
  1473. file @file{blues} that you deleted. @FIXME{check this; will the times,
  1474. permissions, owner, etc be the same, also?}
  1475. First, make sure you are in the @file{practice} directory, and list the
  1476. files in the directory. Now, delete the file, @samp{blues}, and list
  1477. the files in the directory again.
  1478. You can now extract the member @file{blues} from the archive file
  1479. @file{collection.tar} like this:
  1480. @example
  1481. $ @kbd{tar --extract --file=collection.tar blues}
  1482. @end example
  1483. @noindent
  1484. If you list the files in the directory again, you will see that the file
  1485. @file{blues} has been restored, with its original permissions, creation
  1486. times, and owner.@FIXME{This is only accidentally true, but not in
  1487. general. In most cases, one has to be root for restoring the owner, and
  1488. use a special option for restoring permissions. Here, it just happens
  1489. that the restoring user is also the owner of the archived members, and
  1490. that the current @code{umask} is compatible with original permissions.}
  1491. (These parameters will be identical to those which
  1492. the file had when you originally placed it in the archive; any changes
  1493. you may have made before deleting the file from the file system,
  1494. however, will @emph{not} have been made to the archive member.) The
  1495. archive file, @samp{collection.tar}, is the same as it was before you
  1496. extracted @samp{blues}. You can confirm this by running @command{tar} with
  1497. @value{op-list}.
  1498. @FIXME{we hope this will change:}Remember that as with other operations,
  1499. specifying the exact member name is important. @w{@kbd{tar --extract
  1500. --file=bfiles.tar birds}} will fail, because there is no member named
  1501. @file{birds}. To extract the member named @file{./birds}, you must
  1502. specify @w{@kbd{tar --extract --file=bfiles.tar ./birds}}. To find the
  1503. exact member names of the members of an archive, use @value{op-list}
  1504. (@pxref{list}).
  1505. You can extract a file to standard output by combining the above options
  1506. with the @option{--to-stdout} option (@pxref{Writing to Standard
  1507. Output}).
  1508. If you give the @value{op-verbose} option, then @value{op-extract} will
  1509. print the names of the archive members as it extracts them.
  1510. @node extract dir
  1511. @subsection Extracting Files that are Directories
  1512. Extracting directories which are members of an archive is similar to
  1513. extracting other files. The main difference to be aware of is that if
  1514. the extracted directory has the same name as any directory already in
  1515. the working directory, then files in the extracted directory will be
  1516. placed into the directory of the same name. Likewise, if there are
  1517. files in the pre-existing directory with the same names as the members
  1518. which you extract, the files from the extracted archive will replace
  1519. the files already in the working directory (and possible
  1520. subdirectories). This will happen regardless of whether or not the
  1521. files in the working directory were more recent than those extracted.
  1522. However, if a file was stored with a directory name as part of its file
  1523. name, and that directory does not exist under the working directory when
  1524. the file is extracted, @command{tar} will create the directory.
  1525. We can demonstrate how to use @samp{--extract} to extract a directory
  1526. file with an example. Change to the @file{practice} directory if you
  1527. weren't there, and remove the files @file{folk} and @file{jazz}. Then,
  1528. go back to the parent directory and extract the archive
  1529. @file{music.tar}. You may either extract the entire archive, or you may
  1530. extract only the files you just deleted. To extract the entire archive,
  1531. don't give any file names as arguments after the archive name
  1532. @file{music.tar}. To extract only the files you deleted, use the
  1533. following command:
  1534. @example
  1535. $ @kbd{tar -xvf music.tar practice/folk practice/jazz}
  1536. @end example
  1537. @FIXME{need to show tar's response; used verbose above. also, here's a
  1538. good place to demonstrate the -v -v thing. have to write that up
  1539. (should be trivial, but i'm too tired!).}
  1540. @noindent
  1541. Because you created the directory with @file{practice} as part of the
  1542. file names of each of the files by archiving the @file{practice}
  1543. directory as @file{practice}, you must give @file{practice} as part
  1544. of the file names when you extract those files from the archive.
  1545. @FIXME{IMPORTANT! show the final structure, here. figure out what it
  1546. will be.}
  1547. @node failing commands
  1548. @subsection Commands That Will Fail
  1549. Here are some sample commands you might try which will not work, and why
  1550. they won't work.
  1551. If you try to use this command,
  1552. @example
  1553. $ @kbd{tar -xvf music.tar folk jazz}
  1554. @end example
  1555. @noindent
  1556. you will get the following response:
  1557. @example
  1558. tar: folk: Not found in archive
  1559. tar: jazz: Not found in archive
  1560. $
  1561. @end example
  1562. @noindent
  1563. This is because these files were not originally @emph{in} the parent
  1564. directory @file{..}, where the archive is located; they were in the
  1565. @file{practice} directory, and their file names reflect this:
  1566. @example
  1567. $ @kbd{tar -tvf music.tar}
  1568. practice/folk
  1569. practice/jazz
  1570. practice/rock
  1571. @end example
  1572. @FIXME{make sure the above works when going through the examples in
  1573. order...}
  1574. @noindent
  1575. Likewise, if you try to use this command,
  1576. @example
  1577. $ @kbd{tar -tvf music.tar folk jazz}
  1578. @end example
  1579. @noindent
  1580. you would get a similar response. Members with those names are not in the
  1581. archive. You must use the correct member names in order to extract the
  1582. files from the archive.
  1583. If you have forgotten the correct names of the files in the archive,
  1584. use @w{@kbd{tar --list --verbose}} to list them correctly.
  1585. @FIXME{more examples, here? hag thinks it's a good idea.}
  1586. @node going further
  1587. @section Going Further Ahead in this Manual
  1588. @FIXME{need to write up a node here about the things that are going to
  1589. be in the rest of the manual.}
  1590. @node tar invocation
  1591. @chapter Invoking @acronym{GNU} @command{tar}
  1592. @UNREVISED
  1593. This chapter is about how one invokes the @acronym{GNU} @command{tar}
  1594. command, from the command synopsis (@pxref{Synopsis}). There are
  1595. numerous options, and many styles for writing them. One mandatory
  1596. option specifies the operation @command{tar} should perform
  1597. (@pxref{Operation Summary}), other options are meant to detail how
  1598. this operation should be performed (@pxref{Option Summary}).
  1599. Non-option arguments are not always interpreted the same way,
  1600. depending on what the operation is.
  1601. You will find in this chapter everything about option styles and rules for
  1602. writing them (@pxref{Styles}). On the other hand, operations and options
  1603. are fully described elsewhere, in other chapters. Here, you will find
  1604. only synthetic descriptions for operations and options, together with
  1605. pointers to other parts of the @command{tar} manual.
  1606. Some options are so special they are fully described right in this
  1607. chapter. They have the effect of inhibiting the normal operation of
  1608. @command{tar} or else, they globally alter the amount of feedback the user
  1609. receives about what is going on. These are the @value{op-help} and
  1610. @value{op-version} (@pxref{help}), @value{op-verbose} (@pxref{verbose})
  1611. and @value{op-interactive} options (@pxref{interactive}).
  1612. @menu
  1613. * Synopsis::
  1614. * using tar options::
  1615. * Styles::
  1616. * All Options::
  1617. * help::
  1618. * verbose::
  1619. * interactive::
  1620. @end menu
  1621. @node Synopsis
  1622. @section General Synopsis of @command{tar}
  1623. The @acronym{GNU} @command{tar} program is invoked as either one of:
  1624. @example
  1625. @kbd{tar @var{option}@dots{} [@var{name}]@dots{}}
  1626. @kbd{tar @var{letter}@dots{} [@var{argument}]@dots{} [@var{option}]@dots{} [@var{name}]@dots{}}
  1627. @end example
  1628. The second form is for when old options are being used.
  1629. You can use @command{tar} to store files in an archive, to extract them from
  1630. an archive, and to do other types of archive manipulation. The primary
  1631. argument to @command{tar}, which is called the @dfn{operation}, specifies
  1632. which action to take. The other arguments to @command{tar} are either
  1633. @dfn{options}, which change the way @command{tar} performs an operation,
  1634. or file names or archive members, which specify the files or members
  1635. @command{tar} is to act on.
  1636. You can actually type in arguments in any order, even if in this manual
  1637. the options always precede the other arguments, to make examples easier
  1638. to understand. Further, the option stating the main operation mode
  1639. (the @command{tar} main command) is usually given first.
  1640. Each @var{name} in the synopsis above is interpreted as an archive member
  1641. name when the main command is one of @value{op-compare}, @value{op-delete},
  1642. @value{op-extract}, @value{op-list} or @value{op-update}. When naming
  1643. archive members, you must give the exact name of the member in the
  1644. archive, as it is printed by @value{op-list}. For @value{op-append}
  1645. and @value{op-create}, these @var{name} arguments specify the names
  1646. of either files or directory hierarchies to place in the archive.
  1647. These files or hierarchies should already exist in the file system,
  1648. prior to the execution of the @command{tar} command.
  1649. @command{tar} interprets relative file names as being relative to the
  1650. working directory. @command{tar} will make all file names relative
  1651. (by removing leading slashes when archiving or restoring files),
  1652. unless you specify otherwise (using the @value{op-absolute-names}
  1653. option). @value{xref-absolute-names}, for more information about
  1654. @value{op-absolute-names}.
  1655. If you give the name of a directory as either a file name or a member
  1656. name, then @command{tar} acts recursively on all the files and directories
  1657. beneath that directory. For example, the name @file{/} identifies all
  1658. the files in the filesystem to @command{tar}.
  1659. The distinction between file names and archive member names is especially
  1660. important when shell globbing is used, and sometimes a source of confusion
  1661. for newcomers. @xref{Wildcards}, for more information about globbing.
  1662. The problem is that shells may only glob using existing files in the
  1663. file system. Only @command{tar} itself may glob on archive members, so when
  1664. needed, you must ensure that wildcard characters reach @command{tar} without
  1665. being interpreted by the shell first. Using a backslash before @samp{*}
  1666. or @samp{?}, or putting the whole argument between quotes, is usually
  1667. sufficient for this.
  1668. Even if @var{name}s are often specified on the command line, they
  1669. can also be read from a text file in the file system, using the
  1670. @value{op-files-from} option.
  1671. If you don't use any file name arguments, @value{op-append},
  1672. @value{op-delete} and @value{op-concatenate} will do nothing, while
  1673. @value{op-create} will usually yield a diagnostic and inhibit @command{tar}
  1674. execution. The other operations of @command{tar} (@value{op-list},
  1675. @value{op-extract}, @value{op-compare}, and @value{op-update}) will act
  1676. on the entire contents of the archive.
  1677. @cindex exit status
  1678. @cindex return status
  1679. Besides successful exits, @acronym{GNU} @command{tar} may fail for
  1680. many reasons. Some reasons correspond to bad usage, that is, when the
  1681. @command{tar} command is improperly written. Errors may be
  1682. encountered later, while encountering an error processing the archive
  1683. or the files. Some errors are recoverable, in which case the failure
  1684. is delayed until @command{tar} has completed all its work. Some
  1685. errors are such that it would not meaningful, or at least risky, to
  1686. continue processing: @command{tar} then aborts processing immediately.
  1687. All abnormal exits, whether immediate or delayed, should always be
  1688. clearly diagnosed on @code{stderr}, after a line stating the nature of
  1689. the error.
  1690. @acronym{GNU} @command{tar} returns only a few exit statuses. I'm really
  1691. aiming simplicity in that area, for now. If you are not using the
  1692. @value{op-compare} option, zero means that everything went well, besides
  1693. maybe innocuous warnings. Nonzero means that something went wrong.
  1694. Right now, as of today, ``nonzero'' is almost always 2, except for
  1695. remote operations, where it may be 128.
  1696. @node using tar options
  1697. @section Using @command{tar} Options
  1698. @acronym{GNU} @command{tar} has a total of eight operating modes which
  1699. allow you to perform a variety of tasks. You are required to choose
  1700. one operating mode each time you employ the @command{tar} program by
  1701. specifying one, and only one operation as an argument to the
  1702. @command{tar} command (two lists of four operations each may be found
  1703. at @ref{frequent operations} and @ref{Operations}). Depending on
  1704. circumstances, you may also wish to customize how the chosen operating
  1705. mode behaves. For example, you may wish to change the way the output
  1706. looks, or the format of the files that you wish to archive may require
  1707. you to do something special in order to make the archive look right.
  1708. You can customize and control @command{tar}'s performance by running
  1709. @command{tar} with one or more options (such as @value{op-verbose}, which
  1710. we used in the tutorial). As we said in the tutorial, @dfn{options} are
  1711. arguments to @command{tar} which are (as their name suggests) optional.
  1712. Depending on the operating mode, you may specify one or more options.
  1713. Different options will have different effects, but in general they all
  1714. change details of the operation, such as archive format, archive name,
  1715. or level of user interaction. Some options make sense with all
  1716. operating modes, while others are meaningful only with particular modes.
  1717. You will likely use some options frequently, while you will only use
  1718. others infrequently, or not at all. (A full list of options is
  1719. available in @pxref{All Options}.)
  1720. The @env{TAR_OPTIONS} environment variable specifies default options to
  1721. be placed in front of any explicit options. For example, if
  1722. @code{TAR_OPTIONS} is @samp{-v --unlink-first}, @command{tar} behaves as
  1723. if the two options @option{-v} and @option{--unlink-first} had been
  1724. specified before any explicit options. Option specifications are
  1725. separated by whitespace. A backslash escapes the next character, so it
  1726. can be used to specify an option containing whitespace or a backslash.
  1727. Note that @command{tar} options are case sensitive. For example, the
  1728. options @samp{-T} and @samp{-t} are different; the first requires an
  1729. argument for stating the name of a file providing a list of @var{name}s,
  1730. while the second does not require an argument and is another way to
  1731. write @value{op-list}.
  1732. In addition to the eight operations, there are many options to
  1733. @command{tar}, and three different styles for writing both: long (mnemonic)
  1734. form, short form, and old style. These styles are discussed below.
  1735. Both the options and the operations can be written in any of these three
  1736. styles.
  1737. @FIXME{menu at end of this node. need to think of an actual outline
  1738. for this chapter; probably do that after stuff from chap. 4 is
  1739. incorporated.}
  1740. @node Styles
  1741. @section The Three Option Styles
  1742. There are three styles for writing operations and options to the command
  1743. line invoking @command{tar}. The different styles were developed at
  1744. different times during the history of @command{tar}. These styles will be
  1745. presented below, from the most recent to the oldest.
  1746. Some options must take an argument. (For example, @value{op-file} takes
  1747. the name of an archive file as an argument. If you do not supply an
  1748. archive file name, @command{tar} will use a default, but this can be
  1749. confusing; thus, we recommend that you always supply a specific archive
  1750. file name.) Where you @emph{place} the arguments generally depends on
  1751. which style of options you choose. We will detail specific information
  1752. relevant to each option style in the sections on the different option
  1753. styles, below. The differences are subtle, yet can often be very
  1754. important; incorrect option placement can cause you to overwrite a
  1755. number of important files. We urge you to note these differences, and
  1756. only use the option style(s) which makes the most sense to you until you
  1757. feel comfortable with the others.
  1758. @FIXME{hag to write a brief paragraph on the option(s) which can
  1759. optionally take an argument}
  1760. @menu
  1761. * Mnemonic Options:: Mnemonic Option Style
  1762. * Short Options:: Short Option Style
  1763. * Old Options:: Old Option Style
  1764. * Mixing:: Mixing Option Styles
  1765. @end menu
  1766. @node Mnemonic Options
  1767. @subsection Mnemonic Option Style
  1768. @FIXME{have to decide whether or ot to replace other occurrences of
  1769. "mnemonic" with "long", or *ugh* vice versa.}
  1770. Each option has at least one long (or mnemonic) name starting with two
  1771. dashes in a row, e.g.@: @samp{--list}. The long names are more clear than
  1772. their corresponding short or old names. It sometimes happens that a
  1773. single mnemonic option has many different different names which are
  1774. synonymous, such as @samp{--compare} and @samp{--diff}. In addition,
  1775. long option names can be given unique abbreviations. For example,
  1776. @samp{--cre} can be used in place of @samp{--create} because there is no
  1777. other mnemonic option which begins with @samp{cre}. (One way to find
  1778. this out is by trying it and seeing what happens; if a particular
  1779. abbreviation could represent more than one option, @command{tar} will tell
  1780. you that that abbreviation is ambiguous and you'll know that that
  1781. abbreviation won't work. You may also choose to run @samp{tar --help}
  1782. to see a list of options. Be aware that if you run @command{tar} with a
  1783. unique abbreviation for the long name of an option you didn't want to
  1784. use, you are stuck; @command{tar} will perform the command as ordered.)
  1785. Mnemonic options are meant to be obvious and easy to remember, and their
  1786. meanings are generally easier to discern than those of their
  1787. corresponding short options (see below). For example:
  1788. @example
  1789. $ @kbd{tar --create --verbose --blocking-factor=20 --file=/dev/rmt0}
  1790. @end example
  1791. @noindent
  1792. gives a fairly good set of hints about what the command does, even
  1793. for those not fully acquainted with @command{tar}.
  1794. Mnemonic options which require arguments take those arguments
  1795. immediately following the option name; they are introduced by an equal
  1796. sign. For example, the @samp{--file} option (which tells the name
  1797. of the @command{tar} archive) is given a file such as @file{archive.tar}
  1798. as argument by using the notation @samp{--file=archive.tar} for the
  1799. mnemonic option.
  1800. @node Short Options
  1801. @subsection Short Option Style
  1802. Most options also have a short option name. Short options start with
  1803. a single dash, and are followed by a single character, e.g.@: @samp{-t}
  1804. (which is equivalent to @samp{--list}). The forms are absolutely
  1805. identical in function; they are interchangeable.
  1806. The short option names are faster to type than long option names.
  1807. Short options which require arguments take their arguments immediately
  1808. following the option, usually separated by white space. It is also
  1809. possible to stick the argument right after the short option name, using
  1810. no intervening space. For example, you might write @w{@samp{-f
  1811. archive.tar}} or @samp{-farchive.tar} instead of using
  1812. @samp{--file=archive.tar}. Both @samp{--file=@var{archive-name}} and
  1813. @w{@samp{-f @var{archive-name}}} denote the option which indicates a
  1814. specific archive, here named @file{archive.tar}.
  1815. Short options' letters may be clumped together, but you are not
  1816. required to do this (as compared to old options; see below). When
  1817. short options are clumped as a set, use one (single) dash for them
  1818. all, e.g.@: @w{@samp{@command{tar} -cvf}}. Only the last option in
  1819. such a set is allowed to have an argument@footnote{Clustering many
  1820. options, the last of which has an argument, is a rather opaque way to
  1821. write options. Some wonder if @acronym{GNU} @code{getopt} should not
  1822. even be made helpful enough for considering such usages as invalid.}.
  1823. When the options are separated, the argument for each option which requires
  1824. an argument directly follows that option, as is usual for Unix programs.
  1825. For example:
  1826. @example
  1827. $ @kbd{tar -c -v -b 20 -f /dev/rmt0}
  1828. @end example
  1829. If you reorder short options' locations, be sure to move any arguments
  1830. that belong to them. If you do not move the arguments properly, you may
  1831. end up overwriting files.
  1832. @node Old Options
  1833. @subsection Old Option Style
  1834. @UNREVISED
  1835. Like short options, old options are single letters. However, old options
  1836. must be written together as a single clumped set, without spaces separating
  1837. them or dashes preceding them@footnote{Beware that if you precede options
  1838. with a dash, you are announcing the short option style instead of the
  1839. old option style; short options are decoded differently.}. This set
  1840. of letters must be the first to appear on the command line, after the
  1841. @command{tar} program name and some white space; old options cannot appear
  1842. anywhere else. The letter of an old option is exactly the same letter as
  1843. the corresponding short option. For example, the old option @samp{t} is
  1844. the same as the short option @samp{-t}, and consequently, the same as the
  1845. mnemonic option @samp{--list}. So for example, the command @w{@samp{tar
  1846. cv}} specifies the option @samp{-v} in addition to the operation @samp{-c}.
  1847. @FIXME{bob suggests having an uglier example. :-) }
  1848. When options that need arguments are given together with the command,
  1849. all the associated arguments follow, in the same order as the options.
  1850. Thus, the example given previously could also be written in the old
  1851. style as follows:
  1852. @example
  1853. $ @kbd{tar cvbf 20 /dev/rmt0}
  1854. @end example
  1855. @noindent
  1856. Here, @samp{20} is the argument of @samp{-b} and @samp{/dev/rmt0} is
  1857. the argument of @samp{-f}.
  1858. On the other hand, this old style syntax makes it difficult to match
  1859. option letters with their corresponding arguments, and is often
  1860. confusing. In the command @w{@samp{tar cvbf 20 /dev/rmt0}}, for example,
  1861. @samp{20} is the argument for @samp{-b}, @samp{/dev/rmt0} is the
  1862. argument for @samp{-f}, and @samp{-v} does not have a corresponding
  1863. argument. Even using short options like in @w{@samp{tar -c -v -b 20 -f
  1864. /dev/rmt0}} is clearer, putting all arguments next to the option they
  1865. pertain to.
  1866. If you want to reorder the letters in the old option argument, be
  1867. sure to reorder any corresponding argument appropriately.
  1868. This old way of writing @command{tar} options can surprise even experienced
  1869. users. For example, the two commands:
  1870. @example
  1871. @kbd{tar cfz archive.tar.gz file}
  1872. @kbd{tar -cfz archive.tar.gz file}
  1873. @end example
  1874. @noindent
  1875. are quite different. The first example uses @file{archive.tar.gz} as
  1876. the value for option @samp{f} and recognizes the option @samp{z}. The
  1877. second example, however, uses @file{z} as the value for option
  1878. @samp{f}---probably not what was intended.
  1879. Old options are kept for compatibility with old versions of @command{tar}.
  1880. This second example could be corrected in many ways, among which the
  1881. following are equivalent:
  1882. @example
  1883. @kbd{tar -czf archive.tar.gz file}
  1884. @kbd{tar -cf archive.tar.gz -z file}
  1885. @kbd{tar cf archive.tar.gz -z file}
  1886. @end example
  1887. @FIXME{still could explain this better; it's redundant:}
  1888. @cindex option syntax, traditional
  1889. As far as we know, all @command{tar} programs, @acronym{GNU} and
  1890. non-@acronym{GNU}, support old options. @acronym{GNU} @command{tar}
  1891. supports them not only for historical reasons, but also because many
  1892. people are used to them. For compatibility with Unix @command{tar},
  1893. the first argument is always treated as containing command and option
  1894. letters even if it doesn't start with @samp{-}. Thus, @samp{tar c} is
  1895. equivalent to @w{@samp{tar -c}:} both of them specify the
  1896. @value{op-create} command to create an archive.
  1897. @node Mixing
  1898. @subsection Mixing Option Styles
  1899. All three styles may be intermixed in a single @command{tar} command,
  1900. so long as the rules for each style are fully
  1901. respected@footnote{Before @acronym{GNU} @command{tar} version 1.11.6,
  1902. a bug prevented intermixing old style options with mnemonic options in
  1903. some cases.}. Old style options and either of the modern styles of
  1904. options may be mixed within a single @command{tar} command. However,
  1905. old style options must be introduced as the first arguments only,
  1906. following the rule for old options (old options must appear directly
  1907. after the @command{tar} command and some white space). Modern options
  1908. may be given only after all arguments to the old options have been
  1909. collected. If this rule is not respected, a modern option might be
  1910. falsely interpreted as the value of the argument to one of the old
  1911. style options.
  1912. For example, all the following commands are wholly equivalent, and
  1913. illustrate the many combinations and orderings of option styles.
  1914. @example
  1915. @kbd{tar --create --file=archive.tar}
  1916. @kbd{tar --create -f archive.tar}
  1917. @kbd{tar --create -farchive.tar}
  1918. @kbd{tar --file=archive.tar --create}
  1919. @kbd{tar --file=archive.tar -c}
  1920. @kbd{tar -c --file=archive.tar}
  1921. @kbd{tar -c -f archive.tar}
  1922. @kbd{tar -c -farchive.tar}
  1923. @kbd{tar -cf archive.tar}
  1924. @kbd{tar -cfarchive.tar}
  1925. @kbd{tar -f archive.tar --create}
  1926. @kbd{tar -f archive.tar -c}
  1927. @kbd{tar -farchive.tar --create}
  1928. @kbd{tar -farchive.tar -c}
  1929. @kbd{tar c --file=archive.tar}
  1930. @kbd{tar c -f archive.tar}
  1931. @kbd{tar c -farchive.tar}
  1932. @kbd{tar cf archive.tar}
  1933. @kbd{tar f archive.tar --create}
  1934. @kbd{tar f archive.tar -c}
  1935. @kbd{tar fc archive.tar}
  1936. @end example
  1937. On the other hand, the following commands are @emph{not} equivalent to
  1938. the previous set:
  1939. @example
  1940. @kbd{tar -f -c archive.tar}
  1941. @kbd{tar -fc archive.tar}
  1942. @kbd{tar -fcarchive.tar}
  1943. @kbd{tar -farchive.tarc}
  1944. @kbd{tar cfarchive.tar}
  1945. @end example
  1946. @noindent
  1947. These last examples mean something completely different from what the
  1948. user intended (judging based on the example in the previous set which
  1949. uses long options, whose intent is therefore very clear). The first
  1950. four specify that the @command{tar} archive would be a file named
  1951. @samp{-c}, @samp{c}, @samp{carchive.tar} or @samp{archive.tarc},
  1952. respectively. The first two examples also specify a single non-option,
  1953. @var{name} argument having the value @samp{archive.tar}. The last
  1954. example contains only old style option letters (repeating option
  1955. @samp{c} twice), not all of which are meaningful (eg., @samp{.},
  1956. @samp{h}, or @samp{i}), with no argument value. @FIXME{not sure i liked
  1957. the first sentence of this paragraph..}
  1958. @node All Options
  1959. @section All @command{tar} Options
  1960. The coming manual sections contain an alphabetical listing of all
  1961. @command{tar} operations and options, with brief descriptions and cross
  1962. references to more in-depth explanations in the body of the manual.
  1963. They also contain an alphabetically arranged table of the short option
  1964. forms with their corresponding long option. You can use this table as
  1965. a reference for deciphering @command{tar} commands in scripts.
  1966. @menu
  1967. * Operation Summary::
  1968. * Option Summary::
  1969. * Short Option Summary::
  1970. @end menu
  1971. @node Operation Summary
  1972. @subsection Operations
  1973. @table @kbd
  1974. @item --append
  1975. @itemx -r
  1976. Appends files to the end of the archive. @xref{append}.
  1977. @item --catenate
  1978. @itemx -A
  1979. Same as @samp{--concatenate}. @xref{concatenate}.
  1980. @item --compare
  1981. @itemx -d
  1982. Compares archive members with their counterparts in the file
  1983. system, and reports differences in file size, mode, owner,
  1984. modification date and contents. @xref{compare}.
  1985. @item --concatenate
  1986. @itemx -A
  1987. Appends other @command{tar} archives to the end of the archive.
  1988. @xref{concatenate}.
  1989. @item --create
  1990. @itemx -c
  1991. Creates a new @command{tar} archive. @xref{create}.
  1992. @item --delete
  1993. Deletes members from the archive. Don't try this on a archive on a
  1994. tape! @xref{delete}.
  1995. @item --diff
  1996. @itemx -d
  1997. Same @samp{--compare}. @xref{compare}.
  1998. @item --extract
  1999. @itemx -x
  2000. Extracts members from the archive into the file system. @xref{extract}.
  2001. @item --get
  2002. @itemx -x
  2003. Same as @samp{--extract}. @xref{extract}.
  2004. @item --list
  2005. @itemx -t
  2006. Lists the members in an archive. @xref{list}.
  2007. @item --update
  2008. @itemx -u
  2009. @FIXME{It was: A combination of the @samp{--compare} and
  2010. @samp{--append} operations. This is not true and rather misleading,
  2011. as @value{op-compare} does a lot more than @value{op-update} for
  2012. ensuring files are identical.} Adds files to the end of the archive,
  2013. but only if they are newer than their counterparts already in the
  2014. archive, or if they do not already exist in the archive.
  2015. @xref{update}.
  2016. @end table
  2017. @node Option Summary
  2018. @subsection @command{tar} Options
  2019. @table @kbd
  2020. @item --absolute-names
  2021. @itemx -P
  2022. Normally when creating an archive, @command{tar} strips an initial
  2023. @samp{/} from member names. This option disables that behavior.
  2024. @FIXME-xref{}
  2025. @item --after-date
  2026. (See @samp{--newer}.) @FIXME-pxref{}
  2027. @item --anchored
  2028. An exclude pattern must match an initial subsequence of the name's components.
  2029. @FIXME-xref{}
  2030. @item --atime-preserve
  2031. Tells @command{tar} to preserve the access time field in a file's inode when
  2032. reading it. Due to limitations in the @code{utimes} system call, the
  2033. modification time field is also preserved, which may cause problems if
  2034. the file is simultaneously being modified by another program.
  2035. This option is incompatible with incremental backups, because
  2036. preserving the access time involves updating the last-changed time.
  2037. Also, this option does not work on files that you do not own,
  2038. unless you're root.
  2039. @FIXME-xref{}
  2040. @item --backup=@var{backup-type}
  2041. Rather than deleting files from the file system, @command{tar} will
  2042. back them up using simple or numbered backups, depending upon
  2043. @var{backup-type}. @FIXME-xref{}
  2044. @item --block-number
  2045. @itemx -R
  2046. With this option present, @command{tar} prints error messages for read errors
  2047. with the block number in the archive file. @FIXME-xref{}
  2048. @item --blocking-factor=@var{blocking}
  2049. @itemx -b @var{blocking}
  2050. Sets the blocking factor @command{tar} uses to @var{blocking} x 512 bytes per
  2051. record. @FIXME-xref{}
  2052. @item --bzip2
  2053. @itemx -j
  2054. This option tells @command{tar} to read or write archives through
  2055. @code{bzip2}. @FIXME-xref{}
  2056. @item --checkpoint
  2057. This option directs @command{tar} to print periodic checkpoint messages as it
  2058. reads through the archive. Its intended for when you want a visual
  2059. indication that @command{tar} is still running, but don't want to see
  2060. @samp{--verbose} output. @FIXME-xref{}
  2061. @item --check-links
  2062. If this option was given, @command{tar} will check the number of links
  2063. dumped for each processed file. If this number does not match the
  2064. total number of hard links for the file, a warning message will be
  2065. output.
  2066. @item --compress
  2067. @itemx --uncompress
  2068. @itemx -Z
  2069. @command{tar} will use the @command{compress} program when reading or
  2070. writing the archive. This allows you to directly act on archives
  2071. while saving space. @FIXME-xref{}
  2072. @item --confirmation
  2073. (See @samp{--interactive}.) @FIXME-pxref{}
  2074. @item --dereference
  2075. @itemx -h
  2076. When creating a @command{tar} archive, @command{tar} will archive the
  2077. file that a symbolic link points to, rather than archiving the
  2078. symlink. @FIXME-xref{}
  2079. @item --directory=@var{dir}
  2080. @itemx -C @var{dir}
  2081. When this option is specified, @command{tar} will change its current directory
  2082. to @var{dir} before performing any operations. When this option is used
  2083. during archive creation, it is order sensitive. @FIXME-xref{}
  2084. @item --exclude=@var{pattern}
  2085. When performing operations, @command{tar} will skip files that match
  2086. @var{pattern}. @FIXME-xref{}
  2087. @item --exclude-from=@var{file}
  2088. @itemx -X @var{file}
  2089. Similar to @samp{--exclude}, except @command{tar} will use the list of
  2090. patterns in the file @var{file}. @FIXME-xref{}
  2091. @item --file=@var{archive}
  2092. @itemx -f @var{archive}
  2093. @command{tar} will use the file @var{archive} as the @command{tar} archive it
  2094. performs operations on, rather than @command{tar}'s compilation dependent
  2095. default. @FIXME-xref{}
  2096. @item --files-from=@var{file}
  2097. @itemx -T @var{file}
  2098. @command{tar} will use the contents of @var{file} as a list of archive members
  2099. or files to operate on, in addition to those specified on the
  2100. command-line. @FIXME-xref{}
  2101. @item --force-local
  2102. Forces @command{tar} to interpret the filename given to @samp{--file}
  2103. as a local file, even if it looks like a remote tape drive name.
  2104. @FIXME-xref{}
  2105. @item --group=@var{group}
  2106. Files added to the @command{tar} archive will have a group id of @var{group},
  2107. rather than the group from the source file. @var{group} is first decoded
  2108. as a group symbolic name, but if this interpretation fails, it has to be
  2109. a decimal numeric group ID. @FIXME-xref{}
  2110. Also see the comments for the @value{op-owner} option.
  2111. @item --gunzip
  2112. (See @samp{--gzip}.) @FIXME-pxref{}
  2113. @item --gzip
  2114. @itemx --gunzip
  2115. @itemx --ungzip
  2116. @itemx -z
  2117. This option tells @command{tar} to read or write archives through
  2118. @command{gzip}, allowing @command{tar} to directly operate on several
  2119. kinds of compressed archives transparently. @FIXME-xref{}
  2120. @item --help
  2121. @command{tar} will print out a short message summarizing the operations and
  2122. options to @command{tar} and exit. @FIXME-xref{}
  2123. @item --ignore-case
  2124. Ignore case when excluding files.
  2125. @FIXME-xref{}
  2126. @item --ignore-failed-read
  2127. Do not exit unsuccessfully merely because an unreadable file was encountered.
  2128. @xref{Reading}.
  2129. @item --ignore-zeros
  2130. @itemx -i
  2131. With this option, @command{tar} will ignore zeroed blocks in the
  2132. archive, which normally signals EOF. @xref{Reading}.
  2133. @item --incremental
  2134. @itemx -G
  2135. Used to inform @command{tar} that it is working with an old
  2136. @acronym{GNU}-format incremental backup archive. It is intended
  2137. primarily for backwards compatibility only. @FIXME-xref{}
  2138. @item --index-file=@var{file}
  2139. Send verbose output to @var{file} instead of to standard output.
  2140. @item --info-script=@var{script-file}
  2141. @itemx --new-volume-script=@var{script-file}
  2142. @itemx -F @var{script-file}
  2143. When @command{tar} is performing multi-tape backups, @var{script-file} is run
  2144. at the end of each tape. If @var{script-file} exits with nonzero status,
  2145. @command{tar} fails immediately. @FIXME-xref{}
  2146. @item --interactive
  2147. @itemx --confirmation
  2148. @itemx -w
  2149. Specifies that @command{tar} should ask the user for confirmation before
  2150. performing potentially destructive options, such as overwriting files.
  2151. @FIXME-xref{}
  2152. @item --keep-old-files
  2153. @itemx -k
  2154. Do not overwrite existing files when extracting files from an archive.
  2155. @xref{Writing}.
  2156. @item --label=@var{name}
  2157. @itemx -V @var{name}
  2158. When creating an archive, instructs @command{tar} to write @var{name}
  2159. as a name record in the archive. When extracting or listing archives,
  2160. @command{tar} will only operate on archives that have a label matching
  2161. the pattern specified in @var{name}. @FIXME-xref{}
  2162. @item --listed-incremental=@var{snapshot-file}
  2163. @itemx -g @var{snapshot-file}
  2164. During a @samp{--create} operation, specifies that the archive that
  2165. @command{tar} creates is a new @acronym{GNU}-format incremental
  2166. backup, using @var{snapshot-file} to determine which files to backup.
  2167. With other operations, informs @command{tar} that the archive is in
  2168. incremental format. @FIXME-xref{}
  2169. @item --mode=@var{permissions}
  2170. When adding files to an archive, @command{tar} will use
  2171. @var{permissions} for the archive members, rather than the permissions
  2172. from the files. The program @command{chmod} and this @command{tar}
  2173. option share the same syntax for what @var{permissions} might be.
  2174. @xref{File permissions, Permissions, File permissions, fileutils,
  2175. @acronym{GNU} file utilities}. This reference also has useful
  2176. information for those not being overly familiar with the Unix
  2177. permission system.
  2178. Of course, @var{permissions} might be plainly specified as an octal number.
  2179. However, by using generic symbolic modifications to mode bits, this allows
  2180. more flexibility. For example, the value @samp{a+rw} adds read and write
  2181. permissions for everybody, while retaining executable bits on directories
  2182. or on any other file already marked as executable.
  2183. @item --multi-volume
  2184. @itemx -M
  2185. Informs @command{tar} that it should create or otherwise operate on a
  2186. multi-volume @command{tar} archive. @FIXME-xref{}
  2187. @item --new-volume-script
  2188. (see --info-script)
  2189. @item --newer=@var{date}
  2190. @itemx --after-date=@var{date}
  2191. @itemx -N
  2192. When creating an archive, @command{tar} will only add files that have changed
  2193. since @var{date}. If @var{date} begins with @samp{/} or @samp{.}, it
  2194. is taken to be the name of a file whose last-modified time specifies
  2195. the date. @FIXME-xref{}
  2196. @item --newer-mtime=@var{date}
  2197. Like @samp{--newer}, but add only files whose
  2198. contents have changed (as opposed to just @samp{--newer}, which will
  2199. also back up files for which any status information has changed).
  2200. @item --no-anchored
  2201. An exclude pattern can match any subsequence of the name's components.
  2202. @FIXME-xref{}
  2203. @item --no-ignore-case
  2204. Use case-sensitive matching when excluding files.
  2205. @FIXME-xref{}
  2206. @item --no-recursion
  2207. With this option, @command{tar} will not recurse into directories.
  2208. @FIXME-xref{}
  2209. @item --no-same-owner
  2210. When extracting an archive, do not attempt to preserve the owner
  2211. specified in the @command{tar} archive. This the default behavior
  2212. for ordinary users; this option has an effect only for the superuser.
  2213. @item --no-same-permissions
  2214. When extracting an archive, subtract the user's umask from files from
  2215. the permissions specified in the archive. This is the default behavior
  2216. for ordinary users; this option has an effect only for the superuser.
  2217. @item --no-wildcards
  2218. Do not use wildcards when excluding files.
  2219. @FIXME-xref{}
  2220. @item --no-wildcards-match-slash
  2221. Wildcards do not match @samp{/} when excluding files.
  2222. @FIXME-xref{}
  2223. @item --null
  2224. When @command{tar} is using the @samp{--files-from} option, this option
  2225. instructs @command{tar} to expect filenames terminated with @kbd{NUL}, so
  2226. @command{tar} can correctly work with file names that contain newlines.
  2227. @FIXME-xref{}
  2228. @item --numeric-owner
  2229. This option will notify @command{tar} that it should use numeric user
  2230. and group IDs when creating a @command{tar} file, rather than names.
  2231. @FIXME-xref{}
  2232. @item --old-archive
  2233. (See @samp{--portability}.) @FIXME-pxref{}
  2234. @item --one-file-system
  2235. @itemx -l
  2236. Used when creating an archive. Prevents @command{tar} from recursing into
  2237. directories that are on different file systems from the current
  2238. directory. @FIXME-xref{}
  2239. @item --overwrite
  2240. Overwrite existing files and directory metadata when extracting files
  2241. from an archive. @xref{Overwrite Old Files}.
  2242. @item --overwrite-dir
  2243. Overwrite the metadata of existing directories when extracting files
  2244. from an archive. @xref{Overwrite Old Files}.
  2245. @item --owner=@var{user}
  2246. Specifies that @command{tar} should use @var{user} as the owner of members
  2247. when creating archives, instead of the user associated with the source
  2248. file. @var{user} is first decoded as a user symbolic name, but if
  2249. this interpretation fails, it has to be a decimal numeric user ID.
  2250. @FIXME-xref{}
  2251. There is no value indicating a missing number, and @samp{0} usually means
  2252. @code{root}. Some people like to force @samp{0} as the value to offer in
  2253. their distributions for the owner of files, because the @code{root} user is
  2254. anonymous anyway, so that might as well be the owner of anonymous archives.
  2255. This option does not affect extraction from archives.
  2256. @item --portability
  2257. @itemx --old-archive
  2258. @itemx -o
  2259. Tells @command{tar} to create an archive that is compatible with Unix V7
  2260. @command{tar}. @FIXME-xref{}
  2261. @item --posix
  2262. Instructs @command{tar} to create a @sc{posix} compliant @command{tar}
  2263. archive. @FIXME-xref{}
  2264. @item --preserve
  2265. Synonymous with specifying both @samp{--preserve-permissions} and
  2266. @samp{--same-order}. @FIXME-xref{}
  2267. @item --preserve-order
  2268. (See @samp{--same-order}; @pxref{Reading}.)
  2269. @item --preserve-permissions
  2270. @itemx --same-permissions
  2271. @itemx -p
  2272. When @command{tar} is extracting an archive, it normally subtracts the
  2273. users' umask from the permissions specified in the archive and uses
  2274. that number as the permissions to create the destination file.
  2275. Specifying this option instructs @command{tar} that it should use the
  2276. permissions directly from the archive. @xref{Writing}.
  2277. @item --read-full-records
  2278. @itemx -B
  2279. Specifies that @command{tar} should reblock its input, for reading
  2280. from pipes on systems with buggy implementations. @xref{Reading}.
  2281. @item --record-size=@var{size}
  2282. Instructs @command{tar} to use @var{size} bytes per record when accessing the
  2283. archive. @FIXME-xref{}
  2284. @item --recursion
  2285. With this option, @command{tar} recurses into directories.
  2286. @FIXME-xref{}
  2287. @item --recursive-unlink
  2288. Remove existing
  2289. directory hierarchies before extracting directories of the same name
  2290. from the archive. @xref{Writing}.
  2291. @item --remove-files
  2292. Directs @command{tar} to remove the source file from the file system after
  2293. appending it to an archive. @FIXME-xref{}
  2294. @item --rsh-command=@var{cmd}
  2295. Notifies @command{tar} that is should use @var{cmd} to communicate with remote
  2296. devices. @FIXME-xref{}
  2297. @item --same-order
  2298. @itemx --preserve-order
  2299. @itemx -s
  2300. This option is an optimization for @command{tar} when running on machines with
  2301. small amounts of memory. It informs @command{tar} that the list of file
  2302. arguments has already been sorted to match the order of files in the
  2303. archive. @xref{Reading}.
  2304. @item --same-owner
  2305. When extracting an archive, @command{tar} will attempt to preserve the owner
  2306. specified in the @command{tar} archive with this option present.
  2307. This is the default behavior for the superuser; this option has an
  2308. effect only for ordinary users. @FIXME-xref{}
  2309. @item --same-permissions
  2310. (See @samp{--preserve-permissions}; @pxref{Writing}.)
  2311. @item --show-omitted-dirs
  2312. Instructs @command{tar} to mention directories its skipping over when
  2313. operating on a @command{tar} archive. @FIXME-xref{}
  2314. @item --sparse
  2315. @itemx -S
  2316. Invokes a @acronym{GNU} extension when adding files to an archive that handles
  2317. sparse files efficiently. @FIXME-xref{}
  2318. @item --starting-file=@var{name}
  2319. @itemx -K @var{name}
  2320. This option affects extraction only; @command{tar} will skip extracting
  2321. files in the archive until it finds one that matches @var{name}.
  2322. @xref{Scarce}.
  2323. @item --suffix=@var{suffix}
  2324. Alters the suffix @command{tar} uses when backing up files from the default
  2325. @samp{~}. @FIXME-xref{}
  2326. @item --tape-length=@var{num}
  2327. @itemx -L @var{num}
  2328. Specifies the length of tapes that @command{tar} is writing as being
  2329. @w{@var{num} x 1024} bytes long. @FIXME-xref{}
  2330. @item --to-stdout
  2331. @itemx -O
  2332. During extraction, @command{tar} will extract files to stdout rather
  2333. than to the file system. @xref{Writing}.
  2334. @item --totals
  2335. Displays the total number of bytes written after creating an archive.
  2336. @FIXME-xref{}
  2337. @item --touch
  2338. @itemx -m
  2339. Sets the modification time of extracted files to the extraction time,
  2340. rather than the modification time stored in the archive.
  2341. @xref{Writing}.
  2342. @item --uncompress
  2343. (See @samp{--compress}.) @FIXME-pxref{}
  2344. @item --ungzip
  2345. (See @samp{--gzip}.) @FIXME-pxref{}
  2346. @item --unlink-first
  2347. @itemx -U
  2348. Directs @command{tar} to remove the corresponding file from the file
  2349. system before extracting it from the archive. @xref{Writing}.
  2350. @item --use-compress-program=@var{prog}
  2351. Instructs @command{tar} to access the archive through @var{prog}, which is
  2352. presumed to be a compression program of some sort. @FIXME-xref{}
  2353. @item --verbose
  2354. @itemx -v
  2355. Specifies that @command{tar} should be more verbose about the operations its
  2356. performing. This option can be specified multiple times for some
  2357. operations to increase the amount of information displayed. @FIXME-xref{}
  2358. @item --verify
  2359. @itemx -W
  2360. Verifies that the archive was correctly written when creating an
  2361. archive. @FIXME-xref{}
  2362. @item --version
  2363. @command{tar} will print an informational message about what version
  2364. it is and a copyright message, some credits, and then exit.
  2365. @FIXME-xref{}
  2366. @item --volno-file=@var{file}
  2367. Used in conjunction with @samp{--multi-volume}. @command{tar} will keep track
  2368. of which volume of a multi-volume archive its working in @var{file}.
  2369. @FIXME-xref{}
  2370. @item --wildcards
  2371. Use wildcards when excluding files.
  2372. @FIXME-xref{}
  2373. @item --wildcards-match-slash
  2374. Wildcards match @samp{/} when excluding files.
  2375. @FIXME-xref{}
  2376. @end table
  2377. @node Short Option Summary
  2378. @subsection Short Options Cross Reference
  2379. Here is an alphabetized list of all of the short option forms, matching
  2380. them with the equivalent long option.
  2381. @table @kbd
  2382. @item -A
  2383. @samp{--concatenate}
  2384. @item -B
  2385. @samp{--read-full-records}
  2386. @item -C
  2387. @samp{--directory}
  2388. @item -F
  2389. @samp{--info-script}
  2390. @item -G
  2391. @samp{--incremental}
  2392. @item -K
  2393. @samp{--starting-file}
  2394. @item -L
  2395. @samp{--tape-length}
  2396. @item -M
  2397. @samp{--multi-volume}
  2398. @item -N
  2399. @samp{--newer}
  2400. @item -O
  2401. @samp{--to-stdout}
  2402. @item -P
  2403. @samp{--absolute-names}
  2404. @item -R
  2405. @samp{--block-number}
  2406. @item -S
  2407. @samp{--sparse}
  2408. @item -T
  2409. @samp{--files-from}
  2410. @item -U
  2411. @samp{--unlink-first}
  2412. @item -V
  2413. @samp{--label}
  2414. @item -W
  2415. @samp{--verify}
  2416. @item -X
  2417. @samp{--exclude-from}
  2418. @item -Z
  2419. @samp{--compress}
  2420. @item -b
  2421. @samp{--blocking-factor}
  2422. @item -c
  2423. @samp{--create}
  2424. @item -d
  2425. @samp{--compare}
  2426. @item -f
  2427. @samp{--file}
  2428. @item -g
  2429. @samp{--listed-incremental}
  2430. @item -h
  2431. @samp{--dereference}
  2432. @item -i
  2433. @samp{--ignore-zeros}
  2434. @item -j
  2435. @samp{--bzip2}
  2436. @item -k
  2437. @samp{--keep-old-files}
  2438. @item -l
  2439. @samp{--one-file-system}
  2440. @item -m
  2441. @samp{--touch}
  2442. @item -o
  2443. @samp{--portability}
  2444. @item -p
  2445. @samp{--preserve-permissions}
  2446. @item -r
  2447. @samp{--append}
  2448. @item -s
  2449. @samp{--same-order}
  2450. @item -t
  2451. @samp{--list}
  2452. @item -u
  2453. @samp{--update}
  2454. @item -v
  2455. @samp{--verbose}
  2456. @item -w
  2457. @samp{--interactive}
  2458. @item -x
  2459. @samp{--extract}
  2460. @item -z
  2461. @samp{--gzip}
  2462. @end table
  2463. @node help
  2464. @section @acronym{GNU} @command{tar} documentation
  2465. Being careful, the first thing is really checking that you are using
  2466. @acronym{GNU} @command{tar}, indeed. The @value{op-version} option
  2467. will generate a message giving confirmation that you are using
  2468. @acronym{GNU} @command{tar}, with the precise version of @acronym{GNU}
  2469. @command{tar} you are using. @command{tar} identifies itself and
  2470. prints the version number to the standard output, then immediately
  2471. exits successfully, without doing anything else, ignoring all other
  2472. options. For example, @w{@samp{tar --version}} might return:
  2473. @example
  2474. tar (@acronym{GNU} tar) @value{VERSION}
  2475. @end example
  2476. @noindent
  2477. The first occurrence of @samp{tar} in the result above is the program
  2478. name in the package (for example, @command{rmt} is another program),
  2479. while the second occurrence of @samp{tar} is the name of the package
  2480. itself, containing possibly many programs. The package is currently
  2481. named @samp{tar}, after the name of the main program it
  2482. contains@footnote{There are plans to merge the @command{cpio} and
  2483. @command{tar} packages into a single one which would be called
  2484. @code{paxutils}. So, who knows if, one of this days, the
  2485. @value{op-version} would not yield @w{@samp{tar (@acronym{GNU}
  2486. paxutils) 3.2}}}.
  2487. Another thing you might want to do is checking the spelling or meaning
  2488. of some particular @command{tar} option, without resorting to this
  2489. manual, for once you have carefully read it. @acronym{GNU}
  2490. @command{tar} has a short help feature, triggerable through the
  2491. @value{op-help} option. By using this option, @command{tar} will
  2492. print a usage message listing all available options on standard
  2493. output, then exit successfully, without doing anything else and
  2494. ignoring all other options. Even if this is only a brief summary, it
  2495. may be several screens long. So, if you are not using some kind of
  2496. scrollable window, you might prefer to use something like:
  2497. @example
  2498. $ @kbd{tar --help | less}
  2499. @end example
  2500. @noindent
  2501. presuming, here, that you like using @command{less} for a pager. Other
  2502. popular pagers are @command{more} and @command{pg}. If you know about some
  2503. @var{keyword} which interests you and do not want to read all the
  2504. @value{op-help} output, another common idiom is doing:
  2505. @example
  2506. tar --help | grep @var{keyword}
  2507. @end example
  2508. @noindent
  2509. for getting only the pertinent lines.
  2510. The perceptive reader would have noticed some contradiction in the
  2511. previous paragraphs. It is written that both @value{op-version} and
  2512. @value{op-help} print something, and have all other options ignored. In
  2513. fact, they cannot ignore each other, and one of them has to win. We do
  2514. not specify which is stronger, here; experiment if you really wonder!
  2515. The short help output is quite succinct, and you might have to get
  2516. back to the full documentation for precise points. If you are reading
  2517. this paragraph, you already have the @command{tar} manual in some
  2518. form. This manual is available in printed form, as a kind of small
  2519. book. It may printed out of the @acronym{GNU} @command{tar}
  2520. distribution, provided you have @TeX{} already installed somewhere,
  2521. and a laser printer around. Just configure the distribution, execute
  2522. the command @w{@samp{make dvi}}, then print @file{doc/tar.dvi} the
  2523. usual way (contact your local guru to know how). If @acronym{GNU}
  2524. @command{tar} has been conveniently installed at your place, this
  2525. manual is also available in interactive, hypertextual form as an Info
  2526. file. Just call @w{@samp{info tar}} or, if you do not have the
  2527. @command{info} program handy, use the Info reader provided within
  2528. @acronym{GNU} Emacs, calling @samp{tar} from the main Info menu.
  2529. There is currently no @code{man} page for @acronym{GNU} @command{tar}.
  2530. If you observe such a @code{man} page on the system you are running,
  2531. either it does not long to @acronym{GNU} @command{tar}, or it has not
  2532. been produced by @acronym{GNU}. Currently, @acronym{GNU}
  2533. @command{tar} documentation is provided in Texinfo format only, if we
  2534. except, of course, the short result of @kbd{tar --help}.
  2535. @node verbose
  2536. @section Checking @command{tar} progress
  2537. @cindex Progress information
  2538. @cindex Status information
  2539. @cindex Information on progress and status of operations
  2540. @cindex Verbose operation
  2541. @cindex Block number where error occurred
  2542. @cindex Error message, block number of
  2543. @cindex Version of the @command{tar} program
  2544. @cindex Getting more information during the operation
  2545. @cindex Information during operation
  2546. @cindex Feedback from @command{tar}
  2547. Typically, @command{tar} performs most operations without reporting any
  2548. information to the user except error messages. When using @command{tar}
  2549. with many options, particularly ones with complicated or
  2550. difficult-to-predict behavior, it is possible to make serious mistakes.
  2551. @command{tar} provides several options that make observing @command{tar}
  2552. easier. These options cause @command{tar} to print information as it
  2553. progresses in its job, and you might want to use them just for being
  2554. more careful about what is going on, or merely for entertaining
  2555. yourself. If you have encountered a problem when operating on an
  2556. archive, however, you may need more information than just an error
  2557. message in order to solve the problem. The following options can be
  2558. helpful diagnostic tools.
  2559. Normally, the @value{op-list} command to list an archive prints just
  2560. the file names (one per line) and the other commands are silent.
  2561. When used with most operations, the @value{op-verbose} option causes
  2562. @command{tar} to print the name of each file or archive member as it
  2563. is processed. This and the other options which make @command{tar} print
  2564. status information can be useful in monitoring @command{tar}.
  2565. With @value{op-create} or @value{op-extract}, @value{op-verbose} used once
  2566. just prints the names of the files or members as they are processed.
  2567. Using it twice causes @command{tar} to print a longer listing (reminiscent
  2568. of @samp{ls -l}) for each member. Since @value{op-list} already prints
  2569. the names of the members, @value{op-verbose} used once with @value{op-list}
  2570. causes @command{tar} to print an @samp{ls -l} type listing of the files
  2571. in the archive. The following examples both extract members with
  2572. long list output:
  2573. @example
  2574. $ @kbd{tar --extract --file=archive.tar --verbose --verbose}
  2575. $ @kbd{tar xvv archive.tar}
  2576. @end example
  2577. Verbose output appears on the standard output except when an archive is
  2578. being written to the standard output, as with @samp{tar --create
  2579. --file=- --verbose} (@samp{tar cfv -}, or even @samp{tar cv}---if the
  2580. installer let standard output be the default archive). In that case
  2581. @command{tar} writes verbose output to the standard error stream.
  2582. If @option{--index-file=@var{file}} is specified, @command{tar} sends
  2583. verbose output to @var{file} rather than to standard output or standard
  2584. error.
  2585. The @value{op-totals} option---which is only meaningful when used with
  2586. @value{op-create}---causes @command{tar} to print the total
  2587. amount written to the archive, after it has been fully created.
  2588. The @value{op-checkpoint} option prints an occasional message
  2589. as @command{tar} reads or writes the archive. In fact, it print
  2590. directory names while reading the archive. It is designed for
  2591. those who don't need the more detailed (and voluminous) output of
  2592. @value{op-block-number}, but do want visual confirmation that @command{tar}
  2593. is actually making forward progress.
  2594. @FIXME{There is some confusion here. It seems that -R once wrote a
  2595. message at @samp{every} record read or written.}
  2596. The @value{op-show-omitted-dirs} option, when reading an archive---with
  2597. @value{op-list} or @value{op-extract}, for example---causes a message
  2598. to be printed for each directory in the archive which is skipped.
  2599. This happens regardless of the reason for skipping: the directory might
  2600. not have been named on the command line (implicitly or explicitly),
  2601. it might be excluded by the use of the @value{op-exclude} option, or
  2602. some other reason.
  2603. If @value{op-block-number} is used, @command{tar} prints, along with
  2604. every message it would normally produce, the block number within the
  2605. archive where the message was triggered. Also, supplementary messages
  2606. are triggered when reading blocks full of NULs, or when hitting end of
  2607. file on the archive. As of now, if the archive if properly terminated
  2608. with a NUL block, the reading of the file may stop before end of file
  2609. is met, so the position of end of file will not usually show when
  2610. @value{op-block-number} is used. Note that @acronym{GNU}
  2611. @command{tar} drains the archive before exiting when reading the
  2612. archive from a pipe.
  2613. This option is especially useful when reading damaged archives, since
  2614. it helps pinpoint the damaged sections. It can also be used with
  2615. @value{op-list} when listing a file-system backup tape, allowing you to
  2616. choose among several backup tapes when retrieving a file later, in
  2617. favor of the tape where the file appears earliest (closest to the
  2618. front of the tape). @FIXME-xref{when the node name is set and the
  2619. backup section written.}
  2620. @node interactive
  2621. @section Asking for Confirmation During Operations
  2622. @cindex Interactive operation
  2623. Typically, @command{tar} carries out a command without stopping for
  2624. further instructions. In some situations however, you may want to
  2625. exclude some files and archive members from the operation (for instance
  2626. if disk or storage space is tight). You can do this by excluding
  2627. certain files automatically (@pxref{Choosing}), or by performing
  2628. an operation interactively, using the @value{op-interactive} option.
  2629. @command{tar} also accepts @samp{--confirmation} for this option.
  2630. When the @value{op-interactive} option is specified, before
  2631. reading, writing, or deleting files, @command{tar} first prints a message
  2632. for each such file, telling what operation it intends to take, then asks
  2633. for confirmation on the terminal. The actions which require
  2634. confirmation include adding a file to the archive, extracting a file
  2635. from the archive, deleting a file from the archive, and deleting a file
  2636. from disk. To confirm the action, you must type a line of input
  2637. beginning with @samp{y}. If your input line begins with anything other
  2638. than @samp{y}, @command{tar} skips that file.
  2639. If @command{tar} is reading the archive from the standard input,
  2640. @command{tar} opens the file @file{/dev/tty} to support the interactive
  2641. communications.
  2642. Verbose output is normally sent to standard output, separate from
  2643. other error messages. However, if the archive is produced directly
  2644. on standard output, then verbose output is mixed with errors on
  2645. @code{stderr}. Producing the archive on standard output may be used
  2646. as a way to avoid using disk space, when the archive is soon to be
  2647. consumed by another process reading it, say. Some people felt the need
  2648. of producing an archive on stdout, still willing to segregate between
  2649. verbose output and error output. A possible approach would be using a
  2650. named pipe to receive the archive, and having the consumer process to
  2651. read from that named pipe. This has the advantage of letting standard
  2652. output free to receive verbose output, all separate from errors.
  2653. @node operations
  2654. @chapter @acronym{GNU} @command{tar} Operations
  2655. @menu
  2656. * Basic tar::
  2657. * Advanced tar::
  2658. * create options::
  2659. * extract options::
  2660. * backup::
  2661. * Applications::
  2662. * looking ahead::
  2663. @end menu
  2664. @node Basic tar
  2665. @section Basic @acronym{GNU} @command{tar} Operations
  2666. The basic @command{tar} operations, @value{op-create}, @value{op-list} and
  2667. @value{op-extract}, are currently presented and described in the tutorial
  2668. chapter of this manual. This section provides some complementary notes
  2669. for these operations.
  2670. @table @asis
  2671. @item @value{op-create}
  2672. Creating an empty archive would have some kind of elegance. One can
  2673. initialize an empty archive and later use @value{op-append} for adding
  2674. all members. Some applications would not welcome making an exception
  2675. in the way of adding the first archive member. On the other hand,
  2676. many people reported that it is dangerously too easy for @command{tar}
  2677. to destroy a magnetic tape with an empty archive@footnote{This is well
  2678. described in @cite{Unix-haters Handbook}, by Simson Garfinkel, Daniel
  2679. Weise & Steven Strassmann, IDG Books, ISBN 1-56884-203-1.}. The two most
  2680. common errors are:
  2681. @enumerate
  2682. @item
  2683. Mistakingly using @code{create} instead of @code{extract}, when the
  2684. intent was to extract the full contents of an archive. This error
  2685. is likely: keys @kbd{c} and @kbd{x} are right next ot each other on
  2686. the QWERTY keyboard. Instead of being unpacked, the archive then
  2687. gets wholly destroyed. When users speak about @dfn{exploding} an
  2688. archive, they usually mean something else :-).
  2689. @item
  2690. Forgetting the argument to @code{file}, when the intent was to create
  2691. an archive with a single file in it. This error is likely because a
  2692. tired user can easily add the @kbd{f} key to the cluster of option
  2693. letters, by the mere force of habit, without realizing the full
  2694. consequence of doing so. The usual consequence is that the single
  2695. file, which was meant to be saved, is rather destroyed.
  2696. @end enumerate
  2697. So, recognizing the likelihood and the catastrophical nature of these
  2698. errors, @acronym{GNU} @command{tar} now takes some distance from elegance, and
  2699. cowardly refuses to create an archive when @value{op-create} option is
  2700. given, there are no arguments besides options, and @value{op-files-from}
  2701. option is @emph{not} used. To get around the cautiousness of @acronym{GNU}
  2702. @command{tar} and nevertheless create an archive with nothing in it,
  2703. one may still use, as the value for the @value{op-files-from} option,
  2704. a file with no names in it, as shown in the following commands:
  2705. @example
  2706. @kbd{tar --create --file=empty-archive.tar --files-from=/dev/null}
  2707. @kbd{tar cfT empty-archive.tar /dev/null}
  2708. @end example
  2709. @item @value{op-extract}
  2710. A socket is stored, within a @acronym{GNU} @command{tar} archive, as a pipe.
  2711. @item @value{op-list}
  2712. @acronym{GNU} @command{tar} now shows dates as @samp{1996-08-30},
  2713. while it used to show them as @samp{Aug 30 1996}. (One can revert to
  2714. the old behavior by defining @code{USE_OLD_CTIME} in @file{src/list.c}
  2715. before reinstalling.) But preferably, people should get used to ISO
  2716. 8601 dates. Local American dates should be made available again with
  2717. full date localization support, once ready. In the meantime, programs
  2718. not being localizable for dates should prefer international dates,
  2719. that's really the way to go.
  2720. Look up @url{http://www.ft.uni-erlangen.de/~mskuhn/iso-time.html} if you
  2721. are curious, it contains a detailed explanation of the ISO 8601 standard.
  2722. @end table
  2723. @node Advanced tar
  2724. @section Advanced @acronym{GNU} @command{tar} Operations
  2725. Now that you have learned the basics of using @acronym{GNU}
  2726. @command{tar}, you may want to learn about further ways in which
  2727. @command{tar} can help you.
  2728. This chapter presents five, more advanced operations which you probably
  2729. won't use on a daily basis, but which serve more specialized functions.
  2730. We also explain the different styles of options and why you might want
  2731. to use one or another, or a combination of them in your @command{tar}
  2732. commands. Additionally, this chapter includes options which allow you to
  2733. define the output from @command{tar} more carefully, and provide help and
  2734. error correction in special circumstances.
  2735. @FIXME{check this after the chapter is actually revised to make sure
  2736. it still introduces the info in the chapter correctly : ).}
  2737. @menu
  2738. * Operations::
  2739. * append::
  2740. * update::
  2741. * concatenate::
  2742. * delete::
  2743. * compare::
  2744. @end menu
  2745. @node Operations
  2746. @subsection The Five Advanced @command{tar} Operations
  2747. @UNREVISED
  2748. In the last chapter, you learned about the first three operations to
  2749. @command{tar}. This chapter presents the remaining five operations to
  2750. @command{tar}: @samp{--append}, @samp{--update}, @samp{--concatenate},
  2751. @samp{--delete}, and @samp{--compare}.
  2752. You are not likely to use these operations as frequently as those
  2753. covered in the last chapter; however, since they perform specialized
  2754. functions, they are quite useful when you do need to use them. We
  2755. will give examples using the same directory and files that you created
  2756. in the last chapter. As you may recall, the directory is called
  2757. @file{practice}, the files are @samp{jazz}, @samp{blues}, @samp{folk},
  2758. @samp{rock}, and the two archive files you created are
  2759. @samp{collection.tar} and @samp{music.tar}.
  2760. We will also use the archive files @samp{afiles.tar} and
  2761. @samp{bfiles.tar}. @samp{afiles.tar} contains the members @samp{apple},
  2762. @samp{angst}, and @samp{aspic}. @samp{bfiles.tar} contains the members
  2763. @samp{./birds}, @samp{baboon}, and @samp{./box}.
  2764. Unless we state otherwise, all practicing you do and examples you follow
  2765. in this chapter will take place in the @file{practice} directory that
  2766. you created in the previous chapter; see @ref{prepare for examples}.
  2767. (Below in this section, we will remind you of the state of the examples
  2768. where the last chapter left them.)
  2769. The five operations that we will cover in this chapter are:
  2770. @table @kbd
  2771. @item --append
  2772. @itemx -r
  2773. Add new entries to an archive that already exists.
  2774. @item --update
  2775. @itemx -r
  2776. Add more recent copies of archive members to the end of an archive, if
  2777. they exist.
  2778. @item --concatenate
  2779. @itemx --catenate
  2780. @itemx -A
  2781. Add one or more pre-existing archives to the end of another archive.
  2782. @item --delete
  2783. Delete items from an archive (does not work on tapes).
  2784. @item --compare
  2785. @itemx --diff
  2786. @itemx -d
  2787. Compare archive members to their counterparts in the file system.
  2788. @end table
  2789. @node append
  2790. @subsection How to Add Files to Existing Archives: @code{--append}
  2791. @UNREVISED
  2792. If you want to add files to an existing archive, you don't need to
  2793. create a new archive; you can use @value{op-append}. The archive must
  2794. already exist in order to use @samp{--append}. (A related operation
  2795. is the @samp{--update} operation; you can use this to add newer
  2796. versions of archive members to an existing archive. To learn how to
  2797. do this with @samp{--update}, @pxref{update}.)
  2798. @FIXME{Explain in second paragraph whether you can get to the previous
  2799. version -- explain whole situation somewhat more clearly.}
  2800. If you use @value{op-append} to add a file that has the same name as an
  2801. archive member to an archive containing that archive member, then the
  2802. old member is not deleted. What does happen, however, is somewhat
  2803. complex. @command{tar} @emph{allows} you to have infinite numbers of files
  2804. with the same name. Some operations treat these same-named members no
  2805. differently than any other set of archive members: for example, if you
  2806. view an archive with @value{op-list}, you will see all of those members
  2807. listed, with their modification times, owners, etc.
  2808. Other operations don't deal with these members as perfectly as you might
  2809. prefer; if you were to use @value{op-extract} to extract the archive,
  2810. only the most recently added copy of a member with the same name as four
  2811. other members would end up in the working directory. This is because
  2812. @samp{--extract} extracts an archive in the order the members appeared
  2813. in the archive; the most recently archived members will be extracted
  2814. last. Additionally, an extracted member will @emph{replace} a file of
  2815. the same name which existed in the directory already, and @command{tar}
  2816. will not prompt you about this. Thus, only the most recently archived
  2817. member will end up being extracted, as it will replace the one
  2818. extracted before it, and so on.
  2819. @FIXME{ hag -- you might want to incorporate some of the above into the
  2820. MMwtSN node; not sure. i didn't know how to make it simpler...}
  2821. There are a few ways to get around this. @FIXME-xref{Multiple Members
  2822. with the Same Name.}
  2823. @cindex Members, replacing with other members
  2824. @cindex Replacing members with other members
  2825. If you want to replace an archive member, use @value{op-delete} to
  2826. delete the member you want to remove from the archive, , and then use
  2827. @samp{--append} to add the member you want to be in the archive. Note
  2828. that you can not change the order of the archive; the most recently
  2829. added member will still appear last. In this sense, you cannot truly
  2830. ``replace'' one member with another. (Replacing one member with another
  2831. will not work on certain types of media, such as tapes; see @ref{delete}
  2832. and @ref{Media}, for more information.)
  2833. @menu
  2834. * appending files:: Appending Files to an Archive
  2835. * multiple::
  2836. @end menu
  2837. @node appending files
  2838. @subsubsection Appending Files to an Archive
  2839. @UNREVISED
  2840. @cindex Adding files to an Archive
  2841. @cindex Appending files to an Archive
  2842. @cindex Archives, Appending files to
  2843. The simplest way to add a file to an already existing archive is the
  2844. @value{op-append} operation, which writes specified files into the
  2845. archive whether or not they are already among the archived files.
  2846. When you use @samp{--append}, you @emph{must} specify file name
  2847. arguments, as there is no default. If you specify a file that already
  2848. exists in the archive, another copy of the file will be added to the
  2849. end of the archive. As with other operations, the member names of the
  2850. newly added files will be exactly the same as their names given on the
  2851. command line. The @value{op-verbose} option will print out the names
  2852. of the files as they are written into the archive.
  2853. @samp{--append} cannot be performed on some tape drives, unfortunately,
  2854. due to deficiencies in the formats those tape drives use. The archive
  2855. must be a valid @command{tar} archive, or else the results of using this
  2856. operation will be unpredictable. @xref{Media}.
  2857. To demonstrate using @samp{--append} to add a file to an archive,
  2858. create a file called @file{rock} in the @file{practice} directory.
  2859. Make sure you are in the @file{practice} directory. Then, run the
  2860. following @command{tar} command to add @file{rock} to
  2861. @file{collection.tar}:
  2862. @example
  2863. $ @kbd{tar --append --file=collection.tar rock}
  2864. @end example
  2865. @noindent
  2866. If you now use the @value{op-list} operation, you will see that
  2867. @file{rock} has been added to the archive:
  2868. @example
  2869. $ @kbd{tar --list --file=collection.tar}
  2870. -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
  2871. -rw-rw-rw- me user 21 1996-09-23 16:44 blues
  2872. -rw-rw-rw- me user 20 1996-09-23 16:44 folk
  2873. -rw-rw-rw- me user 20 1996-09-23 16:44 rock
  2874. @end example
  2875. @FIXME{in theory, dan will (soon) try to turn this node into what it's
  2876. title claims it will become...}
  2877. @node multiple
  2878. @subsubsection Multiple Files with the Same Name
  2879. You can use @value{op-append} to add copies of files which have been
  2880. updated since the archive was created. (However, we do not recommend
  2881. doing this since there is another @command{tar} option called
  2882. @samp{--update}; @pxref{update} for more information. We describe this
  2883. use of @samp{--append} here for the sake of completeness.) @FIXME{is
  2884. this really a good idea, to give this whole description for something
  2885. which i believe is basically a Stupid way of doing something? certain
  2886. aspects of it show ways in which tar is more broken than i'd personally
  2887. like to admit to, specifically the last sentence. On the other hand, i
  2888. don't think it's a good idea to be saying that re explicitly don't
  2889. recommend using something, but i can't see any better way to deal with
  2890. the situation.}When you extract the archive, the older version will be
  2891. effectively lost. This works because files are extracted from an
  2892. archive in the order in which they were archived. Thus, when the
  2893. archive is extracted, a file archived later in time will replace a
  2894. file of the same name which was archived earlier, even though the older
  2895. version of the file will remain in the archive unless you delete all
  2896. versions of the file.
  2897. Supposing you change the file @file{blues} and then append the changed
  2898. version to @file{collection.tar}. As you saw above, the original
  2899. @file{blues} is in the archive @file{collection.tar}. If you change the
  2900. file and append the new version of the file to the archive, there will
  2901. be two copies in the archive. When you extract the archive, the older
  2902. version of the file will be extracted first, and then replaced by the
  2903. newer version when it is extracted.
  2904. You can append the new, changed copy of the file @file{blues} to the
  2905. archive in this way:
  2906. @example
  2907. $ @kbd{tar --append --verbose --file=collection.tar blues}
  2908. blues
  2909. @end example
  2910. @noindent
  2911. Because you specified the @samp{--verbose} option, @command{tar} has
  2912. printed the name of the file being appended as it was acted on. Now
  2913. list the contents of the archive:
  2914. @example
  2915. $ @kbd{tar --list --verbose --file=collection.tar}
  2916. -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
  2917. -rw-rw-rw- me user 21 1996-09-23 16:44 blues
  2918. -rw-rw-rw- me user 20 1996-09-23 16:44 folk
  2919. -rw-rw-rw- me user 20 1996-09-23 16:44 rock
  2920. -rw-rw-rw- me user 58 1996-10-24 18:30 blues
  2921. @end example
  2922. @noindent
  2923. The newest version of @file{blues} is now at the end of the archive
  2924. (note the different creation dates and file sizes). If you extract
  2925. the archive, the older version of the file @file{blues} will be
  2926. replaced by the newer version. You can confirm this by extracting
  2927. the archive and running @samp{ls} on the directory. @xref{Writing},
  2928. for more information. (@emph{Please note:} This is the case unless
  2929. you employ the @value{op-backup} option. @FIXME-ref{Multiple Members
  2930. with the Same Name}.)
  2931. @node update
  2932. @subsection Updating an Archive
  2933. @UNREVISED
  2934. @cindex Updating an archive
  2935. In the previous section, you learned how to use @value{op-append} to add
  2936. a file to an existing archive. A related operation is
  2937. @value{op-update}. The @samp{--update} operation updates a @command{tar}
  2938. archive by comparing the date of the specified archive members against
  2939. the date of the file with the same name. If the file has been modified
  2940. more recently than the archive member, then the newer version of the
  2941. file is added to the archive (as with @value{op-append}).
  2942. Unfortunately, you cannot use @samp{--update} with magnetic tape drives.
  2943. The operation will fail.
  2944. @FIXME{other examples of media on which --update will fail? need to ask
  2945. charles and/or mib/thomas/dave shevett..}
  2946. Both @samp{--update} and @samp{--append} work by adding to the end
  2947. of the archive. When you extract a file from the archive, only the
  2948. version stored last will wind up in the file system, unless you use
  2949. the @value{op-backup} option. @FIXME-ref{Multiple Members with the
  2950. Same Name}
  2951. @menu
  2952. * how to update::
  2953. @end menu
  2954. @node how to update
  2955. @subsubsection How to Update an Archive Using @code{--update}
  2956. You must use file name arguments with the @value{op-update} operation.
  2957. If you don't specify any files, @command{tar} won't act on any files and
  2958. won't tell you that it didn't do anything (which may end up confusing
  2959. you).
  2960. @FIXME{note: the above parenthetical added because in fact, this
  2961. behavior just confused the author. :-) }
  2962. To see the @samp{--update} option at work, create a new file,
  2963. @file{classical}, in your practice directory, and some extra text to the
  2964. file @file{blues}, using any text editor. Then invoke @command{tar} with
  2965. the @samp{update} operation and the @value{op-verbose} option specified,
  2966. using the names of all the files in the practice directory as file name
  2967. arguments:
  2968. @example
  2969. $ @kbd{tar --update -v -f collection.tar blues folk rock classical}
  2970. blues
  2971. classical
  2972. $
  2973. @end example
  2974. @noindent
  2975. Because we have specified verbose mode, @command{tar} prints out the names
  2976. of the files it is working on, which in this case are the names of the
  2977. files that needed to be updated. If you run @samp{tar --list} and look
  2978. at the archive, you will see @file{blues} and @file{classical} at its
  2979. end. There will be a total of two versions of the member @samp{blues};
  2980. the one at the end will be newer and larger, since you added text before
  2981. updating it.
  2982. (The reason @command{tar} does not overwrite the older file when updating
  2983. it is because writing to the middle of a section of tape is a difficult
  2984. process. Tapes are not designed to go backward. @xref{Media}, for more
  2985. information about tapes.
  2986. @value{op-update} is not suitable for performing backups for two
  2987. reasons: it does not change directory content entries, and it
  2988. lengthens the archive every time it is used. The @acronym{GNU}
  2989. @command{tar} options intended specifically for backups are more
  2990. efficient. If you need to run backups, please consult @ref{Backups}.
  2991. @node concatenate
  2992. @subsection Combining Archives with @code{--concatenate}
  2993. @cindex Adding archives to an archive
  2994. @cindex Concatenating Archives
  2995. Sometimes it may be convenient to add a second archive onto the end of
  2996. an archive rather than adding individual files to the archive. To add
  2997. one or more archives to the end of another archive, you should use the
  2998. @value{op-concatenate} operation.
  2999. To use @samp{--concatenate}, name the archives to be concatenated on the
  3000. command line. (Nothing happens if you don't list any.) The members,
  3001. and their member names, will be copied verbatim from those archives. If
  3002. this causes multiple members to have the same name, it does not delete
  3003. any members; all the members with the same name coexist. @FIXME-ref{For
  3004. information on how this affects reading the archive, Multiple
  3005. Members with the Same Name.}
  3006. To demonstrate how @samp{--concatenate} works, create two small archives
  3007. called @file{bluesrock.tar} and @file{folkjazz.tar}, using the relevant
  3008. files from @file{practice}:
  3009. @example
  3010. $ @kbd{tar -cvf bluesrock.tar blues rock}
  3011. blues
  3012. classical
  3013. $ @kbd{tar -cvf folkjazz.tar folk jazz}
  3014. folk
  3015. jazz
  3016. @end example
  3017. @noindent
  3018. If you like, You can run @samp{tar --list} to make sure the archives
  3019. contain what they are supposed to:
  3020. @example
  3021. $ @kbd{tar -tvf bluesrock.tar}
  3022. -rw-rw-rw- melissa user 105 1997-01-21 19:42 blues
  3023. -rw-rw-rw- melissa user 33 1997-01-20 15:34 rock
  3024. $ @kbd{tar -tvf folkjazz.tar}
  3025. -rw-rw-rw- melissa user 20 1996-09-23 16:44 folk
  3026. -rw-rw-rw- melissa user 65 1997-01-30 14:15 jazz
  3027. @end example
  3028. We can concatenate these two archives with @command{tar}:
  3029. @example
  3030. $ @kbd{cd ..}
  3031. $ @kbd{tar --concatenate --file=bluesrock.tar jazzfolk.tar}
  3032. @end example
  3033. If you now list the contents of the @file{bluesclass.tar}, you will see
  3034. that now it also contains the archive members of @file{jazzfolk.tar}:
  3035. @example
  3036. $ @kbd{tar --list --file=bluesrock.tar}
  3037. blues
  3038. rock
  3039. jazz
  3040. folk
  3041. @end example
  3042. When you use @samp{--concatenate}, the source and target archives must
  3043. already exist and must have been created using compatible format
  3044. parameters. @FIXME-pxref{Matching Format Parameters}The new,
  3045. concatenated archive will be called by the same name as the first
  3046. archive listed on the command line. @FIXME{is there a way to specify a
  3047. new name?}
  3048. Like @value{op-append}, this operation cannot be performed on some
  3049. tape drives, due to deficiencies in the formats those tape drives use.
  3050. @cindex @code{concatenate} vs @command{cat}
  3051. @cindex @command{cat} vs @code{concatenate}
  3052. It may seem more intuitive to you to want or try to use @command{cat} to
  3053. concatenate two archives instead of using the @samp{--concatenate}
  3054. operation; after all, @command{cat} is the utility for combining files.
  3055. However, @command{tar} archives incorporate an end-of-file marker which
  3056. must be removed if the concatenated archives are to be read properly as
  3057. one archive. @samp{--concatenate} removes the end-of-archive marker
  3058. from the target archive before each new archive is appended. If you use
  3059. @command{cat} to combine the archives, the result will not be a valid
  3060. @command{tar} format archive. If you need to retrieve files from an
  3061. archive that was added to using the @command{cat} utility, use the
  3062. @value{op-ignore-zeros} option. @xref{Ignore Zeros}, for further
  3063. information on dealing with archives improperly combined using the
  3064. @command{cat} shell utility.
  3065. @FIXME{this shouldn't go here. where should it go?} You must specify
  3066. the source archives using @value{op-file} (@value{pxref-file}). If you
  3067. do not specify the target archive, @command{tar} uses the value of the
  3068. environment variable @env{TAPE}, or, if this has not been set, the
  3069. default archive name.
  3070. @node delete
  3071. @subsection Removing Archive Members Using @samp{--delete}
  3072. @UNREVISED
  3073. @cindex Deleting files from an archive
  3074. @cindex Removing files from an archive
  3075. You can remove members from an archive by using the @value{op-delete}
  3076. option. Specify the name of the archive with @value{op-file} and then
  3077. specify the names of the members to be deleted; if you list no member
  3078. names, nothing will be deleted. The @value{op-verbose} option will
  3079. cause @command{tar} to print the names of the members as they are deleted.
  3080. As with @value{op-extract}, you must give the exact member names when
  3081. using @samp{tar --delete}. @samp{--delete} will remove all versions of
  3082. the named file from the archive. The @samp{--delete} operation can run
  3083. very slowly.
  3084. Unlike other operations, @samp{--delete} has no short form.
  3085. @cindex Tapes, using @code{--delete} and
  3086. @cindex Deleting from tape archives
  3087. This operation will rewrite the archive. You can only use
  3088. @samp{--delete} on an archive if the archive device allows you to
  3089. write to any point on the media, such as a disk; because of this, it
  3090. does not work on magnetic tapes. Do not try to delete an archive member
  3091. from a magnetic tape; the action will not succeed, and you will be
  3092. likely to scramble the archive and damage your tape. There is no safe
  3093. way (except by completely re-writing the archive) to delete files from
  3094. most kinds of magnetic tape. @xref{Media}.
  3095. To delete all versions of the file @file{blues} from the archive
  3096. @file{collection.tar} in the @file{practice} directory, make sure you
  3097. are in that directory, and then,
  3098. @example
  3099. $ @kbd{tar --list --file=collection.tar}
  3100. blues
  3101. folk
  3102. jazz
  3103. rock
  3104. practice/blues
  3105. practice/folk
  3106. practice/jazz
  3107. practice/rock
  3108. practice/blues
  3109. $ @kbd{tar --delete --file=collection.tar blues}
  3110. $ @kbd{tar --list --file=collection.tar}
  3111. folk
  3112. jazz
  3113. rock
  3114. $
  3115. @end example
  3116. @FIXME{I changed the order of these nodes around and haven't had a chance
  3117. to fix the above example's results, yet. I have to play with this and
  3118. follow it and see what it actually does!}
  3119. The @value{op-delete} option has been reported to work properly when
  3120. @command{tar} acts as a filter from @code{stdin} to @code{stdout}.
  3121. @node compare
  3122. @subsection Comparing Archive Members with the File System
  3123. @cindex Verifying the currency of an archive
  3124. @UNREVISED
  3125. The @samp{--compare} (@samp{-d}), or @samp{--diff} operation compares
  3126. specified archive members against files with the same names, and then
  3127. reports differences in file size, mode, owner, modification date and
  3128. contents. You should @emph{only} specify archive member names, not file
  3129. names. If you do not name any members, then @command{tar} will compare the
  3130. entire archive. If a file is represented in the archive but does not
  3131. exist in the file system, @command{tar} reports a difference.
  3132. You have to specify the record size of the archive when modifying an
  3133. archive with a non-default record size.
  3134. @command{tar} ignores files in the file system that do not have
  3135. corresponding members in the archive.
  3136. The following example compares the archive members @file{rock},
  3137. @file{blues} and @file{funk} in the archive @file{bluesrock.tar} with
  3138. files of the same name in the file system. (Note that there is no file,
  3139. @file{funk}; @command{tar} will report an error message.)
  3140. @example
  3141. $ @kbd{tar --compare --file=bluesrock.tar rock blues funk}
  3142. rock
  3143. blues
  3144. tar: funk not found in archive
  3145. @end example
  3146. @noindent
  3147. @FIXME{what does this actually depend on? i'm making a guess,
  3148. here.}Depending on the system where you are running @command{tar} and the
  3149. version you are running, @command{tar} may have a different error message,
  3150. such as:
  3151. @example
  3152. funk: does not exist
  3153. @end example
  3154. @FIXME-xref{somewhere, for more information about format parameters.
  3155. Melissa says: such as "format variations"? But why? Clearly I don't
  3156. get it yet; I'll deal when I get to that section.}
  3157. The spirit behind the @value{op-compare} option is to check whether the
  3158. archive represents the current state of files on disk, more than validating
  3159. the integrity of the archive media. For this later goal, @xref{verify}.
  3160. @node create options
  3161. @section Options Used by @code{--create}
  3162. The previous chapter described the basics of how to use
  3163. @value{op-create} to create an archive from a set of files.
  3164. @xref{create}. This section described advanced options to be used with
  3165. @samp{--create}.
  3166. @menu
  3167. * Ignore Failed Read::
  3168. @end menu
  3169. @node Ignore Failed Read
  3170. @subsection Ignore Fail Read
  3171. @table @kbd
  3172. @item --ignore-failed-read
  3173. Do not exit with nonzero on unreadable files or directories.
  3174. @end table
  3175. @node extract options
  3176. @section Options Used by @code{--extract}
  3177. @UNREVISED
  3178. @FIXME{i need to get dan to go over these options with me and see if
  3179. there's a better way of organizing them.}
  3180. The previous chapter showed how to use @value{op-extract} to extract
  3181. an archive into the filesystem. Various options cause @command{tar} to
  3182. extract more information than just file contents, such as the owner,
  3183. the permissions, the modification date, and so forth. This section
  3184. presents options to be used with @samp{--extract} when certain special
  3185. considerations arise. You may review the information presented in
  3186. @ref{extract} for more basic information about the
  3187. @samp{--extract} operation.
  3188. @menu
  3189. * Reading:: Options to Help Read Archives
  3190. * Writing:: Changing How @command{tar} Writes Files
  3191. * Scarce:: Coping with Scarce Resources
  3192. @end menu
  3193. @node Reading
  3194. @subsection Options to Help Read Archives
  3195. @cindex Options when reading archives
  3196. @cindex Reading incomplete records
  3197. @cindex Records, incomplete
  3198. @cindex End-of-archive entries, ignoring
  3199. @cindex Ignoring end-of-archive entries
  3200. @cindex Large lists of file names on small machines
  3201. @cindex Small memory
  3202. @cindex Running out of space
  3203. @UNREVISED
  3204. Normally, @command{tar} will request data in full record increments from
  3205. an archive storage device. If the device cannot return a full record,
  3206. @command{tar} will report an error. However, some devices do not always
  3207. return full records, or do not require the last record of an archive to
  3208. be padded out to the next record boundary. To keep reading until you
  3209. obtain a full record, or to accept an incomplete record if it contains
  3210. an end-of-archive marker, specify the @value{op-read-full-records} option
  3211. in conjunction with the @value{op-extract} or @value{op-list} operations.
  3212. @value{xref-read-full-records}.
  3213. The @value{op-read-full-records} option is turned on by default when
  3214. @command{tar} reads an archive from standard input, or from a remote
  3215. machine. This is because on BSD Unix systems, attempting to read a
  3216. pipe returns however much happens to be in the pipe, even if it is
  3217. less than was requested. If this option were not enabled, @command{tar}
  3218. would fail as soon as it read an incomplete record from the pipe.
  3219. If you're not sure of the blocking factor of an archive, you can
  3220. read the archive by specifying @value{op-read-full-records} and
  3221. @value{op-blocking-factor}, using a blocking factor larger than what the
  3222. archive uses. This lets you avoid having to determine the blocking factor
  3223. of an archive. @value{xref-blocking-factor}.
  3224. @menu
  3225. * read full records::
  3226. * Ignore Zeros::
  3227. @end menu
  3228. @node read full records
  3229. @unnumberedsubsubsec Reading Full Records
  3230. @FIXME{need sentence or so of intro here}
  3231. @table @kbd
  3232. @item --read-full-records
  3233. @item -B
  3234. Use in conjunction with @value{op-extract} to read an archive which
  3235. contains incomplete records, or one which has a blocking factor less
  3236. than the one specified.
  3237. @end table
  3238. @node Ignore Zeros
  3239. @unnumberedsubsubsec Ignoring Blocks of Zeros
  3240. Normally, @command{tar} stops reading when it encounters a block of zeros
  3241. between file entries (which usually indicates the end of the archive).
  3242. @value{op-ignore-zeros} allows @command{tar} to completely read an archive
  3243. which contains a block of zeros before the end (i.e.@: a damaged
  3244. archive, or one which was created by concatenating several archives
  3245. together).
  3246. The @value{op-ignore-zeros} option is turned off by default because many
  3247. versions of @command{tar} write garbage after the end-of-archive entry,
  3248. since that part of the media is never supposed to be read. @acronym{GNU}
  3249. @command{tar} does not write after the end of an archive, but seeks to
  3250. maintain compatiblity among archiving utilities.
  3251. @table @kbd
  3252. @item --ignore-zeros
  3253. @itemx -i
  3254. To ignore blocks of zeros (ie.@: end-of-archive entries) which may be
  3255. encountered while reading an archive. Use in conjunction with
  3256. @value{op-extract} or @value{op-list}.
  3257. @end table
  3258. @node Writing
  3259. @subsection Changing How @command{tar} Writes Files
  3260. @cindex Overwriting old files, prevention
  3261. @cindex Protecting old files
  3262. @cindex Modification times of extracted files
  3263. @cindex Permissions of extracted files
  3264. @cindex Modes of extracted files
  3265. @cindex Writing extracted files to standard output
  3266. @cindex Standard output, writing extracted files to
  3267. @UNREVISED
  3268. @FIXME{need to mention the brand new option, --backup}
  3269. @menu
  3270. * Dealing with Old Files::
  3271. * Overwrite Old Files::
  3272. * Keep Old Files::
  3273. * Unlink First::
  3274. * Recursive Unlink::
  3275. * Modification Times::
  3276. * Setting Access Permissions::
  3277. * Writing to Standard Output::
  3278. * remove files::
  3279. @end menu
  3280. @node Dealing with Old Files
  3281. @unnumberedsubsubsec Options Controlling the Overwriting of Existing Files
  3282. When extracting files, if @command{tar} discovers that the extracted
  3283. file already exists, it normally replaces the file by removing it before
  3284. extracting it, to prevent confusion in the presence of hard or symbolic
  3285. links. (If the existing file is a symbolic link, it is removed, not
  3286. followed.) However, if a directory cannot be removed because it is
  3287. nonempty, @command{tar} normally overwrites its metadata (ownership,
  3288. permission, etc.). The @option{--overwrite-dir} option enables this
  3289. default behavior. To be more cautious and preserve the metadata of
  3290. such a directory, use the @option{--no-overwrite-dir} option.
  3291. To be even more cautious and prevent existing files from being replaced, use
  3292. the @value{op-keep-old-files} option. It causes @command{tar} to refuse
  3293. to replace or update a file that already exists, i.e., a file with the
  3294. same name as an archive member prevents extraction of that archive
  3295. member. Instead, it reports an error.
  3296. To be more aggressive about altering existing files, use the
  3297. @value{op-overwrite} option. It causes @command{tar} to overwrite
  3298. existing files and to follow existing symbolic links when extracting.
  3299. Some people argue that @acronym{GNU} @command{tar} should not hesitate
  3300. to overwrite files with other files when extracting. When extracting
  3301. a @command{tar} archive, they expect to see a faithful copy of the
  3302. state of the filesystem when the archive was created. It is debatable
  3303. that this would always be a proper behavior. For example, suppose one
  3304. has an archive in which @file{usr/local} is a link to
  3305. @file{usr/local2}. Since then, maybe the site removed the link and
  3306. renamed the whole hierarchy from @file{/usr/local2} to
  3307. @file{/usr/local}. Such things happen all the time. I guess it would
  3308. not be welcome at all that @acronym{GNU} @command{tar} removes the
  3309. whole hierarchy just to make room for the link to be reinstated
  3310. (unless it @emph{also} simultaneously restores the full
  3311. @file{/usr/local2}, of course! @acronym{GNU} @command{tar} is indeed
  3312. able to remove a whole hierarchy to reestablish a symbolic link, for
  3313. example, but @emph{only if} @value{op-recursive-unlink} is specified
  3314. to allow this behavior. In any case, single files are silently
  3315. removed.
  3316. Finally, the @value{op-unlink-first} option can improve performance in
  3317. some cases by causing @command{tar} to remove files unconditionally
  3318. before extracting them.
  3319. @node Overwrite Old Files
  3320. @unnumberedsubsubsec Overwrite Old Files
  3321. @table @kbd
  3322. @item --overwrite
  3323. Overwrite existing files and directory metadata when extracting files
  3324. from an archive.
  3325. This
  3326. causes @command{tar} to write extracted files into the file system without
  3327. regard to the files already on the system; i.e., files with the same
  3328. names as archive members are overwritten when the archive is extracted.
  3329. It also causes @command{tar} to extract the ownership, permissions,
  3330. and time stamps onto any preexisting files or directories.
  3331. If the name of a corresponding file name is a symbolic link, the file
  3332. pointed to by the symbolic link will be overwritten instead of the
  3333. symbolic link itself (if this is possible). Moreover, special devices,
  3334. empty directories and even symbolic links are automatically removed if
  3335. they are in the way of extraction.
  3336. Be careful when using the @value{op-overwrite} option, particularly when
  3337. combined with the @value{op-absolute-names} option, as this combination
  3338. can change the contents, ownership or permissions of any file on your
  3339. system. Also, many systems do not take kindly to overwriting files that
  3340. are currently being executed.
  3341. @item --overwrite-dir
  3342. Overwrite the metadata of directories when extracting files from an
  3343. archive, but remove other files before extracting.
  3344. @end table
  3345. @node Keep Old Files
  3346. @unnumberedsubsubsec Keep Old Files
  3347. @table @kbd
  3348. @item --keep-old-files
  3349. @itemx -k
  3350. Do not replace existing files from archive. The
  3351. @value{op-keep-old-files} option prevents @command{tar} from replacing
  3352. existing files with files with the same name from the archive.
  3353. The @value{op-keep-old-files} option is meaningless with @value{op-list}.
  3354. Prevents @command{tar} from replacing files in the file system during
  3355. extraction.
  3356. @end table
  3357. @node Unlink First
  3358. @unnumberedsubsubsec Unlink First
  3359. @table @kbd
  3360. @item --unlink-first
  3361. @itemx -U
  3362. Remove files before extracting over them.
  3363. This can make @command{tar} run a bit faster if you know in advance
  3364. that the extracted files all need to be removed. Normally this option
  3365. slows @command{tar} down slightly, so it is disabled by default.
  3366. @end table
  3367. @node Recursive Unlink
  3368. @unnumberedsubsubsec Recursive Unlink
  3369. @table @kbd
  3370. @item --recursive-unlink
  3371. When this option is specified, try removing files and directory hierarchies
  3372. before extracting over them. @emph{This is a dangerous option!}
  3373. @end table
  3374. If you specify the @value{op-recursive-unlink} option,
  3375. @command{tar} removes @emph{anything} that keeps you from extracting a file
  3376. as far as current permissions will allow it. This could include removal
  3377. of the contents of a full directory hierarchy.
  3378. @node Modification Times
  3379. @unnumberedsubsubsec Setting Modification Times
  3380. Normally, @command{tar} sets the modification times of extracted files to
  3381. the modification times recorded for the files in the archive, but
  3382. limits the permissions of extracted files by the current @code{umask}
  3383. setting.
  3384. To set the modification times of extracted files to the time when
  3385. the files were extracted, use the @value{op-touch} option in
  3386. conjunction with @value{op-extract}.
  3387. @table @kbd
  3388. @item --touch
  3389. @itemx -m
  3390. Sets the modification time of extracted archive members to the time
  3391. they were extracted, not the time recorded for them in the archive.
  3392. Use in conjunction with @value{op-extract}.
  3393. @end table
  3394. @node Setting Access Permissions
  3395. @unnumberedsubsubsec Setting Access Permissions
  3396. To set the modes (access permissions) of extracted files to those
  3397. recorded for those files in the archive, use @samp{--same-permissions}
  3398. in conjunction with the @value{op-extract} operation. @FIXME{Should be
  3399. aliased to ignore-umask.}
  3400. @table @kbd
  3401. @item --preserve-permission
  3402. @itemx --same-permission
  3403. @itemx --ignore-umask
  3404. @itemx -p
  3405. Set modes of extracted archive members to those recorded in the
  3406. archive, instead of current umask settings. Use in conjunction with
  3407. @value{op-extract}.
  3408. @end table
  3409. @FIXME{Following paragraph needs to be rewritten: why doesn't this cat
  3410. files together, why is this useful. is it really useful with
  3411. more than one file?}
  3412. @node Writing to Standard Output
  3413. @unnumberedsubsubsec Writing to Standard Output
  3414. To write the extracted files to the standard output, instead of
  3415. creating the files on the file system, use @value{op-to-stdout} in
  3416. conjunction with @value{op-extract}. This option is useful if you are
  3417. extracting files to send them through a pipe, and do not need to
  3418. preserve them in the file system. If you extract multiple members,
  3419. they appear on standard output concatenated, in the order they are
  3420. found in the archive.
  3421. @table @kbd
  3422. @item --to-stdout
  3423. @itemx -O
  3424. Writes files to the standard output. Used in conjunction with
  3425. @value{op-extract}. Extract files to standard output. When this option
  3426. is used, instead of creating the files specified, @command{tar} writes
  3427. the contents of the files extracted to its standard output. This may
  3428. be useful if you are only extracting the files in order to send them
  3429. through a pipe. This option is meaningless with @value{op-list}.
  3430. @end table
  3431. This can be useful, for example, if you have a tar archive containing
  3432. a big file and don't want to store the file on disk before processing
  3433. it. You can use a command like this:
  3434. @example
  3435. tar -xOzf foo.tgz bigfile | process
  3436. @end example
  3437. or even like this if you want to process the concatenation of the files:
  3438. @example
  3439. tar -xOzf foo.tgz bigfile1 bigfile2 | process
  3440. @end example
  3441. @node remove files
  3442. @unnumberedsubsubsec Removing Files
  3443. @FIXME{the various macros in the front of the manual think that this
  3444. option goes in this section. i have no idea; i only know it's nowhere
  3445. else in the book...}
  3446. @table @kbd
  3447. @item --remove-files
  3448. Remove files after adding them to the archive.
  3449. @end table
  3450. @node Scarce
  3451. @subsection Coping with Scarce Resources
  3452. @cindex Middle of the archive, starting in the
  3453. @cindex Running out of space during extraction
  3454. @cindex Disk space, running out of
  3455. @cindex Space on the disk, recovering from lack of
  3456. @UNREVISED
  3457. @menu
  3458. * Starting File::
  3459. * Same Order::
  3460. @end menu
  3461. @node Starting File
  3462. @unnumberedsubsubsec Starting File
  3463. @table @kbd
  3464. @item --starting-file=@var{name}
  3465. @itemx -K @var{name}
  3466. Starts an operation in the middle of an archive. Use in conjunction
  3467. with @value{op-extract} or @value{op-list}.
  3468. @end table
  3469. If a previous attempt to extract files failed due to lack of disk
  3470. space, you can use @value{op-starting-file} to start extracting only
  3471. after member @var{name} of the archive. This assumes, of course, that
  3472. there is now free space, or that you are now extracting into a
  3473. different file system. (You could also choose to suspend @command{tar},
  3474. remove unnecessary files from the file system, and then restart the
  3475. same @command{tar} operation. In this case, @value{op-starting-file} is
  3476. not necessary. @value{xref-incremental}, @value{xref-interactive},
  3477. and @value{ref-exclude}.)
  3478. @node Same Order
  3479. @unnumberedsubsubsec Same Order
  3480. @table @kbd
  3481. @item --same-order
  3482. @itemx --preserve-order
  3483. @itemx -s
  3484. To process large lists of file names on machines with small amounts of
  3485. memory. Use in conjunction with @value{op-compare},
  3486. @value{op-list}
  3487. or @value{op-extract}.
  3488. @end table
  3489. @FIXME{we don't need/want --preserve to exist any more (from melissa:
  3490. ie, don't want that *version* of the option to exist, or don't want
  3491. the option to exist in either version?}
  3492. @FIXME{i think this explanation is lacking.}
  3493. The @value{op-same-order} option tells @command{tar} that the list of file
  3494. names to be listed or extracted is sorted in the same order as the
  3495. files in the archive. This allows a large list of names to be used,
  3496. even on a small machine that would not otherwise be able to hold all
  3497. the names in memory at the same time. Such a sorted list can easily be
  3498. created by running @samp{tar -t} on the archive and editing its output.
  3499. This option is probably never needed on modern computer systems.
  3500. @node backup
  3501. @section Backup options
  3502. @cindex backup options
  3503. @acronym{GNU} @command{tar} offers options for making backups of files
  3504. before writing new versions. These options control the details of
  3505. these backups. They may apply to the archive itself before it is
  3506. created or rewritten, as well as individual extracted members. Other
  3507. @acronym{GNU} programs (@command{cp}, @command{install}, @command{ln},
  3508. and @command{mv}, for example) offer similar options.
  3509. Backup options may prove unexpectedly useful when extracting archives
  3510. containing many members having identical name, or when extracting archives
  3511. on systems having file name limitations, making different members appear
  3512. has having similar names through the side-effect of name truncation.
  3513. (This is true only if we have a good scheme for truncated backup names,
  3514. which I'm not sure at all: I suspect work is needed in this area.)
  3515. When any existing file is backed up before being overwritten by extraction,
  3516. then clashing files are automatically be renamed to be unique, and the
  3517. true name is kept for only the last file of a series of clashing files.
  3518. By using verbose mode, users may track exactly what happens.
  3519. At the detail level, some decisions are still experimental, and may
  3520. change in the future, we are waiting comments from our users. So, please
  3521. do not learn to depend blindly on the details of the backup features.
  3522. For example, currently, directories themselves are never renamed through
  3523. using these options, so, extracting a file over a directory still has
  3524. good chances to fail. Also, backup options apply to created archives,
  3525. not only to extracted members. For created archives, backups will not
  3526. be attempted when the archive is a block or character device, or when it
  3527. refers to a remote file.
  3528. For the sake of simplicity and efficiency, backups are made by renaming old
  3529. files prior to creation or extraction, and not by copying. The original
  3530. name is restored if the file creation fails. If a failure occurs after a
  3531. partial extraction of a file, both the backup and the partially extracted
  3532. file are kept.
  3533. @table @samp
  3534. @item --backup[=@var{method}]
  3535. @opindex --backup
  3536. @vindex VERSION_CONTROL
  3537. @cindex backups
  3538. Back up files that are about to be overwritten or removed.
  3539. Without this option, the original versions are destroyed.
  3540. Use @var{method} to determine the type of backups made.
  3541. If @var{method} is not specified, use the value of the @env{VERSION_CONTROL}
  3542. environment variable. And if @env{VERSION_CONTROL} is not set,
  3543. use the @samp{existing} method.
  3544. @vindex version-control @r{Emacs variable}
  3545. This option corresponds to the Emacs variable @samp{version-control};
  3546. the same values for @var{method} are accepted as in Emacs. This option
  3547. also allows more descriptive names. The valid @var{method}s are:
  3548. @table @samp
  3549. @item t
  3550. @itemx numbered
  3551. @opindex numbered @r{backup method}
  3552. Always make numbered backups.
  3553. @item nil
  3554. @itemx existing
  3555. @opindex existing @r{backup method}
  3556. Make numbered backups of files that already have them, simple backups
  3557. of the others.
  3558. @item never
  3559. @itemx simple
  3560. @opindex simple @r{backup method}
  3561. Always make simple backups.
  3562. @end table
  3563. @item --suffix=@var{suffix}
  3564. @opindex --suffix
  3565. @cindex backup suffix
  3566. @vindex SIMPLE_BACKUP_SUFFIX
  3567. Append @var{suffix} to each backup file made with @samp{--backup}. If this
  3568. option is not specified, the value of the @env{SIMPLE_BACKUP_SUFFIX}
  3569. environment variable is used. And if @env{SIMPLE_BACKUP_SUFFIX} is not
  3570. set, the default is @samp{~}, just as in Emacs.
  3571. @end table
  3572. Some people express the desire to @emph{always} use the @value{op-backup}
  3573. option, by defining some kind of alias or script. This is not as easy
  3574. as one may think, due to the fact that old style options should appear first
  3575. and consume arguments a bit unpredictably for an alias or script. But,
  3576. if you are ready to give up using old style options, you may resort to
  3577. using something like (a Bourne shell function here):
  3578. @example
  3579. tar () @{ /usr/local/bin/tar --backup $*; @}
  3580. @end example
  3581. @node Applications
  3582. @section Notable @command{tar} Usages
  3583. @UNREVISED
  3584. @FIXME{Using Unix file linking capability to recreate directory
  3585. structures---linking files into one subdirectory and then
  3586. @command{tar}ring that directory.}
  3587. @FIXME{Nice hairy example using absolute-names, newer, etc.}
  3588. @findex uuencode
  3589. You can easily use archive files to transport a group of files from
  3590. one system to another: put all relevant files into an archive on one
  3591. computer system, transfer the archive to another system, and extract
  3592. the contents there. The basic transfer medium might be magnetic tape,
  3593. Internet FTP, or even electronic mail (though you must encode the
  3594. archive with @command{uuencode} in order to transport it properly by
  3595. mail). Both machines do not have to use the same operating system, as
  3596. long as they both support the @command{tar} program.
  3597. For example, here is how you might copy a directory's contents from
  3598. one disk to another, while preserving the dates, modes, owners and
  3599. link-structure of all the files therein. In this case, the transfer
  3600. medium is a @dfn{pipe}, which is one a Unix redirection mechanism:
  3601. @smallexample
  3602. $ @kbd{cd sourcedir; tar -cf - . | (cd targetdir; tar -xf -)}
  3603. @end smallexample
  3604. @noindent
  3605. The command also works using short option forms:
  3606. @FIXME{The following using standard input/output correct??}
  3607. @smallexample
  3608. $ @w{@kbd{cd sourcedir; tar --create --file=- . | (cd targetdir; tar --extract --file=-)}}
  3609. @end smallexample
  3610. @noindent
  3611. This is one of the easiest methods to transfer a @command{tar} archive.
  3612. @node looking ahead
  3613. @section Looking Ahead: The Rest of this Manual
  3614. You have now seen how to use all eight of the operations available to
  3615. @command{tar}, and a number of the possible options. The next chapter
  3616. explains how to choose and change file and archive names, how to use
  3617. files to store names of other files which you can then call as
  3618. arguments to @command{tar} (this can help you save time if you expect to
  3619. archive the same list of files a number of times), and so forth.
  3620. @FIXME{in case it's not obvious, i'm making this up in some sense
  3621. based on my imited memory of what the next chapter *really* does. i
  3622. just wanted to flesh out this final section a little bit so i'd
  3623. remember to sitck it in here. :-)}
  3624. If there are too many files to conveniently list on the command line,
  3625. you can list the names in a file, and @command{tar} will read that file.
  3626. @value{xref-files-from}.
  3627. There are various ways of causing @command{tar} to skip over some files,
  3628. and not archive them. @xref{Choosing}.
  3629. @node Backups
  3630. @chapter Performing Backups and Restoring Files
  3631. @UNREVISED
  3632. @acronym{GNU} @command{tar} is distributed along with the scripts
  3633. which the Free Software Foundation uses for performing backups. There
  3634. is no corresponding scripts available yet for doing restoration of
  3635. files. Even if there is a good chance those scripts may be satisfying
  3636. to you, they are not the only scripts or methods available for doing
  3637. backups and restore. You may well create your own, or use more
  3638. sophisticated packages dedicated to that purpose.
  3639. Some users are enthusiastic about @code{Amanda} (The Advanced Maryland
  3640. Automatic Network Disk Archiver), a backup system developed by James
  3641. da Silva @file{jds@@cs.umd.edu} and available on many Unix systems.
  3642. This is free software, and it is available at these places:
  3643. @example
  3644. http://www.cs.umd.edu/projects/amanda/amanda.html
  3645. ftp://ftp.cs.umd.edu/pub/amanda
  3646. @end example
  3647. @ifclear PUBLISH
  3648. Here is a possible plan for a future documentation about the backuping
  3649. scripts which are provided within the @acronym{GNU} @command{tar}
  3650. distribution.
  3651. @example
  3652. .* dumps
  3653. . + what are dumps
  3654. . + different levels of dumps
  3655. . - full dump = dump everything
  3656. . - level 1, level 2 dumps etc, -
  3657. A level n dump dumps everything changed since the last level
  3658. n-1 dump (?)
  3659. . + how to use scripts for dumps (ie, the concept)
  3660. . - scripts to run after editing backup specs (details)
  3661. . + Backup Specs, what is it.
  3662. . - how to customize
  3663. . - actual text of script [/sp/dump/backup-specs]
  3664. . + Problems
  3665. . - rsh doesn't work
  3666. . - rtape isn't installed
  3667. . - (others?)
  3668. . + the --incremental option of tar
  3669. . + tapes
  3670. . - write protection
  3671. . - types of media
  3672. . : different sizes and types, useful for different things
  3673. . - files and tape marks
  3674. one tape mark between files, two at end.
  3675. . - positioning the tape
  3676. MT writes two at end of write,
  3677. backspaces over one when writing again.
  3678. @end example
  3679. @end ifclear
  3680. This chapter documents both the provided FSF scripts and @command{tar}
  3681. options which are more specific to usage as a backup tool.
  3682. To @dfn{back up} a file system means to create archives that contain
  3683. all the files in that file system. Those archives can then be used to
  3684. restore any or all of those files (for instance if a disk crashes or a
  3685. file is accidentally deleted). File system @dfn{backups} are also
  3686. called @dfn{dumps}.
  3687. @menu
  3688. * Full Dumps:: Using @command{tar} to Perform Full Dumps
  3689. * Inc Dumps:: Using @command{tar} to Perform Incremental Dumps
  3690. * incremental and listed-incremental:: The Incremental Options
  3691. * Backup Levels:: Levels of Backups
  3692. * Backup Parameters:: Setting Parameters for Backups and Restoration
  3693. * Scripted Backups:: Using the Backup Scripts
  3694. * Scripted Restoration:: Using the Restore Script
  3695. @end menu
  3696. @node Full Dumps
  3697. @section Using @command{tar} to Perform Full Dumps
  3698. @UNREVISED
  3699. @cindex full dumps
  3700. @cindex dumps, full
  3701. @cindex corrupted archives
  3702. Full dumps should only be made when no other people or programs
  3703. are modifying files in the filesystem. If files are modified while
  3704. @command{tar} is making the backup, they may not be stored properly in
  3705. the archive, in which case you won't be able to restore them if you
  3706. have to. (Files not being modified are written with no trouble, and do
  3707. not corrupt the entire archive.)
  3708. You will want to use the @value{op-label} option to give the archive a
  3709. volume label, so you can tell what this archive is even if the label
  3710. falls off the tape, or anything like that.
  3711. Unless the filesystem you are dumping is guaranteed to fit on
  3712. one volume, you will need to use the @value{op-multi-volume} option.
  3713. Make sure you have enough tapes on hand to complete the backup.
  3714. If you want to dump each filesystem separately you will need to use
  3715. the @value{op-one-file-system} option to prevent @command{tar} from crossing
  3716. filesystem boundaries when storing (sub)directories.
  3717. The @value{op-incremental} option is not needed, since this is a complete
  3718. copy of everything in the filesystem, and a full restore from this
  3719. backup would only be done onto a completely empty disk.
  3720. Unless you are in a hurry, and trust the @command{tar} program (and your
  3721. tapes), it is a good idea to use the @value{op-verify} option, to make
  3722. sure your files really made it onto the dump properly. This will
  3723. also detect cases where the file was modified while (or just after)
  3724. it was being archived. Not all media (notably cartridge tapes) are
  3725. capable of being verified, unfortunately.
  3726. @value{op-listed-incremental} take a file name argument always. If the
  3727. file doesn't exist, run a level zero dump, creating the file. If the
  3728. file exists, uses that file to see what has changed.
  3729. @value{op-incremental} @FIXME{look it up}
  3730. @value{op-incremental} handle old @acronym{GNU}-format incremental backup.
  3731. This option should only be used when creating an incremental backup of
  3732. a filesystem. When the @value{op-incremental} option is used, @command{tar}
  3733. writes, at the beginning of the archive, an entry for each of the
  3734. directories that will be operated on. The entry for a directory
  3735. includes a list of all the files in the directory at the time the
  3736. dump was done, and a flag for each file indicating whether the file
  3737. is going to be put in the archive. This information is used when
  3738. doing a complete incremental restore.
  3739. Note that this option causes @command{tar} to create a non-standard
  3740. archive that may not be readable by non-@acronym{GNU} versions of the
  3741. @command{tar} program.
  3742. The @value{op-incremental} option means the archive is an incremental
  3743. backup. Its meaning depends on the command that it modifies.
  3744. If the @value{op-incremental} option is used with @value{op-list},
  3745. @command{tar} will list, for each directory in the archive, the list
  3746. of files in that directory at the time the archive was created. This
  3747. information is put out in a format that is not easy for humans to
  3748. read, but which is unambiguous for a program: each file name is
  3749. preceded by either a @samp{Y} if the file is present in the archive,
  3750. an @samp{N} if the file is not included in the archive, or a @samp{D}
  3751. if the file is a directory (and is included in the archive). Each
  3752. file name is terminated by a null character. The last file is
  3753. followed by an additional null and a newline to indicate the end of
  3754. the data.
  3755. If the @value{op-incremental} option is used with @value{op-extract}, then
  3756. when the entry for a directory is found, all files that currently
  3757. exist in that directory but are not listed in the archive @emph{are
  3758. deleted from the directory}.
  3759. This behavior is convenient when you are restoring a damaged file
  3760. system from a succession of incremental backups: it restores the
  3761. entire state of the file system to that which obtained when the backup
  3762. was made. If you don't use @value{op-incremental}, the file system will
  3763. probably fill up with files that shouldn't exist any more.
  3764. @value{op-listed-incremental} handle new @acronym{GNU}-format
  3765. incremental backup. This option handles new @acronym{GNU}-format
  3766. incremental backup. It has much the same effect as
  3767. @value{op-incremental}, but also the time when the dump is done and
  3768. the list of directories dumped is written to the given
  3769. @var{file}. When restoring, only files newer than the saved time are
  3770. restored, and the directory list is used to speed up operations.
  3771. @value{op-listed-incremental} acts like @value{op-incremental}, but when
  3772. used in conjunction with @value{op-create} will also cause @command{tar} to
  3773. use the file @var{file}, which contains information about the state
  3774. of the filesystem at the time of the last backup, to decide which
  3775. files to include in the archive being created. That file will then
  3776. be updated by @command{tar}. If the file @var{file} does not exist when
  3777. this option is specified, @command{tar} will create it, and include all
  3778. appropriate files in the archive.
  3779. The file, which is archive independent, contains the date it was last
  3780. modified and a list of devices, inode numbers and directory names.
  3781. @command{tar} will archive files with newer mod dates or inode change
  3782. times, and directories with an unchanged inode number and device but
  3783. a changed directory name. The file is updated after the files to
  3784. be archived are determined, but before the new archive is actually
  3785. created.
  3786. @node Inc Dumps
  3787. @section Using @command{tar} to Perform Incremental Dumps
  3788. @UNREVISED
  3789. @cindex incremental dumps
  3790. @cindex dumps, incremental
  3791. Performing incremental dumps is similar to performing full dumps,
  3792. although a few more options will usually be needed.
  3793. A standard scheme is to do a @emph{monthly} (full) dump once a month,
  3794. a @emph{weekly} dump once a week of everything since the last monthly
  3795. and a @emph{daily} every day of everything since the last (weekly or
  3796. monthly) dump.
  3797. Here is a sample script to dump the directory hierarchies @samp{/usr}
  3798. and @samp{/var}.
  3799. @example
  3800. #! /bin/sh
  3801. tar --create \
  3802. --blocking-factor=126 \
  3803. --file=/dev/rmt/0 \
  3804. --label="`hostname` /usr /var `date +%Y-%m-%d`" \
  3805. --listed-incremental=/var/log/usr-var.snar \
  3806. --verbose \
  3807. /usr /var
  3808. @end example
  3809. This script uses the file @file{/var/log/usr-var.snar} as a snapshot to
  3810. store information about the previous tar dump.
  3811. The blocking factor 126 is an attempt to make the tape drive stream.
  3812. Some tape devices cannot handle 64 kB blocks or larger, and require the
  3813. block size to be a multiple of 1 kB; for these devices, 126 is the
  3814. largest blocking factor that can be used.
  3815. @node incremental and listed-incremental
  3816. @section The Incremental Options
  3817. @UNREVISED
  3818. @value{op-incremental} is used in conjunction with @value{op-create},
  3819. @value{op-extract} or @value{op-list} when backing up and restoring file
  3820. systems. An archive cannot be extracted or listed with the
  3821. @value{op-incremental} option specified unless it was created with the
  3822. option specified. This option should only be used by a script, not by
  3823. the user, and is usually disregarded in favor of
  3824. @value{op-listed-incremental}, which is described below.
  3825. @value{op-incremental} in conjunction with @value{op-create} causes
  3826. @command{tar} to write, at the beginning of the archive, an entry for
  3827. each of the directories that will be archived. The entry for a
  3828. directory includes a list of all the files in the directory at the
  3829. time the archive was created and a flag for each file indicating
  3830. whether or not the file is going to be put in the archive.
  3831. Note that this option causes @command{tar} to create a non-standard
  3832. archive that may not be readable by non-@acronym{GNU} versions of the
  3833. @command{tar} program.
  3834. @value{op-incremental} in conjunction with @value{op-extract} causes
  3835. @command{tar} to read the lists of directory contents previously stored
  3836. in the archive, @emph{delete} files in the file system that did not
  3837. exist in their directories when the archive was created, and then
  3838. extract the files in the archive.
  3839. This behavior is convenient when restoring a damaged file system from
  3840. a succession of incremental backups: it restores the entire state of
  3841. the file system to that which obtained when the backup was made. If
  3842. @value{op-incremental} isn't specified, the file system will probably
  3843. fill up with files that shouldn't exist any more.
  3844. @value{op-incremental} in conjunction with @value{op-list} causes
  3845. @command{tar} to print, for each directory in the archive, the list of
  3846. files in that directory at the time the archive was created. This
  3847. information is put out in a format that is not easy for humans to
  3848. read, but which is unambiguous for a program: each file name is
  3849. preceded by either a @samp{Y} if the file is present in the archive,
  3850. an @samp{N} if the file is not included in the archive, or a @samp{D}
  3851. if the file is a directory (and is included in the archive). Each
  3852. file name is terminated by a null character. The last file is followed
  3853. by an additional null and a newline to indicate the end of the data.
  3854. @value{op-listed-incremental} acts like @value{op-incremental}, but when
  3855. used in conjunction with @value{op-create} will also cause @command{tar}
  3856. to use the file @var{snapshot-file}, which contains information about
  3857. the state of the file system at the time of the last backup, to decide
  3858. which files to include in the archive being created. That file will
  3859. then be updated by @command{tar}. If the file @var{file} does not exist
  3860. when this option is specified, @command{tar} will create it, and include
  3861. all appropriate files in the archive.
  3862. The file @var{file}, which is archive independent, contains the date
  3863. it was last modified and a list of devices, inode numbers and
  3864. directory names. @command{tar} will archive files with newer mod dates
  3865. or inode change times, and directories with an unchanged inode number
  3866. and device but a changed directory name. The file is updated after
  3867. the files to be archived are determined, but before the new archive is
  3868. actually created.
  3869. Incremental dumps depend crucially on time stamps, so the results are
  3870. unreliable if you modify a file's time stamps during dumping (e.g.@:
  3871. with the @samp{--atime-preserve} option), or if you set the clock
  3872. backwards.
  3873. Despite it should be obvious that a device has a non-volatile value, NFS
  3874. devices have non-dependable values when an automounter gets in the picture.
  3875. This led to a great deal of spurious redumping in incremental dumps,
  3876. so it is somewhat useless to compare two NFS devices numbers over time.
  3877. So @command{tar} now considers all NFS devices as being equal when it comes
  3878. to comparing directories; this is fairly gross, but there does not seem
  3879. to be a better way to go.
  3880. @command{tar} doesn't access @var{snapshot-file} when
  3881. @value{op-create} or @value{op-list} are specified, but the
  3882. @value{op-listed-incremental} option must still be given. A
  3883. placeholder @var{snapshot-file} can be specified, e.g.,
  3884. @file{/dev/null}.
  3885. @FIXME{this section needs to be written}
  3886. @node Backup Levels
  3887. @section Levels of Backups
  3888. @UNREVISED
  3889. An archive containing all the files in the file system is called a
  3890. @dfn{full backup} or @dfn{full dump}. You could insure your data by
  3891. creating a full dump every day. This strategy, however, would waste a
  3892. substantial amount of archive media and user time, as unchanged files
  3893. are daily re-archived.
  3894. It is more efficient to do a full dump only occasionally. To back up
  3895. files between full dumps, you can a incremental dump. A @dfn{level
  3896. one} dump archives all the files that have changed since the last full
  3897. dump.
  3898. A typical dump strategy would be to perform a full dump once a week,
  3899. and a level one dump once a day. This means some versions of files
  3900. will in fact be archived more than once, but this dump strategy makes
  3901. it possible to restore a file system to within one day of accuracy by
  3902. only extracting two archives---the last weekly (full) dump and the
  3903. last daily (level one) dump. The only information lost would be in
  3904. files changed or created since the last daily backup. (Doing dumps
  3905. more than once a day is usually not worth the trouble).
  3906. @acronym{GNU} @command{tar} comes with scripts you can use to do full
  3907. and level-one dumps. Using scripts (shell programs) to perform
  3908. backups and restoration is a convenient and reliable alternative to
  3909. typing out file name lists and @command{tar} commands by hand.
  3910. Before you use these scripts, you need to edit the file
  3911. @file{backup-specs}, which specifies parameters used by the backup
  3912. scripts and by the restore script. @FIXME{There is no such restore
  3913. script!}@FIXME-xref{Script Syntax}Once the backup parameters
  3914. are set, you can perform backups or restoration by running the
  3915. appropriate script.
  3916. The name of the restore script is @code{restore}. @FIXME{There is
  3917. no such restore script!}The names of the level one and full backup
  3918. scripts are, respectively, @code{level-1} and @code{level-0}.
  3919. The @code{level-0} script also exists under the name @code{weekly}, and
  3920. the @code{level-1} under the name @code{daily}---these additional names
  3921. can be changed according to your backup schedule. @FIXME-xref{Scripted
  3922. Restoration, for more information on running the restoration script.}
  3923. @FIXME-xref{Scripted Backups, for more information on running the
  3924. backup scripts.}
  3925. @emph{Please Note:} The backup scripts and the restoration scripts are
  3926. designed to be used together. While it is possible to restore files by
  3927. hand from an archive which was created using a backup script, and to create
  3928. an archive by hand which could then be extracted using the restore script,
  3929. it is easier to use the scripts.@FIXME{There is no such restore script!}
  3930. @value{xref-incremental}, and @value{xref-listed-incremental},
  3931. before making such an attempt.
  3932. @FIXME{shorten node names}
  3933. @node Backup Parameters
  3934. @section Setting Parameters for Backups and Restoration
  3935. @UNREVISED
  3936. The file @file{backup-specs} specifies backup parameters for the
  3937. backup and restoration scripts provided with @command{tar}. You must
  3938. edit @file{backup-specs} to fit your system configuration and schedule
  3939. before using these scripts.
  3940. @FIXME{This about backup scripts needs to be written: BS is a shell
  3941. script .... thus ... @file{backup-specs} is in shell script syntax.}
  3942. @FIXME-xref{Script Syntax, for an explanation of this syntax.}
  3943. @FIXME{Whats a parameter .... looked at by the backup scripts
  3944. ... which will be expecting to find ... now syntax ... value is linked
  3945. to lame ... @file{backup-specs} specifies the following parameters:}
  3946. @table @samp
  3947. @item ADMINISTRATOR
  3948. The user name of the backup administrator.
  3949. @item BACKUP_HOUR
  3950. The hour at which the backups are done. This can be a number from 0
  3951. to 23, or the string @samp{now}.
  3952. @item TAPE_FILE
  3953. The device @command{tar} writes the archive to. This device should be
  3954. attached to the host on which the dump scripts are run.
  3955. @FIXME{examples for all ...}
  3956. @item TAPE_STATUS
  3957. The command to use to obtain the status of the archive device,
  3958. including error count. On some tape drives there may not be such a
  3959. command; in that case, simply use @samp{TAPE_STATUS=false}.
  3960. @item BLOCKING
  3961. The blocking factor @command{tar} will use when writing the dump archive.
  3962. @value{xref-blocking-factor}.
  3963. @item BACKUP_DIRS
  3964. A list of file systems to be dumped. You can include any directory
  3965. name in the list---subdirectories on that file system will be
  3966. included, regardless of how they may look to other networked machines.
  3967. Subdirectories on other file systems will be ignored.
  3968. The host name specifies which host to run @command{tar} on, and should
  3969. normally be the host that actually contains the file system. However,
  3970. the host machine must have @acronym{GNU} @command{tar} installed, and
  3971. must be able to access the directory containing the backup scripts and
  3972. their support files using the same file name that is used on the
  3973. machine where the scripts are run (ie. what @command{pwd} will print
  3974. when in that directory on that machine). If the host that contains
  3975. the file system does not have this capability, you can specify another
  3976. host as long as it can access the file system through NFS.
  3977. @item BACKUP_FILES
  3978. A list of individual files to be dumped. These should be accessible
  3979. from the machine on which the backup script is run.
  3980. @FIXME{Same file name, be specific. Through NFS ...}
  3981. @end table
  3982. @menu
  3983. * backup-specs example:: An Example Text of @file{Backup-specs}
  3984. * Script Syntax:: Syntax for @file{Backup-specs}
  3985. @end menu
  3986. @node backup-specs example
  3987. @subsection An Example Text of @file{Backup-specs}
  3988. @UNREVISED
  3989. The following is the text of @file{backup-specs} as it appears at FSF:
  3990. @example
  3991. # site-specific parameters for file system backup.
  3992. ADMINISTRATOR=friedman
  3993. BACKUP_HOUR=1
  3994. TAPE_FILE=/dev/nrsmt0
  3995. TAPE_STATUS="mts -t $TAPE_FILE"
  3996. BLOCKING=124
  3997. BACKUP_DIRS="
  3998. albert:/fs/fsf
  3999. apple-gunkies:/gd
  4000. albert:/fs/gd2
  4001. albert:/fs/gp
  4002. geech:/usr/jla
  4003. churchy:/usr/roland
  4004. albert:/
  4005. albert:/usr
  4006. apple-gunkies:/
  4007. apple-gunkies:/usr
  4008. gnu:/hack
  4009. gnu:/u
  4010. apple-gunkies:/com/mailer/gnu
  4011. apple-gunkies:/com/archive/gnu"
  4012. BACKUP_FILES="/com/mailer/aliases /com/mailer/league*[a-z]"
  4013. @end example
  4014. @node Script Syntax
  4015. @subsection Syntax for @file{Backup-specs}
  4016. @UNREVISED
  4017. @file{backup-specs} is in shell script syntax. The following
  4018. conventions should be considered when editing the script:
  4019. @FIXME{"conventions?"}
  4020. A quoted string is considered to be contiguous, even if it is on more
  4021. than one line. Therefore, you cannot include commented-out lines
  4022. within a multi-line quoted string. BACKUP_FILES and BACKUP_DIRS are
  4023. the two most likely parameters to be multi-line.
  4024. A quoted string typically cannot contain wildcards. In
  4025. @file{backup-specs}, however, the parameters BACKUP_DIRS and
  4026. BACKUP_FILES can contain wildcards.
  4027. @node Scripted Backups
  4028. @section Using the Backup Scripts
  4029. @UNREVISED
  4030. The syntax for running a backup script is:
  4031. @example
  4032. @file{script-name} [@var{time-to-be-run}]
  4033. @end example
  4034. where @var{time-to-be-run} can be a specific system time, or can be
  4035. @kbd{now}. If you do not specify a time, the script runs at the time
  4036. specified in @file{backup-specs}. @FIXME-pxref{Script Syntax}
  4037. You should start a script with a tape or disk mounted. Once you
  4038. start a script, it prompts you for new tapes or disks as it
  4039. needs them. Media volumes don't have to correspond to archive
  4040. files---a multi-volume archive can be started in the middle of a
  4041. tape that already contains the end of another multi-volume archive.
  4042. The @code{restore} script prompts for media by its archive volume,
  4043. so to avoid an error message you should keep track of which tape
  4044. (or disk) contains which volume of the archive. @FIXME{There is
  4045. no such restore script!} @FIXME-xref{Scripted Restoration}
  4046. @FIXME{Have file names changed?}
  4047. The backup scripts write two files on the file system. The first is a
  4048. record file in @file{/etc/tar-backup/}, which is used by the scripts
  4049. to store and retrieve information about which files were dumped. This
  4050. file is not meant to be read by humans, and should not be deleted by
  4051. them. @FIXME-xref{incremental and listed-incremental, for a more
  4052. detailed explanation of this file.}
  4053. The second file is a log file containing the names of the file systems
  4054. and files dumped, what time the backup was made, and any error
  4055. messages that were generated, as well as how much space was left in
  4056. the media volume after the last volume of the archive was written.
  4057. You should check this log file after every backup. The file name is
  4058. @file{log-@var{mmm-ddd-yyyy}-level-1} or
  4059. @file{log-@var{mmm-ddd-yyyy}-full}.
  4060. The script also prints the name of each system being dumped to the
  4061. standard output.
  4062. @node Scripted Restoration
  4063. @section Using the Restore Script
  4064. @UNREVISED
  4065. @ifset PUBLISH
  4066. The @command{tar} distribution does not provide restoring scripts.
  4067. @end ifset
  4068. @ifclear PUBLISH
  4069. @quotation
  4070. @strong{Warning:} The @acronym{GNU} @command{tar} distribution does @emph{not}
  4071. provide any such @code{restore} script yet. This section is only
  4072. listed here for documentation maintenance purposes. In any case,
  4073. all contents is subject to change as things develop.
  4074. @end quotation
  4075. @FIXME{A section on non-scripted restore may be a good idea.}
  4076. To restore files that were archived using a scripted backup, use the
  4077. @code{restore} script. The syntax for the script is:
  4078. where ***** are the file systems to restore from, and
  4079. ***** is a regular expression which specifies which files to
  4080. restore. If you specify --all, the script restores all the files
  4081. in the file system.
  4082. You should start the restore script with the media containing the
  4083. first volume of the archive mounted. The script will prompt for other
  4084. volumes as they are needed. If the archive is on tape, you don't need
  4085. to rewind the tape to to its beginning---if the tape head is
  4086. positioned past the beginning of the archive, the script will rewind
  4087. the tape as needed. @FIXME-xref{Media, for a discussion of tape
  4088. positioning.}
  4089. If you specify @samp{--all} as the @var{files} argument, the
  4090. @code{restore} script extracts all the files in the archived file
  4091. system into the active file system.
  4092. @quotation
  4093. @strong{Warning:} The script will delete files from the active file
  4094. system if they were not in the file system when the archive was made.
  4095. @end quotation
  4096. @value{xref-incremental}, and @value{ref-listed-incremental},
  4097. for an explanation of how the script makes that determination.
  4098. @FIXME{this may be an option, not a given}
  4099. @end ifclear
  4100. @node Choosing
  4101. @chapter Choosing Files and Names for @command{tar}
  4102. @UNREVISED
  4103. @FIXME{Melissa (still) Doesn't Really Like This ``Intro'' Paragraph!!!}
  4104. Certain options to @command{tar} enable you to specify a name for your
  4105. archive. Other options let you decide which files to include or exclude
  4106. from the archive, based on when or whether files were modified, whether
  4107. the file names do or don't match specified patterns, or whether files
  4108. are in specified directories.
  4109. @menu
  4110. * file:: Choosing the Archive's Name
  4111. * Selecting Archive Members::
  4112. * files:: Reading Names from a File
  4113. * exclude:: Excluding Some Files
  4114. * Wildcards::
  4115. * after:: Operating Only on New Files
  4116. * recurse:: Descending into Directories
  4117. * one:: Crossing Filesystem Boundaries
  4118. @end menu
  4119. @node file
  4120. @section Choosing and Naming Archive Files
  4121. @cindex Naming an archive
  4122. @cindex Archive Name
  4123. @cindex Directing output
  4124. @cindex Choosing an archive file
  4125. @cindex Where is the archive?
  4126. @UNREVISED
  4127. @FIXME{should the title of this section actually be, "naming an
  4128. archive"?}
  4129. By default, @command{tar} uses an archive file name that was compiled when
  4130. it was built on the system; usually this name refers to some physical
  4131. tape drive on the machine. However, the person who installed @command{tar}
  4132. on the system may not set the default to a meaningful value as far as
  4133. most users are concerned. As a result, you will usually want to tell
  4134. @command{tar} where to find (or create) the archive. The @value{op-file}
  4135. option allows you to either specify or name a file to use as the archive
  4136. instead of the default archive file location.
  4137. @table @kbd
  4138. @item --file=@var{archive-name}
  4139. @itemx -f @var{archive-name}
  4140. Name the archive to create or operate on. Use in conjunction with
  4141. any operation.
  4142. @end table
  4143. For example, in this @command{tar} command,
  4144. @example
  4145. $ @kbd{tar -cvf collection.tar blues folk jazz}
  4146. @end example
  4147. @noindent
  4148. @file{collection.tar} is the name of the archive. It must directly
  4149. follow the @samp{-f} option, since whatever directly follows @samp{-f}
  4150. @emph{will} end up naming the archive. If you neglect to specify an
  4151. archive name, you may end up overwriting a file in the working directory
  4152. with the archive you create since @command{tar} will use this file's name
  4153. for the archive name.
  4154. An archive can be saved as a file in the file system, sent through a
  4155. pipe or over a network, or written to an I/O device such as a tape,
  4156. floppy disk, or CD write drive.
  4157. @cindex Writing new archives
  4158. @cindex Archive creation
  4159. If you do not name the archive, @command{tar} uses the value of the
  4160. environment variable @env{TAPE} as the file name for the archive. If
  4161. that is not available, @command{tar} uses a default, compiled-in archive
  4162. name, usually that for tape unit zero (ie. @file{/dev/tu00}).
  4163. @command{tar} always needs an archive name.
  4164. If you use @file{-} as an @var{archive-name}, @command{tar} reads the
  4165. archive from standard input (when listing or extracting files), or
  4166. writes it to standard output (when creating an archive). If you use
  4167. @file{-} as an @var{archive-name} when modifying an archive,
  4168. @command{tar} reads the original archive from its standard input and
  4169. writes the entire new archive to its standard output.
  4170. @FIXME{might want a different example here; this is already used in
  4171. "notable tar usages".}
  4172. @example
  4173. $ @kbd{cd sourcedir; tar -cf - . | (cd targetdir; tar -xf -)}
  4174. @end example
  4175. @FIXME{help!}
  4176. @cindex Standard input and output
  4177. @cindex tar to standard input and output
  4178. To specify an archive file on a device attached to a remote machine,
  4179. use the following:
  4180. @example
  4181. @kbd{--file=@var{hostname}:/@var{dev}/@var{file name}}
  4182. @end example
  4183. @noindent
  4184. @command{tar} will complete the remote connection, if possible, and
  4185. prompt you for a username and password. If you use
  4186. @samp{--file=@@@var{hostname}:/@var{dev}/@var{file name}}, @command{tar}
  4187. will complete the remote connection, if possible, using your username
  4188. as the username on the remote machine.
  4189. If the archive file name includes a colon (@samp{:}), then it is assumed
  4190. to be a file on another machine. If the archive file is
  4191. @samp{@var{user}@@@var{host}:@var{file}}, then @var{file} is used on the
  4192. host @var{host}. The remote host is accessed using the @command{rsh}
  4193. program, with a username of @var{user}. If the username is omitted
  4194. (along with the @samp{@@} sign), then your user name will be used.
  4195. (This is the normal @command{rsh} behavior.) It is necessary for the
  4196. remote machine, in addition to permitting your @command{rsh} access, to
  4197. have the @file{/usr/ucb/rmt} program installed. If you need to use a
  4198. file whose name includes a colon, then the remote tape drive behavior
  4199. can be inhibited by using the @value{op-force-local} option.
  4200. @FIXME{i know we went over this yesterday, but bob (and now i do again,
  4201. too) thinks it's out of the middle of nowhere. it doesn't seem to tie
  4202. into what came before it well enough <<i moved it now, is it better
  4203. here?>>. bob also comments that if Amanda isn't free software, we
  4204. shouldn't mention it..}
  4205. When the archive is being created to @file{/dev/null}, @acronym{GNU}
  4206. @command{tar} tries to minimize input and output operations. The
  4207. Amanda backup system, when used with @acronym{GNU} @command{tar}, has
  4208. an initial sizing pass which uses this feature.
  4209. @node Selecting Archive Members
  4210. @section Selecting Archive Members
  4211. @cindex Specifying files to act on
  4212. @cindex Specifying archive members
  4213. @dfn{File Name arguments} specify which files in the file system
  4214. @command{tar} operates on, when creating or adding to an archive, or which
  4215. archive members @command{tar} operates on, when reading or deleting from
  4216. an archive. @xref{Operations}.
  4217. To specify file names, you can include them as the last arguments on
  4218. the command line, as follows:
  4219. @smallexample
  4220. @kbd{tar} @var{operation} [@var{option1} @var{option2} @dots{}] [@var{file name-1} @var{file name-2} @dots{}]
  4221. @end smallexample
  4222. If you specify a directory name as a file name argument, all the files
  4223. in that directory are operated on by @command{tar}.
  4224. If you do not specify files when @command{tar} is invoked with
  4225. @value{op-create}, @command{tar} operates on all the non-directory files in
  4226. the working directory. If you specify either @value{op-list} or
  4227. @value{op-extract}, @command{tar} operates on all the archive members in the
  4228. archive. If you specify any operation other than one of these three,
  4229. @command{tar} does nothing.
  4230. By default, @command{tar} takes file names from the command line. However,
  4231. there are other ways to specify file or member names, or to modify the
  4232. manner in which @command{tar} selects the files or members upon which to
  4233. operate. @FIXME{add xref here}In general, these methods work both for
  4234. specifying the names of files and archive members.
  4235. @node files
  4236. @section Reading Names from a File
  4237. @UNREVISED
  4238. @cindex Reading file names from a file
  4239. @cindex Lists of file names
  4240. @cindex File Name arguments, alternatives
  4241. Instead of giving the names of files or archive members on the command
  4242. line, you can put the names into a file, and then use the
  4243. @value{op-files-from} option to @command{tar}. Give the name of the file
  4244. which contains the list of files to include as the argument to
  4245. @samp{--files-from}. In the list, the file names should be separated by
  4246. newlines. You will frequently use this option when you have generated
  4247. the list of files to archive with the @command{find} utility.
  4248. @table @kbd
  4249. @item --files-from=@var{file name}
  4250. @itemx -T @var{file name}
  4251. Get names to extract or create from file @var{file name}.
  4252. @end table
  4253. If you give a single dash as a file name for @samp{--files-from}, (i.e.,
  4254. you specify either @samp{--files-from=-} or @samp{-T -}), then the file
  4255. names are read from standard input.
  4256. Unless you are running @command{tar} with @samp{--create}, you can not use
  4257. both @samp{--files-from=-} and @samp{--file=-} (@samp{-f -}) in the same
  4258. command.
  4259. @FIXME{add bob's example, from his message on 2-10-97}
  4260. The following example shows how to use @command{find} to generate a list of
  4261. files smaller than 400K in length and put that list into a file
  4262. called @file{small-files}. You can then use the @samp{-T} option to
  4263. @command{tar} to specify the files from that file, @file{small-files}, to
  4264. create the archive @file{little.tgz}. (The @samp{-z} option to
  4265. @command{tar} compresses the archive with @command{gzip}; @pxref{gzip} for
  4266. more information.)
  4267. @example
  4268. $ @kbd{find . -size -400 -print > small-files}
  4269. $ @kbd{tar -c -v -z -T small-files -f little.tgz}
  4270. @end example
  4271. @noindent
  4272. @FIXME{say more here to conclude the example/section?}
  4273. @menu
  4274. * nul::
  4275. @end menu
  4276. @node nul
  4277. @subsection @kbd{NUL} Terminated File Names
  4278. @cindex File names, terminated by @kbd{NUL}
  4279. @cindex @kbd{NUL} terminated file names
  4280. The @value{op-null} option causes @value{op-files-from} to read file
  4281. names terminated by a @code{NUL} instead of a newline, so files whose
  4282. names contain newlines can be archived using @samp{--files-from}.
  4283. @table @kbd
  4284. @item --null
  4285. Only consider @kbd{NUL} terminated file names, instead of files that
  4286. terminate in a newline.
  4287. @end table
  4288. The @samp{--null} option is just like the one in @acronym{GNU}
  4289. @command{xargs} and @command{cpio}, and is useful with the
  4290. @samp{-print0} predicate of @acronym{GNU} @command{find}. In
  4291. @command{tar}, @samp{--null} also causes @value{op-directory} options
  4292. to be treated as file names to archive, in case there are any files
  4293. out there called @file{-C}.
  4294. This example shows how to use @command{find} to generate a list of files
  4295. larger than 800K in length and put that list into a file called
  4296. @file{long-files}. The @samp{-print0} option to @command{find} just just
  4297. like @samp{-print}, except that it separates files with a @kbd{NUL}
  4298. rather than with a newline. You can then run @command{tar} with both the
  4299. @samp{--null} and @samp{-T} options to specify that @command{tar} get the
  4300. files from that file, @file{long-files}, to create the archive
  4301. @file{big.tgz}. The @samp{--null} option to @command{tar} will cause
  4302. @command{tar} to recognize the @kbd{NUL} separator between files.
  4303. @example
  4304. $ @kbd{find . -size +800 -print0 > long-files}
  4305. $ @kbd{tar -c -v --null --files-from=long-files --file=big.tar}
  4306. @end example
  4307. @FIXME{say anything else here to conclude the section?}
  4308. @node exclude
  4309. @section Excluding Some Files
  4310. @cindex File names, excluding files by
  4311. @cindex Excluding files by name and pattern
  4312. @cindex Excluding files by file system
  4313. @UNREVISED
  4314. To avoid operating on files whose names match a particular pattern,
  4315. use the @value{op-exclude} or @value{op-exclude-from} options.
  4316. @table @kbd
  4317. @item --exclude=@var{pattern}
  4318. Causes @command{tar} to ignore files that match the @var{pattern}.
  4319. @end table
  4320. @findex exclude
  4321. The @value{op-exclude} option prevents any file or member whose name
  4322. matches the shell wildcard (@var{pattern}) from being operated on.
  4323. For example, to create an archive with all the contents of the directory
  4324. @file{src} except for files whose names end in @file{.o}, use the
  4325. command @samp{tar -cf src.tar --exclude='*.o' src}.
  4326. You may give multiple @samp{--exclude} options.
  4327. @table @kbd
  4328. @item --exclude-from=@var{file}
  4329. @itemx -X @var{file}
  4330. Causes @command{tar} to ignore files that match the patterns listed in
  4331. @var{file}.
  4332. @end table
  4333. @findex exclude-from
  4334. Use the @samp{--exclude-from=@var{file-of-patterns}} option to read a
  4335. list of patterns, one per line, from @var{file}; @command{tar} will
  4336. ignore files matching those patterns. Thus if @command{tar} is
  4337. called as @w{@samp{tar -c -X foo .}} and the file @file{foo} contains a
  4338. single line @file{*.o}, no files whose names end in @file{.o} will be
  4339. added to the archive.
  4340. @FIXME{do the exclude options files need to have stuff separated by
  4341. newlines the same as the files-from option does?}
  4342. @menu
  4343. * controlling pattern-patching with exclude::
  4344. * problems with exclude::
  4345. @end menu
  4346. @node controlling pattern-patching with exclude
  4347. @unnumberedsubsec Controlling Pattern-Matching with the @code{exclude} Options
  4348. Normally, a pattern matches a name if an initial subsequence of the
  4349. name's components matches the pattern, where @samp{*}, @samp{?}, and
  4350. @samp{[...]} are the usual shell wildcards, @samp{\} escapes wildcards,
  4351. and wildcards can match @samp{/}.
  4352. Other than optionally stripping leading @samp{/} from names
  4353. (@pxref{absolute}), patterns and names are used as-is. For
  4354. example, trailing @samp{/} is not trimmed from a user-specified name
  4355. before deciding whether to exclude it.
  4356. However, this matching procedure can be altered by the options listed
  4357. below. These options accumulate. For example:
  4358. @example
  4359. --ignore-case --exclude='makefile' --no-ignore-case ---exclude='readme'
  4360. @end example
  4361. ignores case when excluding @samp{makefile}, but not when excluding
  4362. @samp{readme}.
  4363. @table @option
  4364. @item --anchored
  4365. @itemx --no-anchored
  4366. If anchored (the default), a pattern must match an initial subsequence
  4367. of the name's components. Otherwise, the pattern can match any subsequence.
  4368. @item --ignore-case
  4369. @itemx --no-ignore-case
  4370. When ignoring case, upper-case patterns match lower-case names and vice versa.
  4371. When not ignoring case (the default), matching is case-sensitive.
  4372. @item --wildcards
  4373. @itemx --no-wildcards
  4374. When using wildcards (the default), @samp{*}, @samp{?}, and @samp{[...]}
  4375. are the usual shell wildcards, and @samp{\} escapes wildcards.
  4376. Otherwise, none of these characters are special, and patterns must match
  4377. names literally.
  4378. @item --wildcards-match-slash
  4379. @itemx --no-wildcards-match-slash
  4380. When wildcards match slash (the default), a wildcard like @samp{*} in
  4381. the pattern can match a @samp{/} in the name. Otherwise, @samp{/} is
  4382. matched only by @samp{/}.
  4383. @end table
  4384. The @option{--recursion} and @option{--no-recursion} options
  4385. (@pxref{recurse}) also affect how exclude patterns are interpreted. If
  4386. recursion is in effect, a pattern excludes a name if it matches any of
  4387. the name's parent directories.
  4388. @node problems with exclude
  4389. @unnumberedsubsec Problems with Using the @code{exclude} Options
  4390. Some users find @samp{exclude} options confusing. Here are some common
  4391. pitfalls:
  4392. @itemize @bullet
  4393. @item
  4394. The main operating mode of @command{tar} does not act on a path name
  4395. explicitly listed on the command line if one of its file name
  4396. components is excluded. In the example above, if
  4397. you create an archive and exclude files that end with @samp{*.o}, but
  4398. explicitly name the file @samp{dir.o/foo} after all the options have been
  4399. listed, @samp{dir.o/foo} will be excluded from the archive.
  4400. @item
  4401. You can sometimes confuse the meanings of @value{op-exclude} and
  4402. @value{op-exclude-from}. Be careful: use @value{op-exclude} when files
  4403. to be excluded are given as a pattern on the command line. Use
  4404. @samp{--exclude-from=@var{file-of-patterns}} to introduce the name of a
  4405. file which contains a list of patterns, one per line; each of these
  4406. patterns can exclude zero, one, or many files.
  4407. @item
  4408. When you use @value{op-exclude}, be sure to quote the @var{pattern}
  4409. parameter, so @acronym{GNU} @command{tar} sees wildcard characters
  4410. like @samp{*}. If you do not do this, the shell might expand the
  4411. @samp{*} itself using files at hand, so @command{tar} might receive a
  4412. list of files instead of one pattern, or none at all, making the
  4413. command somewhat illegal. This might not correspond to what you want.
  4414. For example, write:
  4415. @example
  4416. $ @kbd{tar -c -f @var{archive.tar} --exclude '*.o' @var{directory}}
  4417. @end example
  4418. @noindent
  4419. rather than:
  4420. @example
  4421. $ @kbd{tar -c -f @var{archive.tar} --exclude *.o @var{directory}}
  4422. @end example
  4423. @item
  4424. You must use use shell syntax, or globbing, rather than @code{regexp}
  4425. syntax, when using exclude options in @command{tar}. If you try to use
  4426. @code{regexp} syntax to describe files to be excluded, your command
  4427. might fail.
  4428. @item
  4429. In earlier versions of @command{tar}, what is now the
  4430. @samp{--exclude-from=@var{file-of-patterns}} option was called
  4431. @samp{--exclude=@var{pattern}} instead. Now,
  4432. @samp{--exclude=@var{pattern}} applies to patterns listed on the command
  4433. line and @samp{--exclude-from=@var{file-of-patterns}} applies to
  4434. patterns listed in a file.
  4435. @end itemize
  4436. @node Wildcards
  4437. @section Wildcards Patterns and Matching
  4438. @dfn{Globbing} is the operation by which @dfn{wildcard} characters,
  4439. @samp{*} or @samp{?} for example, are replaced and expanded into all
  4440. existing files matching the given pattern. However, @command{tar} often
  4441. uses wildcard patterns for matching (or globbing) archive members instead
  4442. of actual files in the filesystem. Wildcard patterns are also used for
  4443. verifying volume labels of @command{tar} archives. This section has the
  4444. purpose of explaining wildcard syntax for @command{tar}.
  4445. @FIXME{the next few paragraphs need work.}
  4446. A @var{pattern} should be written according to shell syntax, using wildcard
  4447. characters to effect globbing. Most characters in the pattern stand
  4448. for themselves in the matched string, and case is significant: @samp{a}
  4449. will match only @samp{a}, and not @samp{A}. The character @samp{?} in the
  4450. pattern matches any single character in the matched string. The character
  4451. @samp{*} in the pattern matches zero, one, or more single characters in
  4452. the matched string. The character @samp{\} says to take the following
  4453. character of the pattern @emph{literally}; it is useful when one needs to
  4454. match the @samp{?}, @samp{*}, @samp{[} or @samp{\} characters, themselves.
  4455. The character @samp{[}, up to the matching @samp{]}, introduces a character
  4456. class. A @dfn{character class} is a list of acceptable characters
  4457. for the next single character of the matched string. For example,
  4458. @samp{[abcde]} would match any of the first five letters of the alphabet.
  4459. Note that within a character class, all of the ``special characters''
  4460. listed above other than @samp{\} lose their special meaning; for example,
  4461. @samp{[-\\[*?]]} would match any of the characters, @samp{-}, @samp{\},
  4462. @samp{[}, @samp{*}, @samp{?}, or @samp{]}. (Due to parsing constraints,
  4463. the characters @samp{-} and @samp{]} must either come @emph{first} or
  4464. @emph{last} in a character class.)
  4465. @cindex Excluding characters from a character class
  4466. @cindex Character class, excluding characters from
  4467. If the first character of the class after the opening @samp{[}
  4468. is @samp{!} or @samp{^}, then the meaning of the class is reversed.
  4469. Rather than listing character to match, it lists those characters which
  4470. are @emph{forbidden} as the next single character of the matched string.
  4471. Other characters of the class stand for themselves. The special
  4472. construction @samp{[@var{a}-@var{e}]}, using an hyphen between two
  4473. letters, is meant to represent all characters between @var{a} and
  4474. @var{e}, inclusive.
  4475. @FIXME{need to add a sentence or so here to make this clear for those
  4476. who don't have dan around.}
  4477. Periods (@samp{.}) or forward slashes (@samp{/}) are not considered
  4478. special for wildcard matches. However, if a pattern completely matches
  4479. a directory prefix of a matched string, then it matches the full matched
  4480. string: excluding a directory also excludes all the files beneath it.
  4481. @node after
  4482. @section Operating Only on New Files
  4483. @cindex Excluding file by age
  4484. @cindex Modification time, excluding files by
  4485. @cindex Age, excluding files by
  4486. @UNREVISED
  4487. The @value{op-after-date} option causes @command{tar} to only work on files
  4488. whose modification or inode-changed times are newer than the @var{date}
  4489. given. If @var{date} starts with @samp{/} or @samp{.}, it is taken to
  4490. be a file name; the last-modified time of that file is used as the date.
  4491. If you use this option when creating or appending to an archive,
  4492. the archive will only include new files. If you use @samp{--after-date}
  4493. when extracting an archive, @command{tar} will only extract files newer
  4494. than the @var{date} you specify.
  4495. If you only want @command{tar} to make the date comparison based on
  4496. modification of the actual contents of the file (rather than inode
  4497. changes), then use the @value{op-newer-mtime} option.
  4498. You may use these options with any operation. Note that these options
  4499. differ from the @value{op-update} operation in that they allow you to
  4500. specify a particular date against which @command{tar} can compare when
  4501. deciding whether or not to archive the files.
  4502. @table @kbd
  4503. @item --after-date=@var{date}
  4504. @itemx --newer=@var{date}
  4505. @itemx -N @var{date}
  4506. Only store files newer than @var{date}.
  4507. Acts on files only if their modification or inode-changed times are
  4508. later than @var{date}. Use in conjunction with any operation.
  4509. If @var{date} starts with @samp{/} or @samp{.}, it is taken to be a file
  4510. name; the last-modified time of that file is used as the date.
  4511. @item --newer-mtime=@var{date}
  4512. Acts like @value{op-after-date}, but only looks at modification times.
  4513. @end table
  4514. These options limit @command{tar} to only operating on files which have
  4515. been modified after the date specified. A file is considered to have
  4516. changed if the contents have been modified, or if the owner,
  4517. permissions, and so forth, have been changed. (For more information on
  4518. how to specify a date, see @ref{Date input formats}; remember that the
  4519. entire date argument must be quoted if it contains any spaces.)
  4520. Gurus would say that @value{op-after-date} tests both the @code{mtime}
  4521. (time the contents of the file were last modified) and @code{ctime}
  4522. (time the file's status was last changed: owner, permissions, etc)
  4523. fields, while @value{op-newer-mtime} tests only @code{mtime} field.
  4524. To be precise, @value{op-after-date} checks @emph{both} @code{mtime} and
  4525. @code{ctime} and processes the file if either one is more recent than
  4526. @var{date}, while @value{op-newer-mtime} only checks @code{mtime} and
  4527. disregards @code{ctime}. Neither uses @code{atime} (the last time the
  4528. contents of the file were looked at).
  4529. Date specifiers can have embedded spaces. Because of this, you may need
  4530. to quote date arguments to keep the shell from parsing them as separate
  4531. arguments.
  4532. @FIXME{Need example of --newer-mtime with quoted argument.}
  4533. @quotation
  4534. @strong{Please Note:} @value{op-after-date} and @value{op-newer-mtime}
  4535. should not be used for incremental backups. Some files (such as those
  4536. in renamed directories) are not selected properly by these options.
  4537. @xref{incremental and listed-incremental}.
  4538. @end quotation
  4539. @noindent
  4540. @FIXME{which tells -- need to fill this in!}
  4541. @node recurse
  4542. @section Descending into Directories
  4543. @cindex Avoiding recursion in directories
  4544. @cindex Descending directories, avoiding
  4545. @cindex Directories, avoiding recursion
  4546. @cindex Recursion in directories, avoiding
  4547. @UNREVISED
  4548. @FIXME{arrggh! this is still somewhat confusing to me. :-< }
  4549. @FIXME{show dan bob's comments, from 2-10-97}
  4550. Usually, @command{tar} will recursively explore all directories (either
  4551. those given on the command line or through the @value{op-files-from}
  4552. option) for the various files they contain. However, you may not always
  4553. want @command{tar} to act this way.
  4554. The @value{op-no-recursion} option inhibits @command{tar}'s recursive descent
  4555. into specified directories. If you specify @samp{--no-recursion}, you can
  4556. use the @command{find} utility for hunting through levels of directories to
  4557. construct a list of file names which you could then pass to @command{tar}.
  4558. @command{find} allows you to be more selective when choosing which files to
  4559. archive; see @ref{files} for more information on using @command{find} with
  4560. @command{tar}, or look.
  4561. @table @kbd
  4562. @item --no-recursion
  4563. Prevents @command{tar} from recursively descending directories.
  4564. @item --recursion
  4565. Requires @command{tar} to recursively descend directories.
  4566. This is the default.
  4567. @end table
  4568. When you use @samp{--no-recursion}, @acronym{GNU} @command{tar} grabs
  4569. directory entries themselves, but does not descend on them
  4570. recursively. Many people use @command{find} for locating files they
  4571. want to back up, and since @command{tar} @emph{usually} recursively
  4572. descends on directories, they have to use the @samp{@w{! -d}} option
  4573. to @command{find} @FIXME{needs more explanation or a cite to another
  4574. info file}as they usually do not want all the files in a directory.
  4575. They then use the @value{op-files-from} option to archive the files
  4576. located via @command{find}.
  4577. The problem when restoring files archived in this manner is that the
  4578. directories themselves are not in the archive; so the
  4579. @value{op-same-permissions} option does not affect them---while users
  4580. might really like it to. Specifying @value{op-no-recursion} is a way to
  4581. tell @command{tar} to grab only the directory entries given to it, adding
  4582. no new files on its own.
  4583. The @value{op-no-recursion} option also applies when extracting: it
  4584. causes @command{tar} to extract only the matched directory entries, not
  4585. the files under those directories.
  4586. The @value{op-no-recursion} option also affects how exclude patterns
  4587. are interpreted (@pxref{controlling pattern-patching with exclude}).
  4588. The @option{--no-recursion} and @option{--recursion} options apply to
  4589. later options and operands, and can be overridden by later occurrences
  4590. of @option{--no-recursion} and @option{--recursion}. For example:
  4591. @example
  4592. $ @kbd{tar -cf jams.tar --norecursion grape --recursion grape/concord}
  4593. @end example
  4594. @noindent
  4595. creates an archive with one entry for @file{grape}, and the recursive
  4596. contents of @file{grape/concord}, but no entries under @file{grape}
  4597. other than @file{grape/concord}.
  4598. @node one
  4599. @section Crossing Filesystem Boundaries
  4600. @cindex File system boundaries, not crossing
  4601. @UNREVISED
  4602. @command{tar} will normally automatically cross file system boundaries in
  4603. order to archive files which are part of a directory tree. You can
  4604. change this behavior by running @command{tar} and specifying
  4605. @value{op-one-file-system}. This option only affects files that are
  4606. archived because they are in a directory that is being archived;
  4607. @command{tar} will still archive files explicitly named on the command line
  4608. or through @value{op-files-from}, regardless of where they reside.
  4609. @table @kbd
  4610. @item --one-file-system
  4611. @itemx -l
  4612. Prevents @command{tar} from crossing file system boundaries when
  4613. archiving. Use in conjunction with any write operation.
  4614. @end table
  4615. The @samp{--one-file-system} option causes @command{tar} to modify its
  4616. normal behavior in archiving the contents of directories. If a file in
  4617. a directory is not on the same filesystem as the directory itself, then
  4618. @command{tar} will not archive that file. If the file is a directory
  4619. itself, @command{tar} will not archive anything beneath it; in other words,
  4620. @command{tar} will not cross mount points.
  4621. It is reported that using this option, the mount point is is archived,
  4622. but nothing under it.
  4623. This option is useful for making full or incremental archival backups of
  4624. a file system. If this option is used in conjunction with
  4625. @value{op-verbose}, files that are excluded are mentioned by name on the
  4626. standard error.
  4627. @menu
  4628. * directory:: Changing Directory
  4629. * absolute:: Absolute File Names
  4630. @end menu
  4631. @node directory
  4632. @subsection Changing the Working Directory
  4633. @FIXME{need to read over this node now for continuity; i've switched
  4634. things around some.}
  4635. @cindex Changing directory mid-stream
  4636. @cindex Directory, changing mid-stream
  4637. @cindex Working directory, specifying
  4638. @UNREVISED
  4639. To change the working directory in the middle of a list of file names,
  4640. either on the command line or in a file specified using
  4641. @value{op-files-from}, use @value{op-directory}. This will change the
  4642. working directory to the directory @var{directory} after that point in
  4643. the list.
  4644. @table @kbd
  4645. @item --directory=@var{directory}
  4646. @itemx -C @var{directory}
  4647. Changes the working directory in the middle of a command line.
  4648. @end table
  4649. For example,
  4650. @example
  4651. $ @kbd{tar -c -f jams.tar grape prune -C food cherry}
  4652. @end example
  4653. @noindent
  4654. will place the files @file{grape} and @file{prune} from the current
  4655. directory into the archive @file{jams.tar}, followed by the file
  4656. @file{cherry} from the directory @file{food}. This option is especially
  4657. useful when you have several widely separated files that you want to
  4658. store in the same archive.
  4659. Note that the file @file{cherry} is recorded in the archive under the
  4660. precise name @file{cherry}, @emph{not} @file{food/cherry}. Thus, the
  4661. archive will contain three files that all appear to have come from the
  4662. same directory; if the archive is extracted with plain @samp{tar
  4663. --extract}, all three files will be written in the current directory.
  4664. Contrast this with the command,
  4665. @example
  4666. $ @kbd{tar -c -f jams.tar grape prune -C food red/cherry}
  4667. @end example
  4668. @noindent
  4669. which records the third file in the archive under the name
  4670. @file{red/cherry} so that, if the archive is extracted using
  4671. @samp{tar --extract}, the third file will be written in a subdirectory
  4672. named @file{orange-colored}.
  4673. You can use the @samp{--directory} option to make the archive
  4674. independent of the original name of the directory holding the files.
  4675. The following command places the files @file{/etc/passwd},
  4676. @file{/etc/hosts}, and @file{/lib/libc.a} into the archive
  4677. @file{foo.tar}:
  4678. @example
  4679. $ @kbd{tar -c -f foo.tar -C /etc passwd hosts -C /lib libc.a}
  4680. @end example
  4681. @noindent
  4682. However, the names of the archive members will be exactly what they were
  4683. on the command line: @file{passwd}, @file{hosts}, and @file{libc.a}.
  4684. They will not appear to be related by file name to the original
  4685. directories where those files were located.
  4686. Note that @samp{--directory} options are interpreted consecutively. If
  4687. @samp{--directory} specifies a relative file name, it is interpreted
  4688. relative to the then current directory, which might not be the same as
  4689. the original current working directory of @command{tar}, due to a previous
  4690. @samp{--directory} option.
  4691. @FIXME{dan: does this mean that you *can* use the short option form, but
  4692. you can *not* use the long option form with --files-from? or is this
  4693. totally screwed?}
  4694. When using @samp{--files-from} (@pxref{files}), you can put @samp{-C}
  4695. options in the file list. Unfortunately, you cannot put
  4696. @samp{--directory} options in the file list. (This interpretation can
  4697. be disabled by using the @value{op-null} option.)
  4698. @node absolute
  4699. @subsection Absolute File Names
  4700. @UNREVISED
  4701. @table @kbd
  4702. @item -P
  4703. @itemx --absolute-names
  4704. Do not strip leading slashes from file names, and permit file names
  4705. containing a @file{..} file name component.
  4706. @end table
  4707. By default, @acronym{GNU} @command{tar} drops a leading @samp{/} on
  4708. input or output, and complains about file names containing a @file{..}
  4709. component. This option turns off this behavior.
  4710. When @command{tar} extracts archive members from an archive, it strips any
  4711. leading slashes (@samp{/}) from the member name. This causes absolute
  4712. member names in the archive to be treated as relative file names. This
  4713. allows you to have such members extracted wherever you want, instead of
  4714. being restricted to extracting the member in the exact directory named
  4715. in the archive. For example, if the archive member has the name
  4716. @file{/etc/passwd}, @command{tar} will extract it as if the name were
  4717. really @file{etc/passwd}.
  4718. File names containing @file{..} can cause problems when extracting, so
  4719. @command{tar} normally warns you about such files when creating an
  4720. archive, and rejects attempts to extracts such files.
  4721. Other @command{tar} programs do not do this. As a result, if you
  4722. create an archive whose member names start with a slash, they will be
  4723. difficult for other people with a non-@acronym{GNU} @command{tar}
  4724. program to use. Therefore, @acronym{GNU} @command{tar} also strips
  4725. leading slashes from member names when putting members into the
  4726. archive. For example, if you ask @command{tar} to add the file
  4727. @file{/bin/ls} to an archive, it will do so, but the member name will
  4728. be @file{bin/ls}.
  4729. If you use the @value{op-absolute-names} option, @command{tar} will do
  4730. none of these transformations.
  4731. To archive or extract files relative to the root directory, specify
  4732. the @value{op-absolute-names} option.
  4733. Normally, @command{tar} acts on files relative to the working
  4734. directory---ignoring superior directory names when archiving, and
  4735. ignoring leading slashes when extracting.
  4736. When you specify @value{op-absolute-names}, @command{tar} stores file names
  4737. including all superior directory names, and preserves leading slashes.
  4738. If you only invoked @command{tar} from the root directory you would never
  4739. need the @value{op-absolute-names} option, but using this option may be
  4740. more convenient than switching to root.
  4741. @FIXME{Should be an example in the tutorial/wizardry section using this
  4742. to transfer files between systems.}
  4743. @FIXME{Is write access an issue?}
  4744. @table @kbd
  4745. @item --absolute-names
  4746. Preserves full file names (including superior directory names) when
  4747. archiving files. Preserves leading slash when extracting files.
  4748. @end table
  4749. @FIXME{this is still horrible; need to talk with dan on monday.}
  4750. @command{tar} prints out a message about removing the @samp{/} from
  4751. file names. This message appears once per @acronym{GNU} @command{tar}
  4752. invocation. It represents something which ought to be told; ignoring
  4753. what it means can cause very serious surprises, later.
  4754. Some people, nevertheless, do not want to see this message. Wanting to
  4755. play really dangerously, one may of course redirect @command{tar} standard
  4756. error to the sink. For example, under @command{sh}:
  4757. @example
  4758. $ @kbd{tar -c -f archive.tar /home 2> /dev/null}
  4759. @end example
  4760. @noindent
  4761. Another solution, both nicer and simpler, would be to change to
  4762. the @file{/} directory first, and then avoid absolute notation.
  4763. For example:
  4764. @example
  4765. $ @kbd{(cd / && tar -c -f archive.tar home)}
  4766. $ @kbd{tar -c -f archive.tar -C / home}
  4767. @end example
  4768. @include getdate.texi
  4769. @node Formats
  4770. @chapter Controlling the Archive Format
  4771. @FIXME{need an intro here}
  4772. @menu
  4773. * Portability:: Making @command{tar} Archives More Portable
  4774. * Compression:: Using Less Space through Compression
  4775. * Attributes:: Handling File Attributes
  4776. * Standard:: The Standard Format
  4777. * Extensions:: @acronym{GNU} Extensions to the Archive Format
  4778. * cpio:: Comparison of @command{tar} and @command{cpio}
  4779. @end menu
  4780. @node Portability
  4781. @section Making @command{tar} Archives More Portable
  4782. Creating a @command{tar} archive on a particular system that is meant to be
  4783. useful later on many other machines and with other versions of @command{tar}
  4784. is more challenging than you might think. @command{tar} archive formats
  4785. have been evolving since the first versions of Unix. Many such formats
  4786. are around, and are not always compatible with each other. This section
  4787. discusses a few problems, and gives some advice about making @command{tar}
  4788. archives more portable.
  4789. One golden rule is simplicity. For example, limit your @command{tar}
  4790. archives to contain only regular files and directories, avoiding
  4791. other kind of special files. Do not attempt to save sparse files or
  4792. contiguous files as such. Let's discuss a few more problems, in turn.
  4793. @menu
  4794. * Portable Names:: Portable Names
  4795. * dereference:: Symbolic Links
  4796. * old:: Old V7 Archives
  4797. * posix:: @sc{posix} archives
  4798. * Checksumming:: Checksumming Problems
  4799. * Large or Negative Values:: Large files, negative time stamps, etc.
  4800. @end menu
  4801. @node Portable Names
  4802. @subsection Portable Names
  4803. Use portable file and member names. A name is portable if it contains
  4804. only ASCII letters and digits, @samp{/}, @samp{.}, @samp{_}, and
  4805. @samp{-}; it cannot be empty, start with @samp{-} or @samp{//}, or
  4806. contain @samp{/-}. Avoid deep directory nesting. For portability to
  4807. old Unix hosts, limit your file name components to 14 characters or
  4808. less.
  4809. If you intend to have your @command{tar} archives to be read under
  4810. MSDOS, you should not rely on case distinction for file names, and you
  4811. might use the @acronym{GNU} @command{doschk} program for helping you
  4812. further diagnosing illegal MSDOS names, which are even more limited
  4813. than System V's.
  4814. @node dereference
  4815. @subsection Symbolic Links
  4816. @cindex File names, using symbolic links
  4817. @cindex Symbolic link as file name
  4818. Normally, when @command{tar} archives a symbolic link, it writes a
  4819. block to the archive naming the target of the link. In that way, the
  4820. @command{tar} archive is a faithful record of the filesystem contents.
  4821. @value{op-dereference} is used with @value{op-create}, and causes
  4822. @command{tar} to archive the files symbolic links point to, instead of
  4823. the links themselves. When this option is used, when @command{tar}
  4824. encounters a symbolic link, it will archive the linked-to file,
  4825. instead of simply recording the presence of a symbolic link.
  4826. The name under which the file is stored in the file system is not
  4827. recorded in the archive. To record both the symbolic link name and
  4828. the file name in the system, archive the file under both names. If
  4829. all links were recorded automatically by @command{tar}, an extracted file
  4830. might be linked to a file name that no longer exists in the file
  4831. system.
  4832. If a linked-to file is encountered again by @command{tar} while creating
  4833. the same archive, an entire second copy of it will be stored. (This
  4834. @emph{might} be considered a bug.)
  4835. So, for portable archives, do not archive symbolic links as such,
  4836. and use @value{op-dereference}: many systems do not support
  4837. symbolic links, and moreover, your distribution might be unusable if
  4838. it contains unresolved symbolic links.
  4839. @node old
  4840. @subsection Old V7 Archives
  4841. @cindex Format, old style
  4842. @cindex Old style format
  4843. @cindex Old style archives
  4844. Certain old versions of @command{tar} cannot handle additional
  4845. information recorded by newer @command{tar} programs. To create an
  4846. archive in V7 format (not ANSI), which can be read by these old
  4847. versions, specify the @value{op-old-archive} option in
  4848. conjunction with the @value{op-create}. @command{tar} also
  4849. accepts @samp{--portability} for this option. When you specify it,
  4850. @command{tar} leaves out information about directories, pipes, fifos,
  4851. contiguous files, and device files, and specifies file ownership by
  4852. group and user IDs instead of group and user names.
  4853. When updating an archive, do not use @value{op-old-archive}
  4854. unless the archive was created with using this option.
  4855. In most cases, a @emph{new} format archive can be read by an @emph{old}
  4856. @command{tar} program without serious trouble, so this option should
  4857. seldom be needed. On the other hand, most modern @command{tar}s are
  4858. able to read old format archives, so it might be safer for you to
  4859. always use @value{op-old-archive} for your distributions.
  4860. @node posix
  4861. @subsection @acronym{GNU} @command{tar} and @sc{posix} @command{tar}
  4862. @acronym{GNU} @command{tar} was based on an early draft of the
  4863. @sc{posix} 1003.1 @code{ustar} standard. @acronym{GNU} extensions to
  4864. @command{tar}, such as the support for file names longer than 100
  4865. characters, use portions of the @command{tar} header record which were
  4866. specified in that @sc{posix} draft as unused. Subsequent changes in
  4867. @sc{posix} have allocated the same parts of the header record for
  4868. other purposes. As a result, @acronym{GNU} @command{tar} is
  4869. incompatible with the current @sc{posix} spec, and with @command{tar}
  4870. programs that follow it.
  4871. We plan to reimplement these @acronym{GNU} extensions in a new way which is
  4872. upward compatible with the latest @sc{posix} @command{tar} format, but we
  4873. don't know when this will be done.
  4874. In the mean time, there is simply no telling what might happen if you
  4875. read a @acronym{GNU} @command{tar} archive, which uses the
  4876. @acronym{GNU} extensions, using some other @command{tar} program. So
  4877. if you want to read the archive with another @command{tar} program, be
  4878. sure to write it using the @samp{--old-archive} option (@samp{-o}).
  4879. @FIXME{is there a way to tell which flavor of tar was used to write a
  4880. particular archive before you try to read it?}
  4881. Traditionally, old @command{tar}s have a limit of 100 characters.
  4882. @acronym{GNU} @command{tar} attempted two different approaches to
  4883. overcome this limit, using and extending a format specified by a draft
  4884. of some P1003.1. The first way was not that successful, and involved
  4885. @file{@@MaNgLeD@@} file names, or such; while a second approach used
  4886. @file{././@@LongLink} and other tricks, yielding better success. In
  4887. theory, @acronym{GNU} @command{tar} should be able to handle file
  4888. names of practically unlimited length. So, if @acronym{GNU}
  4889. @command{tar} fails to dump and retrieve files having more than 100
  4890. characters, then there is a bug in @acronym{GNU} @command{tar},
  4891. indeed.
  4892. But, being strictly @sc{posix}, the limit was still 100 characters.
  4893. For various other purposes, @acronym{GNU} @command{tar} used areas
  4894. left unassigned in the @sc{posix} draft. @sc{posix} later revised
  4895. P1003.1 @code{ustar} format by assigning previously unused header
  4896. fields, in such a way that the upper limit for file name length was
  4897. raised to 256 characters. However, the actual @sc{posix} limit
  4898. oscillates between 100 and 256, depending on the precise location of
  4899. slashes in full file name (this is rather ugly). Since @acronym{GNU}
  4900. @command{tar} use the same fields for quite other purposes, it became
  4901. incompatible with the latest @sc{posix} standards.
  4902. For longer or non-fitting file names, we plan to use yet another set
  4903. of @acronym{GNU} extensions, but this time, complying with the
  4904. provisions @sc{posix} offers for extending the format, rather than
  4905. conflicting with it. Whenever an archive uses old @acronym{GNU}
  4906. @command{tar} extension format or @sc{posix} extensions, would it be
  4907. for very long file names or other specialities, this archive becomes
  4908. non-portable to other @command{tar} implementations. In fact,
  4909. anything can happen. The most forgiving @command{tar}s will merely
  4910. unpack the file using a wrong name, and maybe create another file
  4911. named something like @file{@@LongName}, with the true file name in it.
  4912. @command{tar}s not protecting themselves may segment violate!
  4913. Compatibility concerns make all this thing more difficult, as we will
  4914. have to support @emph{all} these things together, for a while.
  4915. @acronym{GNU} @command{tar} should be able to produce and read true
  4916. @sc{posix} format files, while being able to detect old @acronym{GNU}
  4917. @command{tar} formats, besides old V7 format, and process them
  4918. conveniently. It would take years before this whole area
  4919. stabilizes@dots{}
  4920. There are plans to raise this 100 limit to 256, and yet produce
  4921. @sc{posix} conforming archives. Past 256, I do not know yet if
  4922. @acronym{GNU} @command{tar} will go non-@sc{posix} again, or merely
  4923. refuse to archive the file.
  4924. There are plans so @acronym{GNU} @command{tar} support more fully the
  4925. latest @sc{posix} format, while being able to read old V7 format,
  4926. @acronym{GNU} (semi-@sc{posix} plus extension), as well as full
  4927. @sc{posix}. One may ask if there is part of the @sc{posix} format
  4928. that we still cannot support. This simple question has a complex
  4929. answer. Maybe that, on intimate look, some strong limitations will
  4930. pop up, but until now, nothing sounds too difficult (but see below).
  4931. I only have these few pages of @sc{posix} telling about ``Extended tar
  4932. Format'' (P1003.1-1990 -- section 10.1.1), and there are references to
  4933. other parts of the standard I do not have, which should normally
  4934. enforce limitations on stored file names (I suspect things like fixing
  4935. what @kbd{/} and @kbd{@key{NUL}} means). There are also some points
  4936. which the standard does not make clear, Existing practice will then
  4937. drive what I should do.
  4938. @sc{posix} mandates that, when a file name cannot fit within 100 to
  4939. 256 characters (the variance comes from the fact a @kbd{/} is ideally
  4940. needed as the 156'th character), or a link name cannot fit within 100
  4941. characters, a warning should be issued and the file @emph{not} be
  4942. stored. Unless some @value{op-posix} option is given (or
  4943. @env{POSIXLY_CORRECT} is set), I suspect that @acronym{GNU}
  4944. @command{tar} should disobey this specification, and automatically
  4945. switch to using @acronym{GNU} extensions to overcome file name or link
  4946. name length limitations.
  4947. There is a problem, however, which I did not intimately studied yet.
  4948. Given a truly @sc{posix} archive with names having more than 100
  4949. characters, I guess that @acronym{GNU} @command{tar} up to 1.11.8 will
  4950. process it as if it were an old V7 archive, and be fooled by some
  4951. fields which are coded differently. So, the question is to decide if
  4952. the next generation of @acronym{GNU} @command{tar} should produce
  4953. @sc{posix} format by default, whenever possible, producing archives
  4954. older versions of @acronym{GNU} @command{tar} might not be able to
  4955. read correctly. I fear that we will have to suffer such a choice one
  4956. of these days, if we want @acronym{GNU} @command{tar} to go closer to
  4957. @sc{posix}. We can rush it. Another possibility is to produce the
  4958. current @acronym{GNU} @command{tar} format by default for a few years,
  4959. but have @acronym{GNU} @command{tar} versions from some 1.@var{POSIX}
  4960. and up able to recognize all three formats, and let older
  4961. @acronym{GNU} @command{tar} fade out slowly. Then, we could switch to
  4962. producing @sc{posix} format by default, with not much harm to those
  4963. still having (very old at that time) @acronym{GNU} @command{tar}
  4964. versions prior to 1.@var{POSIX}.
  4965. @sc{posix} format cannot represent very long names, volume headers,
  4966. splitting of files in multi-volumes, sparse files, and incremental
  4967. dumps; these would be all disallowed if @value{op-posix} or
  4968. @env{POSIXLY_CORRECT}. Otherwise, if @command{tar} is given long
  4969. names, or @samp{-[VMSgG]}, then it should automatically go non-@sc{posix}.
  4970. I think this is easily granted without much discussion.
  4971. Another point is that only @code{mtime} is stored in @sc{posix}
  4972. archives, while @acronym{GNU} @command{tar} currently also store
  4973. @code{atime} and @code{ctime}. If we want @acronym{GNU} @command{tar}
  4974. to go closer to @sc{posix}, my choice would be to drop @code{atime}
  4975. and @code{ctime} support on average. On the other hand, I perceive
  4976. that full dumps or incremental dumps need @code{atime} and
  4977. @code{ctime} support, so for those special applications, @sc{posix}
  4978. has to be avoided altogether.
  4979. A few users requested that @value{op-sparse} be always active by
  4980. default, I think that before replying to them, we have to decide if we
  4981. want @acronym{GNU} @command{tar} to go closer to @sc{posix} on
  4982. average, while producing files. My choice would be to go closer to
  4983. @sc{posix} in the long run. Besides possible double reading, I do not
  4984. see any point of not trying to save files as sparse when creating
  4985. archives which are neither @sc{posix} nor old-V7, so the actual
  4986. @value{op-sparse} would become selected by default when producing such
  4987. archives, whatever the reason is. So, @value{op-sparse} alone might
  4988. be redefined to force @acronym{GNU}-format archives, and recover its
  4989. previous meaning from this fact.
  4990. @acronym{GNU}-format as it exists now can easily fool other @sc{posix}
  4991. @command{tar}, as it uses fields which @sc{posix} considers to be part
  4992. of the file name prefix. I wonder if it would not be a good idea, in
  4993. the long run, to try changing @acronym{GNU}-format so any added field
  4994. (like @code{ctime}, @code{atime}, file offset in subsequent volumes,
  4995. or sparse file descriptions) be wholly and always pushed into an
  4996. extension block, instead of using space in the @sc{posix} header
  4997. block. I could manage to do that portably between future
  4998. @acronym{GNU} @command{tar}s. So other @sc{posix} @command{tar}s
  4999. might be at least able to provide kind of correct listings for the
  5000. archives produced by @acronym{GNU} @command{tar}, if not able to
  5001. process them otherwise.
  5002. Using these projected extensions might induce older @command{tar}s to
  5003. fail. We would use the same approach as for @sc{posix}. I'll put out
  5004. a @command{tar} capable of reading @sc{posix}ier, yet extended
  5005. archives, but will not produce this format by default, in
  5006. @acronym{GNU} mode. In a few years, when newer @acronym{GNU}
  5007. @command{tar}s will have flooded out @command{tar} 1.11.X and
  5008. previous, we could switch to producing @sc{posix}ier extended
  5009. archives, with no real harm to users, as almost all existing
  5010. @acronym{GNU} @command{tar}s will be ready to read @sc{posix}ier
  5011. format. In fact, I'll do both changes at the same time, in a few
  5012. years, and just prepare @command{tar} for both changes, without
  5013. effecting them, from 1.@var{POSIX}. (Both changes: 1---using
  5014. @sc{posix} convention for getting over 100 characters; 2---avoiding
  5015. mangling @sc{posix} headers for @acronym{GNU} extensions, using only
  5016. @sc{posix} mandated extension techniques).
  5017. So, a future @command{tar} will have a @value{op-posix} flag forcing
  5018. the usage of truly @sc{posix} headers, and so, producing archives
  5019. previous @acronym{GNU} @command{tar} will not be able to read. So,
  5020. @emph{once} pretest will announce that feature, it would be
  5021. particularly useful that users test how exchangeable will be archives
  5022. between @acronym{GNU} @command{tar} with @value{op-posix} and other
  5023. @sc{posix} @command{tar}.
  5024. In a few years, when @acronym{GNU} @command{tar} will produce
  5025. @sc{posix} headers by default, @value{op-posix} will have a strong
  5026. meaning and will disallow @acronym{GNU} extensions. But in the
  5027. meantime, for a long while, @value{op-posix} in @acronym{GNU} tar will
  5028. not disallow @acronym{GNU} extensions like @value{op-label},
  5029. @value{op-multi-volume}, @value{op-sparse}, or very long file or link
  5030. names. However, @value{op-posix} with @acronym{GNU} extensions will
  5031. use @sc{posix} headers with reserved-for-users extensions to headers,
  5032. and I will be curious to know how well or bad @sc{posix}
  5033. @command{tar}s will react to these.
  5034. @acronym{GNU} @command{tar} prior to 1.@var{POSIX}, and after
  5035. 1.@var{POSIX} without @value{op-posix}, generates and checks
  5036. @samp{ustar@w{ }@w{ }}, with two suffixed spaces. This is sufficient
  5037. for older @acronym{GNU} @command{tar} not to recognize @sc{posix}
  5038. archives, and consequently, wrongly decide those archives are in old
  5039. V7 format. It is a useful bug for me, because @acronym{GNU}
  5040. @command{tar} has other @sc{posix} incompatibilities, and I need to
  5041. segregate @acronym{GNU} @command{tar} semi-@sc{posix} archives from
  5042. truly @sc{posix} archives, for @acronym{GNU} @command{tar} should be
  5043. somewhat compatible with itself, while migrating closer to latest
  5044. @sc{posix} standards. So, I'll be very careful about how and when I
  5045. will do the correction.
  5046. @node Checksumming
  5047. @subsection Checksumming Problems
  5048. SunOS and HP-UX @command{tar} fail to accept archives created using
  5049. @acronym{GNU} @command{tar} and containing non-ASCII file names, that
  5050. is, file names having characters with the eight bit set, because they
  5051. use signed checksums, while @acronym{GNU} @command{tar} uses unsigned
  5052. checksums while creating archives, as per @sc{posix} standards. On
  5053. reading, @acronym{GNU} @command{tar} computes both checksums and
  5054. accept any. It is somewhat worrying that a lot of people may go
  5055. around doing backup of their files using faulty (or at least
  5056. non-standard) software, not learning about it until it's time to
  5057. restore their missing files with an incompatible file extractor, or
  5058. vice versa.
  5059. @acronym{GNU} @command{tar} compute checksums both ways, and accept
  5060. any on read, so @acronym{GNU} tar can read Sun tapes even with their
  5061. wrong checksums. @acronym{GNU} @command{tar} produces the standard
  5062. checksum, however, raising incompatibilities with Sun. That is to
  5063. say, @acronym{GNU} @command{tar} has not been modified to
  5064. @emph{produce} incorrect archives to be read by buggy @command{tar}'s.
  5065. I've been told that more recent Sun @command{tar} now read standard
  5066. archives, so maybe Sun did a similar patch, after all?
  5067. The story seems to be that when Sun first imported @command{tar}
  5068. sources on their system, they recompiled it without realizing that
  5069. the checksums were computed differently, because of a change in
  5070. the default signing of @code{char}'s in their compiler. So they
  5071. started computing checksums wrongly. When they later realized their
  5072. mistake, they merely decided to stay compatible with it, and with
  5073. themselves afterwards. Presumably, but I do not really know, HP-UX
  5074. has chosen that their @command{tar} archives to be compatible with Sun's.
  5075. The current standards do not favor Sun @command{tar} format. In any
  5076. case, it now falls on the shoulders of SunOS and HP-UX users to get
  5077. a @command{tar} able to read the good archives they receive.
  5078. @node Large or Negative Values
  5079. @subsection Large or Negative Values
  5080. @cindex large values
  5081. @cindex future time stamps
  5082. @cindex negative time stamps
  5083. @sc{posix} @command{tar} format uses fixed-sized unsigned octal strings
  5084. to represent numeric values. User and group IDs and device major and
  5085. minor numbers have unsigned 21-bit representations, and file sizes and
  5086. times have unsigned 33-bit representations. @acronym{GNU} @command{tar}
  5087. generates @sc{posix} representations when possible, but for values
  5088. outside the @sc{posix} range it generates two's-complement base-256
  5089. strings: uids, gids, and device numbers have signed 57-bit
  5090. representations, and file sizes and times have signed 89-bit
  5091. representations. These representations are an extension to @sc{posix}
  5092. @command{tar} format, so they are not universally portable.
  5093. The most common portability problems with out-of-range numeric values
  5094. are large files and future or negative time stamps.
  5095. Portable archives should avoid members of 8 GB or larger, as @sc{posix}
  5096. @command{tar} format cannot represent them.
  5097. Portable archives should avoid time stamps from the future. @sc{posix}
  5098. @command{tar} format can represent time stamps in the range 1970-01-01
  5099. 00:00:00 through 2242-03-16 12:56:31 @sc{utc}. However, many current
  5100. hosts use a signed 32-bit @code{time_t}, or internal time stamp format,
  5101. and cannot represent time stamps after 2038-01-19 03:14:07 @sc{utc}; so
  5102. portable archives must avoid these time stamps for many years to come.
  5103. Portable archives should also avoid time stamps before 1970. These time
  5104. stamps are a common @sc{posix} extension but their @code{time_t}
  5105. representations are negative. Many traditional @command{tar}
  5106. implementations generate a two's complement representation for negative
  5107. time stamps that assumes a signed 32-bit @code{time_t}; hence they
  5108. generate archives that are not portable to hosts with differing
  5109. @code{time_t} representations. @acronym{GNU} @command{tar} recognizes this
  5110. situation when it is run on host with a signed 32-bit @code{time_t}, but
  5111. it issues a warning, as these time stamps are nonstandard and unportable.
  5112. @node Compression
  5113. @section Using Less Space through Compression
  5114. @menu
  5115. * gzip:: Creating and Reading Compressed Archives
  5116. * sparse:: Archiving Sparse Files
  5117. @end menu
  5118. @node gzip
  5119. @subsection Creating and Reading Compressed Archives
  5120. @cindex Compressed archives
  5121. @cindex Storing archives in compressed format
  5122. @UNREVISED
  5123. @table @kbd
  5124. @item -z
  5125. @itemx --gzip
  5126. @itemx --ungzip
  5127. Filter the archive through @command{gzip}.
  5128. @end table
  5129. @FIXME{ach; these two bits orig from "compare" (?). where to put?} Some
  5130. format parameters must be taken into consideration when modifying an
  5131. archive.@FIXME{???} Compressed archives cannot be modified.
  5132. You can use @samp{--gzip} and @samp{--gunzip} on physical devices
  5133. (tape drives, etc.) and remote files as well as on normal files; data
  5134. to or from such devices or remote files is reblocked by another copy
  5135. of the @command{tar} program to enforce the specified (or default) record
  5136. size. The default compression parameters are used; if you need to
  5137. override them, avoid the @value{op-gzip} option and run @command{gzip}
  5138. explicitly. (Or set the @env{GZIP} environment variable.)
  5139. The @value{op-gzip} option does not work with the @value{op-multi-volume}
  5140. option, or with the @value{op-update}, @value{op-append},
  5141. @value{op-concatenate}, or @value{op-delete} operations.
  5142. It is not exact to say that @acronym{GNU} @command{tar} is to work in concert
  5143. with @command{gzip} in a way similar to @command{zip}, say. Surely, it is
  5144. possible that @command{tar} and @command{gzip} be done with a single call,
  5145. like in:
  5146. @example
  5147. $ @kbd{tar cfz archive.tar.gz subdir}
  5148. @end example
  5149. @noindent
  5150. to save all of @samp{subdir} into a @code{gzip}'ed archive. Later you
  5151. can do:
  5152. @example
  5153. $ @kbd{tar xfz archive.tar.gz}
  5154. @end example
  5155. @noindent
  5156. to explode and unpack.
  5157. The difference is that the whole archive is compressed. With
  5158. @command{zip}, archive members are archived individually. @command{tar}'s
  5159. method yields better compression. On the other hand, one can view the
  5160. contents of a @command{zip} archive without having to decompress it. As
  5161. for the @command{tar} and @command{gzip} tandem, you need to decompress the
  5162. archive to see its contents. However, this may be done without needing
  5163. disk space, by using pipes internally:
  5164. @example
  5165. $ @kbd{tar tfz archive.tar.gz}
  5166. @end example
  5167. @cindex corrupted archives
  5168. About corrupted compressed archives: @command{gzip}'ed files have no
  5169. redundancy, for maximum compression. The adaptive nature of the
  5170. compression scheme means that the compression tables are implicitly
  5171. spread all over the archive. If you lose a few blocks, the dynamic
  5172. construction of the compression tables becomes unsynchronized, and there
  5173. is little chance that you could recover later in the archive.
  5174. There are pending suggestions for having a per-volume or per-file
  5175. compression in @acronym{GNU} @command{tar}. This would allow for viewing the
  5176. contents without decompression, and for resynchronizing decompression at
  5177. every volume or file, in case of corrupted archives. Doing so, we might
  5178. lose some compressibility. But this would have make recovering easier.
  5179. So, there are pros and cons. We'll see!
  5180. @table @kbd
  5181. @item -j
  5182. @itemx --bzip2
  5183. Filter the archive through @code{bzip2}. Otherwise like @value{op-gzip}.
  5184. @item -Z
  5185. @itemx --compress
  5186. @itemx --uncompress
  5187. Filter the archive through @command{compress}. Otherwise like
  5188. @value{op-gzip}.
  5189. @item --use-compress-program=@var{prog}
  5190. Filter through @var{prog} (must accept @samp{-d}).
  5191. @end table
  5192. @value{op-compress} stores an archive in compressed format. This
  5193. option is useful in saving time over networks and space in pipes, and
  5194. when storage space is at a premium. @value{op-compress} causes
  5195. @command{tar} to compress when writing the archive, or to uncompress when
  5196. reading the archive.
  5197. To perform compression and uncompression on the archive, @command{tar}
  5198. runs the @command{compress} utility. @command{tar} uses the default
  5199. compression parameters; if you need to override them, avoid the
  5200. @value{op-compress} option and run the @command{compress} utility
  5201. explicitly. It is useful to be able to call the @command{compress}
  5202. utility from within @command{tar} because the @command{compress} utility by
  5203. itself cannot access remote tape drives.
  5204. The @value{op-compress} option will not work in conjunction with the
  5205. @value{op-multi-volume} option or the @value{op-append}, @value{op-update}
  5206. and @value{op-delete} operations. @xref{Operations}, for
  5207. more information on these operations.
  5208. If there is no compress utility available, @command{tar} will report an error.
  5209. @strong{Please note} that the @command{compress} program may be covered by
  5210. a patent, and therefore we recommend you stop using it.
  5211. @value{op-bzip2} acts like @value{op-compress}, except that it uses
  5212. the @code{bzip2} utility.
  5213. @table @kbd
  5214. @item --compress
  5215. @itemx --uncompress
  5216. @itemx -z
  5217. @itemx -Z
  5218. When this option is specified, @command{tar} will compress (when
  5219. writing an archive), or uncompress (when reading an archive). Used in
  5220. conjunction with the @value{op-create}, @value{op-extract},
  5221. @value{op-list} and @value{op-compare} operations.
  5222. @end table
  5223. You can have archives be compressed by using the @value{op-gzip} option.
  5224. This will arrange for @command{tar} to use the @command{gzip} program to be
  5225. used to compress or uncompress the archive wren writing or reading it.
  5226. To use the older, obsolete, @command{compress} program, use the
  5227. @value{op-compress} option. The @acronym{GNU} Project recommends you not use
  5228. @command{compress}, because there is a patent covering the algorithm it
  5229. uses. You could be sued for patent infringement merely by running
  5230. @command{compress}.
  5231. I have one question, or maybe it's a suggestion if there isn't a way
  5232. to do it now. I would like to use @value{op-gzip}, but I'd also like
  5233. the output to be fed through a program like @acronym{GNU}
  5234. @command{ecc} (actually, right now that's @samp{exactly} what I'd like
  5235. to use :-)), basically adding ECC protection on top of compression.
  5236. It seems as if this should be quite easy to do, but I can't work out
  5237. exactly how to go about it. Of course, I can pipe the standard output
  5238. of @command{tar} through @command{ecc}, but then I lose (though I
  5239. haven't started using it yet, I confess) the ability to have
  5240. @command{tar} use @command{rmt} for it's I/O (I think).
  5241. I think the most straightforward thing would be to let me specify a
  5242. general set of filters outboard of compression (preferably ordered,
  5243. so the order can be automatically reversed on input operations, and
  5244. with the options they require specifiable), but beggars shouldn't be
  5245. choosers and anything you decide on would be fine with me.
  5246. By the way, I like @command{ecc} but if (as the comments say) it can't
  5247. deal with loss of block sync, I'm tempted to throw some time at adding
  5248. that capability. Supposing I were to actually do such a thing and
  5249. get it (apparently) working, do you accept contributed changes to
  5250. utilities like that? (Leigh Clayton @file{loc@@soliton.com}, May 1995).
  5251. Isn't that exactly the role of the @value{op-use-compress-prog} option?
  5252. I never tried it myself, but I suspect you may want to write a
  5253. @var{prog} script or program able to filter stdin to stdout to
  5254. way you want. It should recognize the @samp{-d} option, for when
  5255. extraction is needed rather than creation.
  5256. It has been reported that if one writes compressed data (through the
  5257. @value{op-gzip} or @value{op-compress} options) to a DLT and tries to use
  5258. the DLT compression mode, the data will actually get bigger and one will
  5259. end up with less space on the tape.
  5260. @node sparse
  5261. @subsection Archiving Sparse Files
  5262. @cindex Sparse Files
  5263. @UNREVISED
  5264. @table @kbd
  5265. @item -S
  5266. @itemx --sparse
  5267. Handle sparse files efficiently.
  5268. @end table
  5269. This option causes all files to be put in the archive to be tested for
  5270. sparseness, and handled specially if they are. The @value{op-sparse}
  5271. option is useful when many @code{dbm} files, for example, are being
  5272. backed up. Using this option dramatically decreases the amount of
  5273. space needed to store such a file.
  5274. In later versions, this option may be removed, and the testing and
  5275. treatment of sparse files may be done automatically with any special
  5276. @acronym{GNU} options. For now, it is an option needing to be specified on
  5277. the command line with the creation or updating of an archive.
  5278. Files in the filesystem occasionally have ``holes.'' A hole in a file
  5279. is a section of the file's contents which was never written. The
  5280. contents of a hole read as all zeros. On many operating systems,
  5281. actual disk storage is not allocated for holes, but they are counted
  5282. in the length of the file. If you archive such a file, @command{tar}
  5283. could create an archive longer than the original. To have @command{tar}
  5284. attempt to recognize the holes in a file, use @value{op-sparse}. When
  5285. you use the @value{op-sparse} option, then, for any file using less
  5286. disk space than would be expected from its length, @command{tar} searches
  5287. the file for consecutive stretches of zeros. It then records in the
  5288. archive for the file where the consecutive stretches of zeros are, and
  5289. only archives the ``real contents'' of the file. On extraction (using
  5290. @value{op-sparse} is not needed on extraction) any such files have
  5291. hols created wherever the continuous stretches of zeros were found.
  5292. Thus, if you use @value{op-sparse}, @command{tar} archives won't take
  5293. more space than the original.
  5294. A file is sparse if it contains blocks of zeros whose existence is
  5295. recorded, but that have no space allocated on disk. When you specify
  5296. the @value{op-sparse} option in conjunction with the @value{op-create}
  5297. operation, @command{tar} tests all files for sparseness while archiving.
  5298. If @command{tar} finds a file to be sparse, it uses a sparse representation of
  5299. the file in the archive. @value{xref-create}, for more information
  5300. about creating archives.
  5301. @value{op-sparse} is useful when archiving files, such as dbm files,
  5302. likely to contain many nulls. This option dramatically
  5303. decreases the amount of space needed to store such an archive.
  5304. @quotation
  5305. @strong{Please Note:} Always use @value{op-sparse} when performing file
  5306. system backups, to avoid archiving the expanded forms of files stored
  5307. sparsely in the system.
  5308. Even if your system has no sparse files currently, some may be
  5309. created in the future. If you use @value{op-sparse} while making file
  5310. system backups as a matter of course, you can be assured the archive
  5311. will never take more space on the media than the files take on disk
  5312. (otherwise, archiving a disk filled with sparse files might take
  5313. hundreds of tapes). @FIXME-xref{incremental when node name is set.}
  5314. @end quotation
  5315. @command{tar} ignores the @value{op-sparse} option when reading an archive.
  5316. @table @kbd
  5317. @item --sparse
  5318. @itemx -S
  5319. Files stored sparsely in the file system are represented sparsely in
  5320. the archive. Use in conjunction with write operations.
  5321. @end table
  5322. However, users should be well aware that at archive creation time,
  5323. @acronym{GNU} @command{tar} still has to read whole disk file to
  5324. locate the @dfn{holes}, and so, even if sparse files use little space
  5325. on disk and in the archive, they may sometimes require inordinate
  5326. amount of time for reading and examining all-zero blocks of a file.
  5327. Although it works, it's painfully slow for a large (sparse) file, even
  5328. though the resulting tar archive may be small. (One user reports that
  5329. dumping a @file{core} file of over 400 megabytes, but with only about
  5330. 3 megabytes of actual data, took about 9 minutes on a Sun Sparcstation
  5331. ELC, with full CPU utilization.)
  5332. This reading is required in all cases and is not related to the fact
  5333. the @value{op-sparse} option is used or not, so by merely @emph{not}
  5334. using the option, you are not saving time@footnote{Well! We should say
  5335. the whole truth, here. When @value{op-sparse} is selected while creating
  5336. an archive, the current @command{tar} algorithm requires sparse files to be
  5337. read twice, not once. We hope to develop a new archive format for saving
  5338. sparse files in which one pass will be sufficient.}.
  5339. Programs like @command{dump} do not have to read the entire file; by
  5340. examining the file system directly, they can determine in advance
  5341. exactly where the holes are and thus avoid reading through them. The
  5342. only data it need read are the actual allocated data blocks.
  5343. @acronym{GNU} @command{tar} uses a more portable and straightforward
  5344. archiving approach, it would be fairly difficult that it does
  5345. otherwise. Elizabeth Zwicky writes to @file{comp.unix.internals}, on
  5346. 1990-12-10:
  5347. @quotation
  5348. What I did say is that you cannot tell the difference between a hole and an
  5349. equivalent number of nulls without reading raw blocks. @code{st_blocks} at
  5350. best tells you how many holes there are; it doesn't tell you @emph{where}.
  5351. Just as programs may, conceivably, care what @code{st_blocks} is (care
  5352. to name one that does?), they may also care where the holes are (I have
  5353. no examples of this one either, but it's equally imaginable).
  5354. I conclude from this that good archivers are not portable. One can
  5355. arguably conclude that if you want a portable program, you can in good
  5356. conscience restore files with as many holes as possible, since you can't
  5357. get it right.
  5358. @end quotation
  5359. @node Attributes
  5360. @section Handling File Attributes
  5361. @UNREVISED
  5362. When @command{tar} reads files, this causes them to have the access
  5363. times updated. To have @command{tar} attempt to set the access times
  5364. back to what they were before they were read, use the
  5365. @value{op-atime-preserve} option.
  5366. Handling of file attributes
  5367. @table @kbd
  5368. @item --atime-preserve
  5369. Preserve access times on files that are read.
  5370. This doesn't work for files that
  5371. you don't own, unless you're root, and it doesn't interact with
  5372. incremental dumps nicely (@pxref{Backups}), and it can set access or
  5373. modification times incorrectly if other programs access the file while
  5374. @command{tar} is running; but it is good enough for some purposes.
  5375. @item -m
  5376. @itemx --touch
  5377. Do not extract file modified time.
  5378. When this option is used, @command{tar} leaves the modification times
  5379. of the files it extracts as the time when the files were extracted,
  5380. instead of setting it to the time recorded in the archive.
  5381. This option is meaningless with @value{op-list}.
  5382. @item --same-owner
  5383. Create extracted files with the same ownership they have in the
  5384. archive.
  5385. This is the default behavior for the superuser,
  5386. so this option is meaningful only for non-root users, when @command{tar}
  5387. is executed on those systems able to give files away. This is
  5388. considered as a security flaw by many people, at least because it
  5389. makes quite difficult to correctly account users for the disk space
  5390. they occupy. Also, the @code{suid} or @code{sgid} attributes of
  5391. files are easily and silently lost when files are given away.
  5392. When writing an archive, @command{tar} writes the user id and user name
  5393. separately. If it can't find a user name (because the user id is not
  5394. in @file{/etc/passwd}), then it does not write one. When restoring,
  5395. and doing a @code{chmod} like when you use @value{op-same-permissions},
  5396. @FIXME{same-owner?}it tries to look the name (if one was written)
  5397. up in @file{/etc/passwd}. If it fails, then it uses the user id
  5398. stored in the archive instead.
  5399. @item --no-same-owner
  5400. Do not attempt to restore ownership when extracting. This is the
  5401. default behavior for ordinary users, so this option has an effect
  5402. only for the superuser.
  5403. @item --numeric-owner
  5404. The @value{op-numeric-owner} option allows (ANSI) archives to be written
  5405. without user/group name information or such information to be ignored
  5406. when extracting. It effectively disables the generation and/or use
  5407. of user/group name information. This option forces extraction using
  5408. the numeric ids from the archive, ignoring the names.
  5409. This is useful in certain circumstances, when restoring a backup from
  5410. an emergency floppy with different passwd/group files for example.
  5411. It is otherwise impossible to extract files with the right ownerships
  5412. if the password file in use during the extraction does not match the
  5413. one belonging to the filesystem(s) being extracted. This occurs,
  5414. for example, if you are restoring your files after a major crash and
  5415. had booted from an emergency floppy with no password file or put your
  5416. disk into another machine to do the restore.
  5417. The numeric ids are @emph{always} saved into @command{tar} archives.
  5418. The identifying names are added at create time when provided by the
  5419. system, unless @value{op-old-archive} is used. Numeric ids could be
  5420. used when moving archives between a collection of machines using
  5421. a centralized management for attribution of numeric ids to users
  5422. and groups. This is often made through using the NIS capabilities.
  5423. When making a @command{tar} file for distribution to other sites, it
  5424. is sometimes cleaner to use a single owner for all files in the
  5425. distribution, and nicer to specify the write permission bits of the
  5426. files as stored in the archive independently of their actual value on
  5427. the file system. The way to prepare a clean distribution is usually
  5428. to have some Makefile rule creating a directory, copying all needed
  5429. files in that directory, then setting ownership and permissions as
  5430. wanted (there are a lot of possible schemes), and only then making a
  5431. @command{tar} archive out of this directory, before cleaning
  5432. everything out. Of course, we could add a lot of options to
  5433. @acronym{GNU} @command{tar} for fine tuning permissions and ownership.
  5434. This is not the good way, I think. @acronym{GNU} @command{tar} is
  5435. already crowded with options and moreover, the approach just explained
  5436. gives you a great deal of control already.
  5437. @item -p
  5438. @itemx --same-permissions
  5439. @itemx --preserve-permissions
  5440. Extract all protection information.
  5441. This option causes @command{tar} to set the modes (access permissions) of
  5442. extracted files exactly as recorded in the archive. If this option
  5443. is not used, the current @code{umask} setting limits the permissions
  5444. on extracted files.
  5445. This option is meaningless with @value{op-list}.
  5446. @item --preserve
  5447. Same as both @value{op-same-permissions} and @value{op-same-order}.
  5448. The @value{op-preserve} option has no equivalent short option name.
  5449. It is equivalent to @value{op-same-permissions} plus @value{op-same-order}.
  5450. @FIXME{I do not see the purpose of such an option. (Neither I. FP.)}
  5451. @end table
  5452. @node Standard
  5453. @section The Standard Format
  5454. @UNREVISED
  5455. While an archive may contain many files, the archive itself is a
  5456. single ordinary file. Like any other file, an archive file can be
  5457. written to a storage device such as a tape or disk, sent through a
  5458. pipe or over a network, saved on the active file system, or even
  5459. stored in another archive. An archive file is not easy to read or
  5460. manipulate without using the @command{tar} utility or Tar mode in
  5461. @acronym{GNU} Emacs.
  5462. Physically, an archive consists of a series of file entries terminated
  5463. by an end-of-archive entry, which consists of 512 zero bytes. A file
  5464. entry usually describes one of the files in the archive (an
  5465. @dfn{archive member}), and consists of a file header and the contents
  5466. of the file. File headers contain file names and statistics, checksum
  5467. information which @command{tar} uses to detect file corruption, and
  5468. information about file types.
  5469. Archives are permitted to have more than one member with the same
  5470. member name. One way this situation can occur is if more than one
  5471. version of a file has been stored in the archive. For information
  5472. about adding new versions of a file to an archive, see @ref{update}.
  5473. @FIXME-xref{To learn more about having more than one archive member with the
  5474. same name, see -backup node, when it's written.}
  5475. In addition to entries describing archive members, an archive may
  5476. contain entries which @command{tar} itself uses to store information.
  5477. @value{xref-label}, for an example of such an archive entry.
  5478. A @command{tar} archive file contains a series of blocks. Each block
  5479. contains @code{BLOCKSIZE} bytes. Although this format may be thought
  5480. of as being on magnetic tape, other media are often used.
  5481. Each file archived is represented by a header block which describes
  5482. the file, followed by zero or more blocks which give the contents
  5483. of the file. At the end of the archive file there may be a block
  5484. filled with binary zeros as an end-of-file marker. A reasonable system
  5485. should write a block of zeros at the end, but must not assume that
  5486. such a block exists when reading an archive.
  5487. The blocks may be @dfn{blocked} for physical I/O operations.
  5488. Each record of @var{n} blocks (where @var{n} is set by the
  5489. @value{op-blocking-factor} option to @command{tar}) is written with a single
  5490. @w{@samp{write ()}} operation. On magnetic tapes, the result of
  5491. such a write is a single record. When writing an archive,
  5492. the last record of blocks should be written at the full size, with
  5493. blocks after the zero block containing all zeros. When reading
  5494. an archive, a reasonable system should properly handle an archive
  5495. whose last record is shorter than the rest, or which contains garbage
  5496. records after a zero block.
  5497. The header block is defined in C as follows. In the @acronym{GNU}
  5498. @command{tar} distribution, this is part of file @file{src/tar.h}:
  5499. @example
  5500. @include header.texi
  5501. @end example
  5502. All characters in header blocks are represented by using 8-bit
  5503. characters in the local variant of ASCII. Each field within the
  5504. structure is contiguous; that is, there is no padding used within
  5505. the structure. Each character on the archive medium is stored
  5506. contiguously.
  5507. Bytes representing the contents of files (after the header block
  5508. of each file) are not translated in any way and are not constrained
  5509. to represent characters in any character set. The @command{tar} format
  5510. does not distinguish text files from binary files, and no translation
  5511. of file contents is performed.
  5512. The @code{name}, @code{linkname}, @code{magic}, @code{uname}, and
  5513. @code{gname} are null-terminated character strings. All other fields
  5514. are zero-filled octal numbers in ASCII. Each numeric field of width
  5515. @var{w} contains @var{w} minus 2 digits, a space, and a null, except
  5516. @code{size}, and @code{mtime}, which do not contain the trailing null.
  5517. The @code{name} field is the file name of the file, with directory names
  5518. (if any) preceding the file name, separated by slashes.
  5519. @FIXME{how big a name before field overflows?}
  5520. The @code{mode} field provides nine bits specifying file permissions
  5521. and three bits to specify the Set UID, Set GID, and Save Text
  5522. (@dfn{sticky}) modes. Values for these bits are defined above.
  5523. When special permissions are required to create a file with a given
  5524. mode, and the user restoring files from the archive does not hold such
  5525. permissions, the mode bit(s) specifying those special permissions
  5526. are ignored. Modes which are not supported by the operating system
  5527. restoring files from the archive will be ignored. Unsupported modes
  5528. should be faked up when creating or updating an archive; e.g.@: the
  5529. group permission could be copied from the @emph{other} permission.
  5530. The @code{uid} and @code{gid} fields are the numeric user and group
  5531. ID of the file owners, respectively. If the operating system does
  5532. not support numeric user or group IDs, these fields should be ignored.
  5533. The @code{size} field is the size of the file in bytes; linked files
  5534. are archived with this field specified as zero. @FIXME-xref{Modifiers, in
  5535. particular the @value{op-incremental} option.}
  5536. The @code{mtime} field is the modification time of the file at the time
  5537. it was archived. It is the ASCII representation of the octal value of
  5538. the last time the file was modified, represented as an integer number of
  5539. seconds since January 1, 1970, 00:00 Coordinated Universal Time.
  5540. The @code{chksum} field is the ASCII representation of the octal value
  5541. of the simple sum of all bytes in the header block. Each 8-bit
  5542. byte in the header is added to an unsigned integer, initialized to
  5543. zero, the precision of which shall be no less than seventeen bits.
  5544. When calculating the checksum, the @code{chksum} field is treated as
  5545. if it were all blanks.
  5546. The @code{typeflag} field specifies the type of file archived. If a
  5547. particular implementation does not recognize or permit the specified
  5548. type, the file will be extracted as if it were a regular file. As this
  5549. action occurs, @command{tar} issues a warning to the standard error.
  5550. The @code{atime} and @code{ctime} fields are used in making incremental
  5551. backups; they store, respectively, the particular file's access time
  5552. and last inode-change time.
  5553. The @code{offset} is used by the @value{op-multi-volume} option, when
  5554. making a multi-volume archive. The offset is number of bytes into
  5555. the file that we need to restart at to continue the file on the next
  5556. tape, i.e., where we store the location that a continued file is
  5557. continued at.
  5558. The following fields were added to deal with sparse files. A file
  5559. is @dfn{sparse} if it takes in unallocated blocks which end up being
  5560. represented as zeros, i.e., no useful data. A test to see if a file
  5561. is sparse is to look at the number blocks allocated for it versus the
  5562. number of characters in the file; if there are fewer blocks allocated
  5563. for the file than would normally be allocated for a file of that
  5564. size, then the file is sparse. This is the method @command{tar} uses to
  5565. detect a sparse file, and once such a file is detected, it is treated
  5566. differently from non-sparse files.
  5567. Sparse files are often @code{dbm} files, or other database-type files
  5568. which have data at some points and emptiness in the greater part of
  5569. the file. Such files can appear to be very large when an @samp{ls
  5570. -l} is done on them, when in truth, there may be a very small amount
  5571. of important data contained in the file. It is thus undesirable
  5572. to have @command{tar} think that it must back up this entire file, as
  5573. great quantities of room are wasted on empty blocks, which can lead
  5574. to running out of room on a tape far earlier than is necessary.
  5575. Thus, sparse files are dealt with so that these empty blocks are
  5576. not written to the tape. Instead, what is written to the tape is a
  5577. description, of sorts, of the sparse file: where the holes are, how
  5578. big the holes are, and how much data is found at the end of the hole.
  5579. This way, the file takes up potentially far less room on the tape,
  5580. and when the file is extracted later on, it will look exactly the way
  5581. it looked beforehand. The following is a description of the fields
  5582. used to handle a sparse file:
  5583. The @code{sp} is an array of @code{struct sparse}. Each @code{struct
  5584. sparse} contains two 12-character strings which represent an offset
  5585. into the file and a number of bytes to be written at that offset.
  5586. The offset is absolute, and not relative to the offset in preceding
  5587. array element.
  5588. The header can hold four of these @code{struct sparse} at the moment;
  5589. if more are needed, they are not stored in the header.
  5590. The @code{isextended} flag is set when an @code{extended_header}
  5591. is needed to deal with a file. Note that this means that this flag
  5592. can only be set when dealing with a sparse file, and it is only set
  5593. in the event that the description of the file will not fit in the
  5594. allotted room for sparse structures in the header. In other words,
  5595. an extended_header is needed.
  5596. The @code{extended_header} structure is used for sparse files which
  5597. need more sparse structures than can fit in the header. The header can
  5598. fit 4 such structures; if more are needed, the flag @code{isextended}
  5599. gets set and the next block is an @code{extended_header}.
  5600. Each @code{extended_header} structure contains an array of 21
  5601. sparse structures, along with a similar @code{isextended} flag
  5602. that the header had. There can be an indeterminate number of such
  5603. @code{extended_header}s to describe a sparse file.
  5604. @table @asis
  5605. @item @code{REGTYPE}
  5606. @itemx @code{AREGTYPE}
  5607. These flags represent a regular file. In order to be compatible
  5608. with older versions of @command{tar}, a @code{typeflag} value of
  5609. @code{AREGTYPE} should be silently recognized as a regular file.
  5610. New archives should be created using @code{REGTYPE}. Also, for
  5611. backward compatibility, @command{tar} treats a regular file whose name
  5612. ends with a slash as a directory.
  5613. @item @code{LNKTYPE}
  5614. This flag represents a file linked to another file, of any type,
  5615. previously archived. Such files are identified in Unix by each
  5616. file having the same device and inode number. The linked-to name is
  5617. specified in the @code{linkname} field with a trailing null.
  5618. @item @code{SYMTYPE}
  5619. This represents a symbolic link to another file. The linked-to name
  5620. is specified in the @code{linkname} field with a trailing null.
  5621. @item @code{CHRTYPE}
  5622. @itemx @code{BLKTYPE}
  5623. These represent character special files and block special files
  5624. respectively. In this case the @code{devmajor} and @code{devminor}
  5625. fields will contain the major and minor device numbers respectively.
  5626. Operating systems may map the device specifications to their own
  5627. local specification, or may ignore the entry.
  5628. @item @code{DIRTYPE}
  5629. This flag specifies a directory or sub-directory. The directory
  5630. name in the @code{name} field should end with a slash. On systems where
  5631. disk allocation is performed on a directory basis, the @code{size} field
  5632. will contain the maximum number of bytes (which may be rounded to
  5633. the nearest disk block allocation unit) which the directory may
  5634. hold. A @code{size} field of zero indicates no such limiting. Systems
  5635. which do not support limiting in this manner should ignore the
  5636. @code{size} field.
  5637. @item @code{FIFOTYPE}
  5638. This specifies a FIFO special file. Note that the archiving of a
  5639. FIFO file archives the existence of this file and not its contents.
  5640. @item @code{CONTTYPE}
  5641. This specifies a contiguous file, which is the same as a normal
  5642. file except that, in operating systems which support it, all its
  5643. space is allocated contiguously on the disk. Operating systems
  5644. which do not allow contiguous allocation should silently treat this
  5645. type as a normal file.
  5646. @item @code{A} @dots{} @code{Z}
  5647. These are reserved for custom implementations. Some of these are
  5648. used in the @acronym{GNU} modified format, as described below.
  5649. @end table
  5650. Other values are reserved for specification in future revisions of
  5651. the P1003 standard, and should not be used by any @command{tar} program.
  5652. The @code{magic} field indicates that this archive was output in
  5653. the P1003 archive format. If this field contains @code{TMAGIC},
  5654. the @code{uname} and @code{gname} fields will contain the ASCII
  5655. representation of the owner and group of the file respectively.
  5656. If found, the user and group IDs are used rather than the values in
  5657. the @code{uid} and @code{gid} fields.
  5658. For references, see ISO/IEC 9945-1:1990 or IEEE Std 1003.1-1990, pages
  5659. 169-173 (section 10.1) for @cite{Archive/Interchange File Format}; and
  5660. IEEE Std 1003.2-1992, pages 380-388 (section 4.48) and pages 936-940
  5661. (section E.4.48) for @cite{pax - Portable archive interchange}.
  5662. @node Extensions
  5663. @section @acronym{GNU} Extensions to the Archive Format
  5664. @UNREVISED
  5665. The @acronym{GNU} format uses additional file types to describe new types of
  5666. files in an archive. These are listed below.
  5667. @table @code
  5668. @item GNUTYPE_DUMPDIR
  5669. @itemx 'D'
  5670. This represents a directory and a list of files created by the
  5671. @value{op-incremental} option. The @code{size} field gives the total
  5672. size of the associated list of files. Each file name is preceded by
  5673. either a @samp{Y} (the file should be in this archive) or an @samp{N}.
  5674. (The file is a directory, or is not stored in the archive.) Each file
  5675. name is terminated by a null. There is an additional null after the
  5676. last file name.
  5677. @item GNUTYPE_MULTIVOL
  5678. @itemx 'M'
  5679. This represents a file continued from another volume of a multi-volume
  5680. archive created with the @value{op-multi-volume} option. The original
  5681. type of the file is not given here. The @code{size} field gives the
  5682. maximum size of this piece of the file (assuming the volume does
  5683. not end before the file is written out). The @code{offset} field
  5684. gives the offset from the beginning of the file where this part of
  5685. the file begins. Thus @code{size} plus @code{offset} should equal
  5686. the original size of the file.
  5687. @item GNUTYPE_SPARSE
  5688. @itemx 'S'
  5689. This flag indicates that we are dealing with a sparse file. Note
  5690. that archiving a sparse file requires special operations to find
  5691. holes in the file, which mark the positions of these holes, along
  5692. with the number of bytes of data to be found after the hole.
  5693. @item GNUTYPE_VOLHDR
  5694. @itemx 'V'
  5695. This file type is used to mark the volume header that was given with
  5696. the @value{op-label} option when the archive was created. The @code{name}
  5697. field contains the @code{name} given after the @value{op-label} option.
  5698. The @code{size} field is zero. Only the first file in each volume
  5699. of an archive should have this type.
  5700. @end table
  5701. You may have trouble reading a @acronym{GNU} format archive on a
  5702. non-@acronym{GNU} system if the options @value{op-incremental},
  5703. @value{op-multi-volume}, @value{op-sparse}, or @value{op-label} were
  5704. used when writing the archive. In general, if @command{tar} does not
  5705. use the @acronym{GNU}-added fields of the header, other versions of
  5706. @command{tar} should be able to read the archive. Otherwise, the
  5707. @command{tar} program will give an error, the most likely one being a
  5708. checksum error.
  5709. @node cpio
  5710. @section Comparison of @command{tar} and @command{cpio}
  5711. @UNREVISED
  5712. @FIXME{Reorganize the following material}
  5713. The @command{cpio} archive formats, like @command{tar}, do have maximum
  5714. pathname lengths. The binary and old ASCII formats have a max path
  5715. length of 256, and the new ASCII and CRC ASCII formats have a max
  5716. path length of 1024. @acronym{GNU} @command{cpio} can read and write archives
  5717. with arbitrary pathname lengths, but other @command{cpio} implementations
  5718. may crash unexplainedly trying to read them.
  5719. @command{tar} handles symbolic links in the form in which it comes in BSD;
  5720. @command{cpio} doesn't handle symbolic links in the form in which it comes
  5721. in System V prior to SVR4, and some vendors may have added symlinks
  5722. to their system without enhancing @command{cpio} to know about them.
  5723. Others may have enhanced it in a way other than the way I did it
  5724. at Sun, and which was adopted by AT&T (and which is, I think, also
  5725. present in the @command{cpio} that Berkeley picked up from AT&T and put
  5726. into a later BSD release---I think I gave them my changes).
  5727. (SVR4 does some funny stuff with @command{tar}; basically, its @command{cpio}
  5728. can handle @command{tar} format input, and write it on output, and it
  5729. probably handles symbolic links. They may not have bothered doing
  5730. anything to enhance @command{tar} as a result.)
  5731. @command{cpio} handles special files; traditional @command{tar} doesn't.
  5732. @command{tar} comes with V7, System III, System V, and BSD source;
  5733. @command{cpio} comes only with System III, System V, and later BSD
  5734. (4.3-tahoe and later).
  5735. @command{tar}'s way of handling multiple hard links to a file can handle
  5736. file systems that support 32-bit inumbers (e.g., the BSD file system);
  5737. @command{cpio}s way requires you to play some games (in its "binary"
  5738. format, i-numbers are only 16 bits, and in its "portable ASCII" format,
  5739. they're 18 bits---it would have to play games with the "file system ID"
  5740. field of the header to make sure that the file system ID/i-number pairs
  5741. of different files were always different), and I don't know which
  5742. @command{cpio}s, if any, play those games. Those that don't might get
  5743. confused and think two files are the same file when they're not, and
  5744. make hard links between them.
  5745. @command{tar}s way of handling multiple hard links to a file places only
  5746. one copy of the link on the tape, but the name attached to that copy
  5747. is the @emph{only} one you can use to retrieve the file; @command{cpio}s
  5748. way puts one copy for every link, but you can retrieve it using any
  5749. of the names.
  5750. @quotation
  5751. What type of check sum (if any) is used, and how is this calculated.
  5752. @end quotation
  5753. See the attached manual pages for @command{tar} and @command{cpio} format.
  5754. @command{tar} uses a checksum which is the sum of all the bytes in the
  5755. @command{tar} header for a file; @command{cpio} uses no checksum.
  5756. @quotation
  5757. If anyone knows why @command{cpio} was made when @command{tar} was present
  5758. at the unix scene,
  5759. @end quotation
  5760. It wasn't. @command{cpio} first showed up in PWB/UNIX 1.0; no
  5761. generally-available version of UNIX had @command{tar} at the time. I don't
  5762. know whether any version that was generally available @emph{within AT&T}
  5763. had @command{tar}, or, if so, whether the people within AT&T who did
  5764. @command{cpio} knew about it.
  5765. On restore, if there is a corruption on a tape @command{tar} will stop at
  5766. that point, while @command{cpio} will skip over it and try to restore the
  5767. rest of the files.
  5768. The main difference is just in the command syntax and header format.
  5769. @command{tar} is a little more tape-oriented in that everything is blocked
  5770. to start on a record boundary.
  5771. @quotation
  5772. Is there any differences between the ability to recover crashed
  5773. archives between the two of them. (Is there any chance of recovering
  5774. crashed archives at all.)
  5775. @end quotation
  5776. Theoretically it should be easier under @command{tar} since the blocking
  5777. lets you find a header with some variation of @samp{dd skip=@var{nn}}.
  5778. However, modern @command{cpio}'s and variations have an option to just
  5779. search for the next file header after an error with a reasonable chance
  5780. of resyncing. However, lots of tape driver software won't allow you to
  5781. continue past a media error which should be the only reason for getting
  5782. out of sync unless a file changed sizes while you were writing the
  5783. archive.
  5784. @quotation
  5785. If anyone knows why @command{cpio} was made when @command{tar} was present
  5786. at the unix scene, please tell me about this too.
  5787. @end quotation
  5788. Probably because it is more media efficient (by not blocking everything
  5789. and using only the space needed for the headers where @command{tar}
  5790. always uses 512 bytes per file header) and it knows how to archive
  5791. special files.
  5792. You might want to look at the freely available alternatives. The
  5793. major ones are @command{afio}, @acronym{GNU} @command{tar}, and
  5794. @command{pax}, each of which have their own extensions with some
  5795. backwards compatibility.
  5796. Sparse files were @command{tar}red as sparse files (which you can
  5797. easily test, because the resulting archive gets smaller, and
  5798. @acronym{GNU} @command{cpio} can no longer read it).
  5799. @node Media
  5800. @chapter Tapes and Other Archive Media
  5801. @UNREVISED
  5802. A few special cases about tape handling warrant more detailed
  5803. description. These special cases are discussed below.
  5804. Many complexities surround the use of @command{tar} on tape drives. Since
  5805. the creation and manipulation of archives located on magnetic tape was
  5806. the original purpose of @command{tar}, it contains many features making
  5807. such manipulation easier.
  5808. Archives are usually written on dismountable media---tape cartridges,
  5809. mag tapes, or floppy disks.
  5810. The amount of data a tape or disk holds depends not only on its size,
  5811. but also on how it is formatted. A 2400 foot long reel of mag tape
  5812. holds 40 megabytes of data when formatted at 1600 bits per inch. The
  5813. physically smaller EXABYTE tape cartridge holds 2.3 gigabytes.
  5814. Magnetic media are re-usable---once the archive on a tape is no longer
  5815. needed, the archive can be erased and the tape or disk used over.
  5816. Media quality does deteriorate with use, however. Most tapes or disks
  5817. should be discarded when they begin to produce data errors. EXABYTE
  5818. tape cartridges should be discarded when they generate an @dfn{error
  5819. count} (number of non-usable bits) of more than 10k.
  5820. Magnetic media are written and erased using magnetic fields, and
  5821. should be protected from such fields to avoid damage to stored data.
  5822. Sticking a floppy disk to a filing cabinet using a magnet is probably
  5823. not a good idea.
  5824. @menu
  5825. * Device:: Device selection and switching
  5826. * Remote Tape Server::
  5827. * Common Problems and Solutions::
  5828. * Blocking:: Blocking
  5829. * Many:: Many archives on one tape
  5830. * Using Multiple Tapes:: Using Multiple Tapes
  5831. * label:: Including a Label in the Archive
  5832. * verify::
  5833. * Write Protection::
  5834. @end menu
  5835. @node Device
  5836. @section Device Selection and Switching
  5837. @UNREVISED
  5838. @table @kbd
  5839. @item -f [@var{hostname}:]@var{file}
  5840. @itemx --file=[@var{hostname}:]@var{file}
  5841. Use archive file or device @var{file} on @var{hostname}.
  5842. @end table
  5843. This option is used to specify the file name of the archive @command{tar}
  5844. works on.
  5845. If the file name is @samp{-}, @command{tar} reads the archive from standard
  5846. input (when listing or extracting), or writes it to standard output
  5847. (when creating). If the @samp{-} file name is given when updating an
  5848. archive, @command{tar} will read the original archive from its standard
  5849. input, and will write the entire new archive to its standard output.
  5850. If the file name contains a @samp{:}, it is interpreted as
  5851. @samp{hostname:file name}. If the @var{hostname} contains an @dfn{at}
  5852. sign (@kbd{@@}), it is treated as @samp{user@@hostname:file name}. In
  5853. either case, @command{tar} will invoke the command @command{rsh} (or
  5854. @command{remsh}) to start up an @file{/etc/rmt} on the remote machine. If
  5855. you give an alternate login name, it will be given to the @command{rsh}.
  5856. Naturally, the remote machine must have an executable @file{/etc/rmt}.
  5857. This program is free software from the University of California, and a
  5858. copy of the source code can be found with the sources for @command{tar};
  5859. it's compiled and installed by default.
  5860. If this option is not given, but the environment variable @env{TAPE}
  5861. is set, its value is used; otherwise, old versions of @command{tar}
  5862. used a default archive name (which was picked when @command{tar} was
  5863. compiled). The default is normally set up to be the @dfn{first} tape
  5864. drive or other transportable I/O medium on the system.
  5865. Starting with version 1.11.5, @acronym{GNU} @command{tar} uses
  5866. standard input and standard output as the default device, and I will
  5867. not try anymore supporting automatic device detection at installation
  5868. time. This was failing really in too many cases, it was hopeless.
  5869. This is now completely left to the installer to override standard
  5870. input and standard output for default device, if this seems
  5871. preferable. Further, I think @emph{most} actual usages of
  5872. @command{tar} are done with pipes or disks, not really tapes,
  5873. cartridges or diskettes.
  5874. Some users think that using standard input and output is running
  5875. after trouble. This could lead to a nasty surprise on your screen if
  5876. you forget to specify an output file name---especially if you are going
  5877. through a network or terminal server capable of buffering large amounts
  5878. of output. We had so many bug reports in that area of configuring
  5879. default tapes automatically, and so many contradicting requests, that
  5880. we finally consider the problem to be portably intractable. We could
  5881. of course use something like @samp{/dev/tape} as a default, but this
  5882. is @emph{also} running after various kind of trouble, going from hung
  5883. processes to accidental destruction of real tapes. After having seen
  5884. all this mess, using standard input and output as a default really
  5885. sounds like the only clean choice left, and a very useful one too.
  5886. @acronym{GNU} @command{tar} reads and writes archive in records, I
  5887. suspect this is the main reason why block devices are preferred over
  5888. character devices. Most probably, block devices are more efficient
  5889. too. The installer could also check for @samp{DEFTAPE} in
  5890. @file{<sys/mtio.h>}.
  5891. @table @kbd
  5892. @item --force-local
  5893. Archive file is local even if it contains a colon.
  5894. @item --rsh-command=@var{command}
  5895. Use remote @var{command} instead of @command{rsh}. This option exists
  5896. so that people who use something other than the standard @command{rsh}
  5897. (e.g., a Kerberized @command{rsh}) can access a remote device.
  5898. When this command is not used, the shell command found when
  5899. the @command{tar} program was installed is used instead. This is
  5900. the first found of @file{/usr/ucb/rsh}, @file{/usr/bin/remsh},
  5901. @file{/usr/bin/rsh}, @file{/usr/bsd/rsh} or @file{/usr/bin/nsh}.
  5902. The installer may have overridden this by defining the environment
  5903. variable @env{RSH} @emph{at installation time}.
  5904. @item -[0-7][lmh]
  5905. Specify drive and density.
  5906. @item -M
  5907. @itemx --multi-volume
  5908. Create/list/extract multi-volume archive.
  5909. This option causes @command{tar} to write a @dfn{multi-volume} archive---one
  5910. that may be larger than will fit on the medium used to hold it.
  5911. @xref{Multi-Volume Archives}.
  5912. @item -L @var{num}
  5913. @itemx --tape-length=@var{num}
  5914. Change tape after writing @var{num} x 1024 bytes.
  5915. This option might be useful when your tape drivers do not properly
  5916. detect end of physical tapes. By being slightly conservative on the
  5917. maximum tape length, you might avoid the problem entirely.
  5918. @item -F @var{file}
  5919. @itemx --info-script=@var{file}
  5920. @itemx --new-volume-script=@var{file}
  5921. Execute @file{file} at end of each tape. If @file{file} exits with
  5922. nonzero status, exit. This implies @value{op-multi-volume}.
  5923. @end table
  5924. @node Remote Tape Server
  5925. @section The Remote Tape Server
  5926. @cindex remote tape drive
  5927. @pindex rmt
  5928. In order to access the tape drive on a remote machine, @command{tar}
  5929. uses the remote tape server written at the University of California at
  5930. Berkeley. The remote tape server must be installed as @file{/etc/rmt}
  5931. on any machine whose tape drive you want to use. @command{tar} calls
  5932. @file{/etc/rmt} by running an @command{rsh} or @command{remsh} to the remote
  5933. machine, optionally using a different login name if one is supplied.
  5934. A copy of the source for the remote tape server is provided. It is
  5935. Copyright @copyright{} 1983 by the Regents of the University of
  5936. California, but can be freely distributed. Instructions for compiling
  5937. and installing it are included in the @file{Makefile}.
  5938. @cindex absolute file names
  5939. Unless you use the @value{op-absolute-names} option, @acronym{GNU}
  5940. @command{tar} will not allow you to create an archive that contains
  5941. absolute file names (a file name beginning with @samp{/}.) If you try,
  5942. @command{tar} will automatically remove the leading @samp{/} from the
  5943. file names it stores in the archive. It will also type a warning
  5944. message telling you what it is doing.
  5945. When reading an archive that was created with a different
  5946. @command{tar} program, @acronym{GNU} @command{tar} automatically
  5947. extracts entries in the archive which have absolute file names as if
  5948. the file names were not absolute. This is an important feature. A
  5949. visitor here once gave a @command{tar} tape to an operator to restore;
  5950. the operator used Sun @command{tar} instead of @acronym{GNU}
  5951. @command{tar}, and the result was that it replaced large portions of
  5952. our @file{/bin} and friends with versions from the tape; needless to
  5953. say, we were unhappy about having to recover the file system from
  5954. backup tapes.
  5955. For example, if the archive contained a file @file{/usr/bin/computoy},
  5956. @acronym{GNU} @command{tar} would extract the file to @file{usr/bin/computoy},
  5957. relative to the current directory. If you want to extract the files in
  5958. an archive to the same absolute names that they had when the archive
  5959. was created, you should do a @samp{cd /} before extracting the files
  5960. from the archive, or you should either use the @value{op-absolute-names}
  5961. option, or use the command @samp{tar -C / @dots{}}.
  5962. @cindex Ultrix 3.1 and write failure
  5963. Some versions of Unix (Ultrix 3.1 is known to have this problem),
  5964. can claim that a short write near the end of a tape succeeded,
  5965. when it actually failed. This will result in the -M option not
  5966. working correctly. The best workaround at the moment is to use a
  5967. significantly larger blocking factor than the default 20.
  5968. In order to update an archive, @command{tar} must be able to backspace the
  5969. archive in order to reread or rewrite a record that was just read (or
  5970. written). This is currently possible only on two kinds of files: normal
  5971. disk files (or any other file that can be backspaced with @samp{lseek}),
  5972. and industry-standard 9-track magnetic tape (or any other kind of tape
  5973. that can be backspaced with the @code{MTIOCTOP} @code{ioctl}.
  5974. This means that the @value{op-append}, @value{op-update},
  5975. @value{op-concatenate}, and @value{op-delete} commands will not work on any
  5976. other kind of file. Some media simply cannot be backspaced, which
  5977. means these commands and options will never be able to work on them.
  5978. These non-backspacing media include pipes and cartridge tape drives.
  5979. Some other media can be backspaced, and @command{tar} will work on them
  5980. once @command{tar} is modified to do so.
  5981. Archives created with the @value{op-multi-volume}, @value{op-label}, and
  5982. @value{op-incremental} options may not be readable by other version
  5983. of @command{tar}. In particular, restoring a file that was split over
  5984. a volume boundary will require some careful work with @command{dd}, if
  5985. it can be done at all. Other versions of @command{tar} may also create
  5986. an empty file whose name is that of the volume header. Some versions
  5987. of @command{tar} may create normal files instead of directories archived
  5988. with the @value{op-incremental} option.
  5989. @node Common Problems and Solutions
  5990. @section Some Common Problems and their Solutions
  5991. @ifclear PUBLISH
  5992. @format
  5993. errors from system:
  5994. permission denied
  5995. no such file or directory
  5996. not owner
  5997. errors from @command{tar}:
  5998. directory checksum error
  5999. header format error
  6000. errors from media/system:
  6001. i/o error
  6002. device busy
  6003. @end format
  6004. @end ifclear
  6005. @node Blocking
  6006. @section Blocking
  6007. @UNREVISED
  6008. @dfn{Block} and @dfn{record} terminology is rather confused, and it
  6009. is also confusing to the expert reader. On the other hand, readers
  6010. who are new to the field have a fresh mind, and they may safely skip
  6011. the next two paragraphs, as the remainder of this manual uses those
  6012. two terms in a quite consistent way.
  6013. John Gilmore, the writer of the public domain @command{tar} from which
  6014. @acronym{GNU} @command{tar} was originally derived, wrote (June 1995):
  6015. @quotation
  6016. The nomenclature of tape drives comes from IBM, where I believe
  6017. they were invented for the IBM 650 or so. On IBM mainframes, what
  6018. is recorded on tape are tape blocks. The logical organization of
  6019. data is into records. There are various ways of putting records into
  6020. blocks, including @code{F} (fixed sized records), @code{V} (variable
  6021. sized records), @code{FB} (fixed blocked: fixed size records, @var{n}
  6022. to a block), @code{VB} (variable size records, @var{n} to a block),
  6023. @code{VSB} (variable spanned blocked: variable sized records that can
  6024. occupy more than one block), etc. The @code{JCL} @samp{DD RECFORM=}
  6025. parameter specified this to the operating system.
  6026. The Unix man page on @command{tar} was totally confused about this.
  6027. When I wrote @code{PD TAR}, I used the historically correct terminology
  6028. (@command{tar} writes data records, which are grouped into blocks).
  6029. It appears that the bogus terminology made it into @sc{posix} (no surprise
  6030. here), and now Fran@,{c}ois has migrated that terminology back
  6031. into the source code too.
  6032. @end quotation
  6033. The term @dfn{physical block} means the basic transfer chunk from or
  6034. to a device, after which reading or writing may stop without anything
  6035. being lost. In this manual, the term @dfn{block} usually refers to
  6036. a disk physical block, @emph{assuming} that each disk block is 512
  6037. bytes in length. It is true that some disk devices have different
  6038. physical blocks, but @command{tar} ignore these differences in its own
  6039. format, which is meant to be portable, so a @command{tar} block is always
  6040. 512 bytes in length, and @dfn{block} always mean a @command{tar} block.
  6041. The term @dfn{logical block} often represents the basic chunk of
  6042. allocation of many disk blocks as a single entity, which the operating
  6043. system treats somewhat atomically; this concept is only barely used
  6044. in @acronym{GNU} @command{tar}.
  6045. The term @dfn{physical record} is another way to speak of a physical
  6046. block, those two terms are somewhat interchangeable. In this manual,
  6047. the term @dfn{record} usually refers to a tape physical block,
  6048. @emph{assuming} that the @command{tar} archive is kept on magnetic tape.
  6049. It is true that archives may be put on disk or used with pipes,
  6050. but nevertheless, @command{tar} tries to read and write the archive one
  6051. @dfn{record} at a time, whatever the medium in use. One record is made
  6052. up of an integral number of blocks, and this operation of putting many
  6053. disk blocks into a single tape block is called @dfn{reblocking}, or
  6054. more simply, @dfn{blocking}. The term @dfn{logical record} refers to
  6055. the logical organization of many characters into something meaningful
  6056. to the application. The term @dfn{unit record} describes a small set
  6057. of characters which are transmitted whole to or by the application,
  6058. and often refers to a line of text. Those two last terms are unrelated
  6059. to what we call a @dfn{record} in @acronym{GNU} @command{tar}.
  6060. When writing to tapes, @command{tar} writes the contents of the archive
  6061. in chunks known as @dfn{records}. To change the default blocking
  6062. factor, use the @value{op-blocking-factor} option. Each record will
  6063. then be composed of @var{512-size} blocks. (Each @command{tar} block is
  6064. 512 bytes. @xref{Standard}.) Each file written to the archive uses
  6065. at least one full record. As a result, using a larger record size
  6066. can result in more wasted space for small files. On the other hand, a
  6067. larger record size can often be read and written much more efficiently.
  6068. Further complicating the problem is that some tape drives ignore the
  6069. blocking entirely. For these, a larger record size can still improve
  6070. performance (because the software layers above the tape drive still
  6071. honor the blocking), but not as dramatically as on tape drives that
  6072. honor blocking.
  6073. When reading an archive, @command{tar} can usually figure out the
  6074. record size on itself. When this is the case, and a non-standard
  6075. record size was used when the archive was created, @command{tar} will
  6076. print a message about a non-standard blocking factor, and then operate
  6077. normally. On some tape devices, however, @command{tar} cannot figure
  6078. out the record size itself. On most of those, you can specify a
  6079. blocking factor (with @value{op-blocking-factor}) larger than the
  6080. actual blocking factor, and then use the @value{op-read-full-records}
  6081. option. (If you specify a blocking factor with
  6082. @value{op-blocking-factor} and don't use the
  6083. @value{op-read-full-records} option, then @command{tar} will not
  6084. attempt to figure out the recording size itself.) On some devices,
  6085. you must always specify the record size exactly with
  6086. @value{op-blocking-factor} when reading, because @command{tar} cannot
  6087. figure it out. In any case, use @value{op-list} before doing any
  6088. extractions to see whether @command{tar} is reading the archive
  6089. correctly.
  6090. @command{tar} blocks are all fixed size (512 bytes), and its scheme for
  6091. putting them into records is to put a whole number of them (one or
  6092. more) into each record. @command{tar} records are all the same size;
  6093. at the end of the file there's a block containing all zeros, which
  6094. is how you tell that the remainder of the last record(s) are garbage.
  6095. In a standard @command{tar} file (no options), the block size is 512
  6096. and the record size is 10240, for a blocking factor of 20. What the
  6097. @value{op-blocking-factor} option does is sets the blocking factor,
  6098. changing the record size while leaving the block size at 512 bytes.
  6099. 20 was fine for ancient 800 or 1600 bpi reel-to-reel tape drives;
  6100. most tape drives these days prefer much bigger records in order to
  6101. stream and not waste tape. When writing tapes for myself, some tend
  6102. to use a factor of the order of 2048, say, giving a record size of
  6103. around one megabyte.
  6104. If you use a blocking factor larger than 20, older @command{tar}
  6105. programs might not be able to read the archive, so we recommend this
  6106. as a limit to use in practice. @acronym{GNU} @command{tar}, however,
  6107. will support arbitrarily large record sizes, limited only by the
  6108. amount of virtual memory or the physical characteristics of the tape
  6109. device.
  6110. @menu
  6111. * Format Variations:: Format Variations
  6112. * Blocking Factor:: The Blocking Factor of an Archive
  6113. @end menu
  6114. @node Format Variations
  6115. @subsection Format Variations
  6116. @cindex Format Parameters
  6117. @cindex Format Options
  6118. @cindex Options, archive format specifying
  6119. @cindex Options, format specifying
  6120. @UNREVISED
  6121. Format parameters specify how an archive is written on the archive
  6122. media. The best choice of format parameters will vary depending on
  6123. the type and number of files being archived, and on the media used to
  6124. store the archive.
  6125. To specify format parameters when accessing or creating an archive,
  6126. you can use the options described in the following sections.
  6127. If you do not specify any format parameters, @command{tar} uses
  6128. default parameters. You cannot modify a compressed archive.
  6129. If you create an archive with the @value{op-blocking-factor} option
  6130. specified (@value{pxref-blocking-factor}), you must specify that
  6131. blocking-factor when operating on the archive. @xref{Formats}, for other
  6132. examples of format parameter considerations.
  6133. @node Blocking Factor
  6134. @subsection The Blocking Factor of an Archive
  6135. @cindex Blocking Factor
  6136. @cindex Record Size
  6137. @cindex Number of blocks per record
  6138. @cindex Number of bytes per record
  6139. @cindex Bytes per record
  6140. @cindex Blocks per record
  6141. @UNREVISED
  6142. The data in an archive is grouped into blocks, which are 512 bytes.
  6143. Blocks are read and written in whole number multiples called
  6144. @dfn{records}. The number of blocks in a record (ie. the size of a
  6145. record in units of 512 bytes) is called the @dfn{blocking factor}.
  6146. The @value{op-blocking-factor} option specifies the blocking factor of
  6147. an archive. The default blocking factor is typically 20 (ie.@:
  6148. 10240 bytes), but can be specified at installation. To find out
  6149. the blocking factor of an existing archive, use @samp{tar --list
  6150. --file=@var{archive-name}}. This may not work on some devices.
  6151. Records are separated by gaps, which waste space on the archive media.
  6152. If you are archiving on magnetic tape, using a larger blocking factor
  6153. (and therefore larger records) provides faster throughput and allows you
  6154. to fit more data on a tape (because there are fewer gaps). If you are
  6155. archiving on cartridge, a very large blocking factor (say 126 or more)
  6156. greatly increases performance. A smaller blocking factor, on the other
  6157. hand, may be useful when archiving small files, to avoid archiving lots
  6158. of nulls as @command{tar} fills out the archive to the end of the record.
  6159. In general, the ideal record size depends on the size of the
  6160. inter-record gaps on the tape you are using, and the average size of the
  6161. files you are archiving. @xref{create}, for information on
  6162. writing archives.
  6163. @FIXME{Need example of using a cartridge with blocking factor=126 or more.}
  6164. Archives with blocking factors larger than 20 cannot be read
  6165. by very old versions of @command{tar}, or by some newer versions
  6166. of @command{tar} running on old machines with small address spaces.
  6167. With @acronym{GNU} @command{tar}, the blocking factor of an archive is limited
  6168. only by the maximum record size of the device containing the archive,
  6169. or by the amount of available virtual memory.
  6170. Also, on some systems, not using adequate blocking factors, as sometimes
  6171. imposed by the device drivers, may yield unexpected diagnostics. For
  6172. example, this has been reported:
  6173. @example
  6174. Cannot write to /dev/dlt: Invalid argument
  6175. @end example
  6176. @noindent
  6177. In such cases, it sometimes happen that the @command{tar} bundled by
  6178. the system is aware of block size idiosyncrasies, while @acronym{GNU}
  6179. @command{tar} requires an explicit specification for the block size,
  6180. which it cannot guess. This yields some people to consider
  6181. @acronym{GNU} @command{tar} is misbehaving, because by comparison,
  6182. @cite{the bundle @command{tar} works OK}. Adding @w{@kbd{-b 256}},
  6183. for example, might resolve the problem.
  6184. If you use a non-default blocking factor when you create an archive, you
  6185. must specify the same blocking factor when you modify that archive. Some
  6186. archive devices will also require you to specify the blocking factor when
  6187. reading that archive, however this is not typically the case. Usually, you
  6188. can use @value{op-list} without specifying a blocking factor---@command{tar}
  6189. reports a non-default record size and then lists the archive members as
  6190. it would normally. To extract files from an archive with a non-standard
  6191. blocking factor (particularly if you're not sure what the blocking factor
  6192. is), you can usually use the @value{op-read-full-records} option while
  6193. specifying a blocking factor larger then the blocking factor of the archive
  6194. (ie. @samp{tar --extract --read-full-records --blocking-factor=300}.
  6195. @xref{list}, for more information on the @value{op-list}
  6196. operation. @xref{Reading}, for a more detailed explanation of that option.
  6197. @table @kbd
  6198. @item --blocking-factor=@var{number}
  6199. @itemx -b @var{number}
  6200. Specifies the blocking factor of an archive. Can be used with any
  6201. operation, but is usually not necessary with @value{op-list}.
  6202. @end table
  6203. Device blocking
  6204. @table @kbd
  6205. @item -b @var{blocks}
  6206. @itemx --blocking-factor=@var{blocks}
  6207. Set record size to @math{@var{blocks} * 512} bytes.
  6208. This option is used to specify a @dfn{blocking factor} for the archive.
  6209. When reading or writing the archive, @command{tar}, will do reads and writes
  6210. of the archive in records of @math{@var{block}*512} bytes. This is true
  6211. even when the archive is compressed. Some devices requires that all
  6212. write operations be a multiple of a certain size, and so, @command{tar}
  6213. pads the archive out to the next record boundary.
  6214. The default blocking factor is set when @command{tar} is compiled, and is
  6215. typically 20. Blocking factors larger than 20 cannot be read by very
  6216. old versions of @command{tar}, or by some newer versions of @command{tar}
  6217. running on old machines with small address spaces.
  6218. With a magnetic tape, larger records give faster throughput and fit
  6219. more data on a tape (because there are fewer inter-record gaps).
  6220. If the archive is in a disk file or a pipe, you may want to specify
  6221. a smaller blocking factor, since a large one will result in a large
  6222. number of null bytes at the end of the archive.
  6223. When writing cartridge or other streaming tapes, a much larger
  6224. blocking factor (say 126 or more) will greatly increase performance.
  6225. However, you must specify the same blocking factor when reading or
  6226. updating the archive.
  6227. Apparently, Exabyte drives have a physical block size of 8K bytes.
  6228. If we choose our blocksize as a multiple of 8k bytes, then the problem
  6229. seems to dissapper. Id est, we are using block size of 112 right
  6230. now, and we haven't had the problem since we switched@dots{}
  6231. With @acronym{GNU} @command{tar} the blocking factor is limited only
  6232. by the maximum record size of the device containing the archive, or by
  6233. the amount of available virtual memory.
  6234. However, deblocking or reblocking is virtually avoided in a special
  6235. case which often occurs in practice, but which requires all the
  6236. following conditions to be simultaneously true:
  6237. @itemize @bullet
  6238. @item
  6239. the archive is subject to a compression option,
  6240. @item
  6241. the archive is not handled through standard input or output, nor
  6242. redirected nor piped,
  6243. @item
  6244. the archive is directly handled to a local disk, instead of any special
  6245. device,
  6246. @item
  6247. @value{op-blocking-factor} is not explicitly specified on the @command{tar}
  6248. invocation.
  6249. @end itemize
  6250. If the output goes directly to a local disk, and not through
  6251. stdout, then the last write is not extended to a full record size.
  6252. Otherwise, reblocking occurs. Here are a few other remarks on this
  6253. topic:
  6254. @itemize @bullet
  6255. @item
  6256. @command{gzip} will complain about trailing garbage if asked to
  6257. uncompress a compressed archive on tape, there is an option to turn
  6258. the message off, but it breaks the regularity of simply having to use
  6259. @samp{@var{prog} -d} for decompression. It would be nice if gzip was
  6260. silently ignoring any number of trailing zeros. I'll ask Jean-loup
  6261. Gailly, by sending a copy of this message to him.
  6262. @item
  6263. @command{compress} does not show this problem, but as Jean-loup pointed
  6264. out to Michael, @samp{compress -d} silently adds garbage after
  6265. the result of decompression, which tar ignores because it already
  6266. recognized its end-of-file indicator. So this bug may be safely
  6267. ignored.
  6268. @item
  6269. @samp{gzip -d -q} will be silent about the trailing zeros indeed,
  6270. but will still return an exit status of 2 which tar reports in turn.
  6271. @command{tar} might ignore the exit status returned, but I hate doing
  6272. that, as it weakens the protection @command{tar} offers users against
  6273. other possible problems at decompression time. If @command{gzip} was
  6274. silently skipping trailing zeros @emph{and} also avoiding setting the
  6275. exit status in this innocuous case, that would solve this situation.
  6276. @item
  6277. @command{tar} should become more solid at not stopping to read a pipe at
  6278. the first null block encountered. This inelegantly breaks the pipe.
  6279. @command{tar} should rather drain the pipe out before exiting itself.
  6280. @end itemize
  6281. @item -i
  6282. @itemx --ignore-zeros
  6283. Ignore blocks of zeros in archive (means EOF).
  6284. The @value{op-ignore-zeros} option causes @command{tar} to ignore blocks
  6285. of zeros in the archive. Normally a block of zeros indicates the
  6286. end of the archive, but when reading a damaged archive, or one which
  6287. was created by concatenating several archives together, this option
  6288. allows @command{tar} to read the entire archive. This option is not on
  6289. by default because many versions of @command{tar} write garbage after
  6290. the zeroed blocks.
  6291. Note that this option causes @command{tar} to read to the end of the
  6292. archive file, which may sometimes avoid problems when multiple files
  6293. are stored on a single physical tape.
  6294. @item -B
  6295. @itemx --read-full-records
  6296. Reblock as we read (for reading 4.2BSD pipes).
  6297. If @value{op-read-full-records} is used, @command{tar} will not panic if an
  6298. attempt to read a record from the archive does not return a full record.
  6299. Instead, @command{tar} will keep reading until it has obtained a full
  6300. record.
  6301. This option is turned on by default when @command{tar} is reading
  6302. an archive from standard input, or from a remote machine. This is
  6303. because on BSD Unix systems, a read of a pipe will return however
  6304. much happens to be in the pipe, even if it is less than @command{tar}
  6305. requested. If this option was not used, @command{tar} would fail as
  6306. soon as it read an incomplete record from the pipe.
  6307. This option is also useful with the commands for updating an archive.
  6308. @end table
  6309. Tape blocking
  6310. @FIXME{Appropriate options should be moved here from elsewhere.}
  6311. @cindex blocking factor
  6312. @cindex tape blocking
  6313. When handling various tapes or cartridges, you have to take care of
  6314. selecting a proper blocking, that is, the number of disk blocks you
  6315. put together as a single tape block on the tape, without intervening
  6316. tape gaps. A @dfn{tape gap} is a small landing area on the tape
  6317. with no information on it, used for decelerating the tape to a
  6318. full stop, and for later regaining the reading or writing speed.
  6319. When the tape driver starts reading a record, the record has to
  6320. be read whole without stopping, as a tape gap is needed to stop the
  6321. tape motion without loosing information.
  6322. @cindex Exabyte blocking
  6323. @cindex DAT blocking
  6324. Using higher blocking (putting more disk blocks per tape block) will use
  6325. the tape more efficiently as there will be less tape gaps. But reading
  6326. such tapes may be more difficult for the system, as more memory will be
  6327. required to receive at once the whole record. Further, if there is a
  6328. reading error on a huge record, this is less likely that the system will
  6329. succeed in recovering the information. So, blocking should not be too
  6330. low, nor it should be too high. @command{tar} uses by default a blocking of
  6331. 20 for historical reasons, and it does not really matter when reading or
  6332. writing to disk. Current tape technology would easily accommodate higher
  6333. blockings. Sun recommends a blocking of 126 for Exabytes and 96 for DATs.
  6334. We were told that for some DLT drives, the blocking should be a multiple
  6335. of 4Kb, preferably 64Kb (@w{@kbd{-b 128}}) or 256 for decent performance.
  6336. Other manufacturers may use different recommendations for the same tapes.
  6337. This might also depends of the buffering techniques used inside modern
  6338. tape controllers. Some imposes a minimum blocking, or a maximum blocking.
  6339. Others request blocking to be some exponent of two.
  6340. So, there is no fixed rule for blocking. But blocking at read time
  6341. should ideally be the same as blocking used at write time. At one place
  6342. I know, with a wide variety of equipment, they found it best to use a
  6343. blocking of 32 to guarantee that their tapes are fully interchangeable.
  6344. I was also told that, for recycled tapes, prior erasure (by the same
  6345. drive unit that will be used to create the archives) sometimes lowers
  6346. the error rates observed at rewriting time.
  6347. I might also use @samp{--number-blocks} instead of
  6348. @samp{--block-number}, so @samp{--block} will then expand to
  6349. @samp{--blocking-factor} unambiguously.
  6350. @node Many
  6351. @section Many Archives on One Tape
  6352. @FIXME{Appropriate options should be moved here from elsewhere.}
  6353. @findex ntape @r{device}
  6354. Most tape devices have two entries in the @file{/dev} directory, or
  6355. entries that come in pairs, which differ only in the minor number for
  6356. this device. Let's take for example @file{/dev/tape}, which often
  6357. points to the only or usual tape device of a given system. There might
  6358. be a corresponding @file{/dev/nrtape} or @file{/dev/ntape}. The simpler
  6359. name is the @emph{rewinding} version of the device, while the name
  6360. having @samp{nr} in it is the @emph{no rewinding} version of the same
  6361. device.
  6362. A rewinding tape device will bring back the tape to its beginning point
  6363. automatically when this device is opened or closed. Since @command{tar}
  6364. opens the archive file before using it and closes it afterwards, this
  6365. means that a simple:
  6366. @example
  6367. $ @kbd{tar cf /dev/tape @var{directory}}
  6368. @end example
  6369. @noindent
  6370. will reposition the tape to its beginning both prior and after saving
  6371. @var{directory} contents to it, thus erasing prior tape contents and
  6372. making it so that any subsequent write operation will destroy what has
  6373. just been saved.
  6374. @cindex tape positioning
  6375. So, a rewinding device is normally meant to hold one and only one file.
  6376. If you want to put more than one @command{tar} archive on a given tape, you
  6377. will need to avoid using the rewinding version of the tape device. You
  6378. will also have to pay special attention to tape positioning. Errors in
  6379. positioning may overwrite the valuable data already on your tape. Many
  6380. people, burnt by past experiences, will only use rewinding devices and
  6381. limit themselves to one file per tape, precisely to avoid the risk of
  6382. such errors. Be fully aware that writing at the wrong position on a
  6383. tape loses all information past this point and most probably until the
  6384. end of the tape, and this destroyed information @emph{cannot} be
  6385. recovered.
  6386. To save @var{directory-1} as a first archive at the beginning of a
  6387. tape, and leave that tape ready for a second archive, you should use:
  6388. @example
  6389. $ @kbd{mt -f /dev/nrtape rewind}
  6390. $ @kbd{tar cf /dev/nrtape @var{directory-1}}
  6391. @end example
  6392. @cindex tape marks
  6393. @dfn{Tape marks} are special magnetic patterns written on the tape
  6394. media, which are later recognizable by the reading hardware. These
  6395. marks are used after each file, when there are many on a single tape.
  6396. An empty file (that is to say, two tape marks in a row) signal the
  6397. logical end of the tape, after which no file exist. Usually,
  6398. non-rewinding tape device drivers will react to the close request issued
  6399. by @command{tar} by first writing two tape marks after your archive, and by
  6400. backspacing over one of these. So, if you remove the tape at that time
  6401. from the tape drive, it is properly terminated. But if you write
  6402. another file at the current position, the second tape mark will be
  6403. erased by the new information, leaving only one tape mark between files.
  6404. So, you may now save @var{directory-2} as a second archive after the
  6405. first on the same tape by issuing the command:
  6406. @example
  6407. $ @kbd{tar cf /dev/nrtape @var{directory-2}}
  6408. @end example
  6409. @noindent
  6410. and so on for all the archives you want to put on the same tape.
  6411. Another usual case is that you do not write all the archives the same
  6412. day, and you need to remove and store the tape between two archive
  6413. sessions. In general, you must remember how many files are already
  6414. saved on your tape. Suppose your tape already has 16 files on it, and
  6415. that you are ready to write the 17th. You have to take care of skipping
  6416. the first 16 tape marks before saving @var{directory-17}, say, by using
  6417. these commands:
  6418. @example
  6419. $ @kbd{mt -f /dev/nrtape rewind}
  6420. $ @kbd{mt -f /dev/nrtape fsf 16}
  6421. $ @kbd{tar cf /dev/nrtape @var{directory-17}}
  6422. @end example
  6423. In all the previous examples, we put aside blocking considerations, but
  6424. you should do the proper things for that as well. @xref{Blocking}.
  6425. @menu
  6426. * Tape Positioning:: Tape Positions and Tape Marks
  6427. * mt:: The @command{mt} Utility
  6428. @end menu
  6429. @node Tape Positioning
  6430. @subsection Tape Positions and Tape Marks
  6431. @UNREVISED
  6432. Just as archives can store more than one file from the file system,
  6433. tapes can store more than one archive file. To keep track of where
  6434. archive files (or any other type of file stored on tape) begin and
  6435. end, tape archive devices write magnetic @dfn{tape marks} on the
  6436. archive media. Tape drives write one tape mark between files,
  6437. two at the end of all the file entries.
  6438. If you think of data as a series of records "rrrr"'s, and tape marks as
  6439. "*"'s, a tape might look like the following:
  6440. @example
  6441. rrrr*rrrrrr*rrrrr*rr*rrrrr**-------------------------
  6442. @end example
  6443. Tape devices read and write tapes using a read/write @dfn{tape
  6444. head}---a physical part of the device which can only access one
  6445. point on the tape at a time. When you use @command{tar} to read or
  6446. write archive data from a tape device, the device will begin reading
  6447. or writing from wherever on the tape the tape head happens to be,
  6448. regardless of which archive or what part of the archive the tape
  6449. head is on. Before writing an archive, you should make sure that no
  6450. data on the tape will be overwritten (unless it is no longer needed).
  6451. Before reading an archive, you should make sure the tape head is at
  6452. the beginning of the archive you want to read. (The @code{restore}
  6453. script will find the archive automatically. @FIXME{There is no such
  6454. restore script!}@FIXME-xref{Scripted Restoration}@xref{mt}, for
  6455. an explanation of the tape moving utility.
  6456. If you want to add new archive file entries to a tape, you should
  6457. advance the tape to the end of the existing file entries, backspace
  6458. over the last tape mark, and write the new archive file. If you were
  6459. to add two archives to the example above, the tape might look like the
  6460. following:
  6461. @example
  6462. rrrr*rrrrrr*rrrrr*rr*rrrrr*rrr*rrrr**----------------
  6463. @end example
  6464. @node mt
  6465. @subsection The @command{mt} Utility
  6466. @UNREVISED
  6467. @FIXME{Is it true that this only works on non-block devices?
  6468. should explain the difference, (fixed or variable).}
  6469. @value{xref-blocking-factor}.
  6470. You can use the @command{mt} utility to advance or rewind a tape past a
  6471. specified number of archive files on the tape. This will allow you
  6472. to move to the beginning of an archive before extracting or reading
  6473. it, or to the end of all the archives before writing a new one.
  6474. @FIXME{Why isn't there an "advance 'til you find two tape marks
  6475. together"?}
  6476. The syntax of the @command{mt} command is:
  6477. @example
  6478. @kbd{mt [-f @var{tapename}] @var{operation} [@var{number}]}
  6479. @end example
  6480. where @var{tapename} is the name of the tape device, @var{number} is
  6481. the number of times an operation is performed (with a default of one),
  6482. and @var{operation} is one of the following:
  6483. @FIXME{is there any use for record operations?}
  6484. @table @kbd
  6485. @item eof
  6486. @itemx weof
  6487. Writes @var{number} tape marks at the current position on the tape.
  6488. @item fsf
  6489. Moves tape position forward @var{number} files.
  6490. @item bsf
  6491. Moves tape position back @var{number} files.
  6492. @item rewind
  6493. Rewinds the tape. (Ignores @var{number}).
  6494. @item offline
  6495. @itemx rewoff1
  6496. Rewinds the tape and takes the tape device off-line. (Ignores @var{number}).
  6497. @item status
  6498. Prints status information about the tape unit.
  6499. @end table
  6500. @FIXME{Is there a better way to frob the spacing on the list?}
  6501. If you don't specify a @var{tapename}, @command{mt} uses the environment
  6502. variable @env{TAPE}; if @env{TAPE} is not set, @command{mt} uses the device
  6503. @file{/dev/rmt12}.
  6504. @command{mt} returns a 0 exit status when the operation(s) were
  6505. successful, 1 if the command was unrecognized, and 2 if an operation
  6506. failed.
  6507. @FIXME{New node on how to find an archive?}
  6508. If you use @value{op-extract} with the @value{op-label} option specified,
  6509. @command{tar} will read an archive label (the tape head has to be positioned
  6510. on it) and print an error if the archive label doesn't match the
  6511. @var{archive-name} specified. @var{archive-name} can be any regular
  6512. expression. If the labels match, @command{tar} extracts the archive.
  6513. @value{xref-label}.
  6514. @FIXME-xref{Matching Format Parameters}@FIXME{fix cross
  6515. references}@samp{tar --list --label} will cause @command{tar} to print the
  6516. label.
  6517. @FIXME{Program to list all the labels on a tape?}
  6518. @node Using Multiple Tapes
  6519. @section Using Multiple Tapes
  6520. @UNREVISED
  6521. Often you might want to write a large archive, one larger than will fit
  6522. on the actual tape you are using. In such a case, you can run multiple
  6523. @command{tar} commands, but this can be inconvenient, particularly if you
  6524. are using options like @value{op-exclude} or dumping entire filesystems.
  6525. Therefore, @command{tar} supports multiple tapes automatically.
  6526. Use @value{op-multi-volume} on the command line, and then @command{tar} will,
  6527. when it reaches the end of the tape, prompt for another tape, and
  6528. continue the archive. Each tape will have an independent archive, and
  6529. can be read without needing the other. (As an exception to this, the
  6530. file that @command{tar} was archiving when it ran out of tape will usually
  6531. be split between the two archives; in this case you need to extract from
  6532. the first archive, using @value{op-multi-volume}, and then put in the
  6533. second tape when prompted, so @command{tar} can restore both halves of the
  6534. file.)
  6535. @acronym{GNU} @command{tar} multi-volume archives do not use a truly
  6536. portable format. You need @acronym{GNU} @command{tar} at both end to
  6537. process them properly.
  6538. When prompting for a new tape, @command{tar} accepts any of the following
  6539. responses:
  6540. @table @kbd
  6541. @item ?
  6542. Request @command{tar} to explain possible responses
  6543. @item q
  6544. Request @command{tar} to exit immediately.
  6545. @item n @var{file name}
  6546. Request @command{tar} to write the next volume on the file @var{file name}.
  6547. @item !
  6548. Request @command{tar} to run a subshell.
  6549. @item y
  6550. Request @command{tar} to begin writing the next volume.
  6551. @end table
  6552. (You should only type @samp{y} after you have changed the tape;
  6553. otherwise @command{tar} will write over the volume it just finished.)
  6554. If you want more elaborate behavior than this, give @command{tar} the
  6555. @value{op-info-script} option. The file @var{script-name} is expected
  6556. to be a program (or shell script) to be run instead of the normal
  6557. prompting procedure. If the program fails, @command{tar} exits;
  6558. otherwise, @command{tar} begins writing the next volume. The behavior
  6559. of the
  6560. @samp{n} response to the normal tape-change prompt is not available
  6561. if you use @value{op-info-script}.
  6562. The method @command{tar} uses to detect end of tape is not perfect, and
  6563. fails on some operating systems or on some devices. You can use the
  6564. @value{op-tape-length} option if @command{tar} can't detect the end of the
  6565. tape itself. This option selects @value{op-multi-volume} automatically.
  6566. The @var{size} argument should then be the usable size of the tape.
  6567. But for many devices, and floppy disks in particular, this option is
  6568. never required for real, as far as we know.
  6569. The volume number used by @command{tar} in its tape-change prompt
  6570. can be changed; if you give the @value{op-volno-file} option, then
  6571. @var{file-of-number} should be an unexisting file to be created, or else,
  6572. a file already containing a decimal number. That number will be used
  6573. as the volume number of the first volume written. When @command{tar} is
  6574. finished, it will rewrite the file with the now-current volume number.
  6575. (This does not change the volume number written on a tape label, as
  6576. per @value{ref-label}, it @emph{only} affects the number used in
  6577. the prompt.)
  6578. If you want @command{tar} to cycle through a series of tape drives, then
  6579. you can use the @samp{n} response to the tape-change prompt. This is
  6580. error prone, however, and doesn't work at all with @value{op-info-script}.
  6581. Therefore, if you give @command{tar} multiple @value{op-file} options, then
  6582. the specified files will be used, in sequence, as the successive volumes
  6583. of the archive. Only when the first one in the sequence needs to be
  6584. used again will @command{tar} prompt for a tape change (or run the info
  6585. script).
  6586. Multi-volume archives
  6587. With @value{op-multi-volume}, @command{tar} will not abort when it cannot
  6588. read or write any more data. Instead, it will ask you to prepare a new
  6589. volume. If the archive is on a magnetic tape, you should change tapes
  6590. now; if the archive is on a floppy disk, you should change disks, etc.
  6591. Each volume of a multi-volume archive is an independent @command{tar}
  6592. archive, complete in itself. For example, you can list or extract any
  6593. volume alone; just don't specify @value{op-multi-volume}. However, if one
  6594. file in the archive is split across volumes, the only way to extract
  6595. it successfully is with a multi-volume extract command @samp{--extract
  6596. --multi-volume} (@samp{-xM}) starting on or before the volume where
  6597. the file begins.
  6598. For example, let's presume someone has two tape drives on a system
  6599. named @file{/dev/tape0} and @file{/dev/tape1}. For having @acronym{GNU}
  6600. @command{tar} to switch to the second drive when it needs to write the
  6601. second tape, and then back to the first tape, etc., just do either of:
  6602. @smallexample
  6603. $ @kbd{tar --create --multi-volume --file=/dev/tape0 --file=/dev/tape1 @var{files}}
  6604. $ @kbd{tar cMff /dev/tape0 /dev/tape1 @var{files}}
  6605. @end smallexample
  6606. @menu
  6607. * Multi-Volume Archives:: Archives Longer than One Tape or Disk
  6608. * Tape Files:: Tape Files
  6609. @end menu
  6610. @node Multi-Volume Archives
  6611. @subsection Archives Longer than One Tape or Disk
  6612. @cindex Multi-volume archives
  6613. @UNREVISED
  6614. To create an archive that is larger than will fit on a single unit of
  6615. the media, use the @value{op-multi-volume} option in conjunction with
  6616. the @value{op-create} option (@pxref{create}). A
  6617. @dfn{multi-volume} archive can be manipulated like any other archive
  6618. (provided the @value{op-multi-volume} option is specified), but is
  6619. stored on more than one tape or disk.
  6620. When you specify @value{op-multi-volume}, @command{tar} does not report an
  6621. error when it comes to the end of an archive volume (when reading), or
  6622. the end of the media (when writing). Instead, it prompts you to load
  6623. a new storage volume. If the archive is on a magnetic tape, you
  6624. should change tapes when you see the prompt; if the archive is on a
  6625. floppy disk, you should change disks; etc.
  6626. You can read each individual volume of a multi-volume archive as if it
  6627. were an archive by itself. For example, to list the contents of one
  6628. volume, use @value{op-list}, without @value{op-multi-volume} specified.
  6629. To extract an archive member from one volume (assuming it is described
  6630. that volume), use @value{op-extract}, again without
  6631. @value{op-multi-volume}.
  6632. If an archive member is split across volumes (ie. its entry begins on
  6633. one volume of the media and ends on another), you need to specify
  6634. @value{op-multi-volume} to extract it successfully. In this case, you
  6635. should load the volume where the archive member starts, and use
  6636. @samp{tar --extract --multi-volume}---@command{tar} will prompt for later
  6637. volumes as it needs them. @xref{extracting archives}, for more
  6638. information about extracting archives.
  6639. @value{op-info-script} is like @value{op-multi-volume}, except that
  6640. @command{tar} does not prompt you directly to change media volumes when
  6641. a volume is full---instead, @command{tar} runs commands you have stored
  6642. in @var{script-name}. For example, this option can be used to eject
  6643. cassettes, or to broadcast messages such as @samp{Someone please come
  6644. change my tape} when performing unattended backups. When @var{script-name}
  6645. is done, @command{tar} will assume that the media has been changed.
  6646. Multi-volume archives can be modified like any other archive. To add
  6647. files to a multi-volume archive, you need to only mount the last
  6648. volume of the archive media (and new volumes, if needed). For all
  6649. other operations, you need to use the entire archive.
  6650. If a multi-volume archive was labeled using @value{op-label}
  6651. (@value{pxref-label}) when it was created, @command{tar} will not
  6652. automatically label volumes which are added later. To label subsequent
  6653. volumes, specify @value{op-label} again in conjunction with the
  6654. @value{op-append}, @value{op-update} or @value{op-concatenate} operation.
  6655. @cindex Labeling multi-volume archives
  6656. @FIXME{example}
  6657. @FIXME{There should be a sample program here, including an exit
  6658. before end. Is the exit status even checked in tar? :-(}
  6659. @table @kbd
  6660. @item --multi-volume
  6661. @itemx -M
  6662. Creates a multi-volume archive, when used in conjunction with
  6663. @value{op-create}. To perform any other operation on a multi-volume
  6664. archive, specify @value{op-multi-volume} in conjunction with that
  6665. operation.
  6666. @item --info-script=@var{program-file}
  6667. @itemx -F @var{program-file}
  6668. Creates a multi-volume archive via a script. Used in conjunction with
  6669. @value{op-create}.
  6670. @end table
  6671. Beware that there is @emph{no} real standard about the proper way, for
  6672. a @command{tar} archive, to span volume boundaries. If you have a
  6673. multi-volume created by some vendor's @command{tar}, there is almost
  6674. no chance you could read all the volumes with @acronym{GNU}
  6675. @command{tar}. The converse is also true: you may not expect
  6676. multi-volume archives created by @acronym{GNU} @command{tar} to be
  6677. fully recovered by vendor's @command{tar}. Since there is little
  6678. chance that, in mixed system configurations, some vendor's
  6679. @command{tar} will work on another vendor's machine, and there is a
  6680. great chance that @acronym{GNU} @command{tar} will work on most of
  6681. them, your best bet is to install @acronym{GNU} @command{tar} on all
  6682. machines between which you know exchange of files is possible.
  6683. @node Tape Files
  6684. @subsection Tape Files
  6685. @UNREVISED
  6686. To give the archive a name which will be recorded in it, use the
  6687. @value{op-label} option. This will write a special block identifying
  6688. @var{volume-label} as the name of the archive to the front of the archive
  6689. which will be displayed when the archive is listed with @value{op-list}.
  6690. If you are creating a multi-volume archive with
  6691. @value{op-multi-volume}@FIXME-pxref{Using Multiple Tapes}, then the
  6692. volume label will have
  6693. @samp{Volume @var{nnn}} appended to the name you give, where @var{nnn} is
  6694. the number of the volume of the archive. (If you use the @value{op-label}
  6695. option when reading an archive, it checks to make sure the label on the
  6696. tape matches the one you give. @value{xref-label}.
  6697. When @command{tar} writes an archive to tape, it creates a single
  6698. tape file. If multiple archives are written to the same tape, one
  6699. after the other, they each get written as separate tape files. When
  6700. extracting, it is necessary to position the tape at the right place
  6701. before running @command{tar}. To do this, use the @command{mt} command.
  6702. For more information on the @command{mt} command and on the organization
  6703. of tapes into a sequence of tape files, see @ref{mt}.
  6704. People seem to often do:
  6705. @example
  6706. @kbd{--label="@var{some-prefix} `date +@var{some-format}`"}
  6707. @end example
  6708. or such, for pushing a common date in all volumes or an archive set.
  6709. @node label
  6710. @section Including a Label in the Archive
  6711. @cindex Labeling an archive
  6712. @cindex Labels on the archive media
  6713. @UNREVISED
  6714. @table @kbd
  6715. @item -V @var{name}
  6716. @itemx --label=@var{name}
  6717. Create archive with volume name @var{name}.
  6718. @end table
  6719. This option causes @command{tar} to write out a @dfn{volume header} at
  6720. the beginning of the archive. If @value{op-multi-volume} is used, each
  6721. volume of the archive will have a volume header of @samp{@var{name}
  6722. Volume @var{n}}, where @var{n} is 1 for the first volume, 2 for the
  6723. next, and so on.
  6724. @FIXME{Should the arg to --label be a quoted string?? No.}
  6725. To avoid problems caused by misplaced paper labels on the archive
  6726. media, you can include a @dfn{label} entry---an archive member which
  6727. contains the name of the archive---in the archive itself. Use the
  6728. @value{op-label} option in conjunction with the @value{op-create} operation
  6729. to include a label entry in the archive as it is being created.
  6730. If you create an archive using both @value{op-label} and
  6731. @value{op-multi-volume}, each volume of the archive will have an
  6732. archive label of the form @samp{@var{archive-label} Volume @var{n}},
  6733. where @var{n} is 1 for the first volume, 2 for the next, and so on.
  6734. @FIXME-xref{Multi-Volume Archives, for information on creating multiple
  6735. volume archives.}
  6736. If you list or extract an archive using @value{op-label}, @command{tar} will
  6737. print an error if the archive label doesn't match the @var{archive-label}
  6738. specified, and will then not list nor extract the archive. In those cases,
  6739. @var{archive-label} argument is interpreted as a globbing-style pattern
  6740. which must match the actual magnetic volume label. @xref{exclude}, for
  6741. a precise description of how match is attempted@footnote{Previous versions
  6742. of @command{tar} used full regular expression matching, or before that, only
  6743. exact string matching, instead of wildcard matchers. We decided for the
  6744. sake of simplicity to use a uniform matching device through @command{tar}.}.
  6745. If the switch @value{op-multi-volume} is being used, the volume label
  6746. matcher will also suffix @var{archive-label} by @w{@samp{ Volume [1-9]*}}
  6747. if the initial match fails, before giving up. Since the volume numbering
  6748. is automatically added in labels at creation time, it sounded logical to
  6749. equally help the user taking care of it when the archive is being read.
  6750. The @value{op-label} was once called @samp{--volume}, but is not available
  6751. under that name anymore.
  6752. To find out an archive's label entry (or to find out if an archive has
  6753. a label at all), use @samp{tar --list --verbose}. @command{tar} will
  6754. print the label first, and then print archive member information, as
  6755. in the example below:
  6756. @example
  6757. $ @kbd{tar --verbose --list --file=iamanarchive}
  6758. V--------- 0 0 0 1992-03-07 12:01 iamalabel--Volume Header--
  6759. -rw-rw-rw- ringo user 40 1990-05-21 13:30 iamafilename
  6760. @end example
  6761. @table @kbd
  6762. @item --label=@var{archive-label}
  6763. @itemx -V @var{archive-label}
  6764. Includes an @dfn{archive-label} at the beginning of the archive when
  6765. the archive is being created, when used in conjunction with the
  6766. @value{op-create} option. Checks to make sure the archive label
  6767. matches the one specified (when used in conjunction with the
  6768. @value{op-extract} option.
  6769. @end table
  6770. To get a common information on all tapes of a series, use the
  6771. @value{op-label} option. For having this information different in each
  6772. series created through a single script used on a regular basis, just
  6773. manage to get some date string as part of the label. For example:
  6774. @example
  6775. $ @kbd{tar cfMV /dev/tape "Daily backup for `date +%Y-%m-%d`"}
  6776. $ @kbd{tar --create --file=/dev/tape --multi-volume \
  6777. --volume="Daily backup for `date +%Y-%m-%d`"}
  6778. @end example
  6779. Also note that each label has its own date and time, which corresponds
  6780. to when @acronym{GNU} @command{tar} initially attempted to write it,
  6781. often soon after the operator launches @command{tar} or types the
  6782. carriage return telling that the next tape is ready. Comparing date
  6783. labels does give an idea of tape throughput only if the delays for
  6784. rewinding tapes and the operator switching them were negligible, which
  6785. is usually not the case.
  6786. @FIXME{was --volume}
  6787. @node verify
  6788. @section Verifying Data as It is Stored
  6789. @cindex Verifying a write operation
  6790. @cindex Double-checking a write operation
  6791. @table @kbd
  6792. @item -W
  6793. @itemx --verify
  6794. Attempt to verify the archive after writing.
  6795. @end table
  6796. This option causes @command{tar} to verify the archive after writing it.
  6797. Each volume is checked after it is written, and any discrepancies
  6798. are recorded on the standard error output.
  6799. Verification requires that the archive be on a back-space-able medium.
  6800. This means pipes, some cartridge tape drives, and some other devices
  6801. cannot be verified.
  6802. You can insure the accuracy of an archive by comparing files in the
  6803. system with archive members. @command{tar} can compare an archive to the
  6804. file system as the archive is being written, to verify a write
  6805. operation, or can compare a previously written archive, to insure that
  6806. it is up to date.
  6807. To check for discrepancies in an archive immediately after it is
  6808. written, use the @value{op-verify} option in conjunction with
  6809. the @value{op-create} operation. When this option is
  6810. specified, @command{tar} checks archive members against their counterparts
  6811. in the file system, and reports discrepancies on the standard error.
  6812. To verify an archive, you must be able to read it from before the end
  6813. of the last written entry. This option is useful for detecting data
  6814. errors on some tapes. Archives written to pipes, some cartridge tape
  6815. drives, and some other devices cannot be verified.
  6816. One can explicitly compare an already made archive with the file system
  6817. by using the @value{op-compare} option, instead of using the more automatic
  6818. @value{op-verify} option. @value{xref-compare}.
  6819. Note that these two options have a slightly different intent. The
  6820. @value{op-compare} option how identical are the logical contents of some
  6821. archive with what is on your disks, while the @value{op-verify} option is
  6822. really for checking if the physical contents agree and if the recording
  6823. media itself is of dependable quality. So, for the @value{op-verify}
  6824. operation, @command{tar} tries to defeat all in-memory cache pertaining to
  6825. the archive, while it lets the speed optimization undisturbed for the
  6826. @value{op-compare} option. If you nevertheless use @value{op-compare} for
  6827. media verification, you may have to defeat the in-memory cache yourself,
  6828. maybe by opening and reclosing the door latch of your recording unit,
  6829. forcing some doubt in your operating system about the fact this is really
  6830. the same volume as the one just written or read.
  6831. The @value{op-verify} option would not be necessary if drivers were indeed
  6832. able to detect dependably all write failures. This sometimes require many
  6833. magnetic heads, some able to read after the writes occurred. One would
  6834. not say that drivers unable to detect all cases are necessarily flawed,
  6835. as long as programming is concerned.
  6836. The @value{op-verify} option will not work in conjunction with the
  6837. @value{op-multi-volume} option or the @value{op-append},
  6838. @value{op-update} and @value{op-delete} operations. @xref{Operations},
  6839. for more information on these operations.
  6840. Also, since @command{tar} normally strips leading @samp{/} from file
  6841. names (@pxref{absolute}), a command like @samp{tar --verify -cf
  6842. /tmp/foo.tar /etc} will work as desired only if the working directory is
  6843. @file{/}, as @command{tar} uses the archive's relative member names
  6844. (e.g., @file{etc/motd}) when verifying the archive.
  6845. @node Write Protection
  6846. @section Write Protection
  6847. Almost all tapes and diskettes, and in a few rare cases, even disks can
  6848. be @dfn{write protected}, to protect data on them from being changed.
  6849. Once an archive is written, you should write protect the media to prevent
  6850. the archive from being accidentally overwritten or deleted. (This will
  6851. protect the archive from being changed with a tape or floppy drive---it
  6852. will not protect it from magnet fields or other physical hazards).
  6853. The write protection device itself is usually an integral part of the
  6854. physical media, and can be a two position (write enabled/write
  6855. disabled) switch, a notch which can be popped out or covered, a ring
  6856. which can be removed from the center of a tape reel, or some other
  6857. changeable feature.
  6858. @node Free Software Needs Free Documentation
  6859. @appendix Free Software Needs Free Documentation
  6860. @include freemanuals.texi
  6861. @node Copying This Manual
  6862. @appendix Copying This Manual
  6863. @menu
  6864. * GNU Free Documentation License:: License for copying this manual
  6865. @end menu
  6866. @include fdl.texi
  6867. @node Index
  6868. @appendix Index
  6869. @printindex cp
  6870. @summarycontents
  6871. @contents
  6872. @bye
  6873. @c Local variables:
  6874. @c texinfo-column-for-description: 32
  6875. @c End: