tar.texi 346 KB

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