1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163 |
- \input texinfo
- comment %**start of header
- include version.texi
- value{VERSION}
- finalout
- c %**end of header
- include value.texi
- syncodeindex fn cp
- syncodeindex pg cp
- defindex op
- copying
- This manual is for command{tar} (version
- value{UPDATED}), which creates and extracts files
- from archives.
- Copyright
- quotation
- Permission is granted to copy, distribute and/or modify this document
- under the terms of the GNU Free Documentation License, Version 1.1 or
- any later version published by the Free Software Foundation; with the
- Invariant Sections being "GNU General Public License", with the
- Front-Cover Texts being ``A GNU Manual,'' and with the Back-Cover Texts
- as in (a) below. A copy of the license is included in the section
- entitled "GNU Free Documentation License".
- (a) The FSF's Back-Cover Text is: ``You are free to copy and modify
- this GNU Manual. Buying copies from GNU Press supports the FSF in
- developing GNU and promoting software freedom.''
- end copying
- direntry
- * Tar: (tar). Making tape (or disk) archives.
- dircategory Individual utilities
- GNUTAR{}.
- shorttitlepage command{tar}
- title
- subtitle value{VERSION},
- author John Gilmore, Jay Fenlason et al.
- vskip 0pt plus 1filll
- end titlepage
- node Top
- acronym{GNU} tar: an archiver tool
- cindex file archival
- end ifnottex
- c (However, getdate.texi's menu is interpolated by hand.)
- detailmenu
- --- The Detailed Node Listing ---
- Introduction
- * Book Contents:: What this Book Contains
- * Definitions:: Some Definitions
- * What tar Does:: What
- command{tar} Archives are Named
- * Current status:: Current development status of
- GNUTAR{} Authors
- * Reports:: Reporting bugs or suggestions
- Tutorial Introduction to
- command{tar} Operations and Options
- * frequent operations::
- * Two Frequent Options::
- * create:: How to Create Archives
- * list:: How to List Archives
- * extract:: How to Extract Members from an Archive
- * going further::
- Two Frequently Used Options
- * file tutorial::
- * verbose tutorial::
- * help tutorial::
- How to Create Archives
- * prepare for examples::
- * Creating the archive::
- * create verbose::
- * short create::
- * create dir::
- How to List Archives
- * list dir::
- How to Extract Members from an Archive
- * extracting archives::
- * extracting files::
- * extract dir::
- * failing commands::
- Invoking
- command{tar} Options
- * Operation Summary::
- * Option Summary::
- * Short Option Summary::
- GNUTAR{} Operations
- * Operations::
- * append::
- * update::
- * concatenate::
- * delete::
- * compare::
- How to Add Files to Existing Archives:
- option{--create}
- * Ignore Failed Read::
- Options Used by
- command{tar} Writes Files
- * Scarce:: Coping with Scarce Resources
- Options to Help Read Archives
- * read full records::
- * Ignore Zeros::
- Changing How
- command{tar} to Perform Full Dumps
- * Incremental Dumps:: Using
- file{Backup-specs}
- Choosing Files and Names for
- sc{est}, sc{gmt}, ...
- * Day of week items:: Monday and others.
- * Relative items in date strings:: next tuesday, 2 years ago.
- * Pure numbers in date strings:: 19931219, 1440.
- * Seconds since the Epoch:: 1078100502.
- * Authors of get_date:: Bellovin, Eggert, Salz, Berets, et al.
- Controlling the Archive Format
- * Portability:: Making
- acronym{GNU} Extensions to the Archive Format
- * cpio:: Comparison of command{cpio}
- Making
- acronym{POSIX} archives
- * Checksumming:: Checksumming Problems
- * Large or Negative Values:: Large files, negative time stamps, etc.
- Using Less Space through Compression
- * gzip:: Creating and Reading Compressed Archives
- * sparse:: Archiving Sparse Files
- Tapes and Other Archive Media
- * Device:: Device selection and switching
- * Remote Tape Server::
- * Common Problems and Solutions::
- * Blocking:: Blocking
- * Many:: Many archives on one tape
- * Using Multiple Tapes:: Using Multiple Tapes
- * label:: Including a Label in the Archive
- * verify::
- * Write Protection::
- Blocking
- * Format Variations:: Format Variations
- * Blocking Factor:: The Blocking Factor of an Archive
- Many Archives on One Tape
- * Tape Positioning:: Tape Positions and Tape Marks
- * mt:: The
- end detailmenu
- node Introduction
- GNUTAR{} creates
- and manipulates
- menu
- * Book Contents:: What this Book Contains
- * Definitions:: Some Definitions
- * What tar Does:: What
- command{tar} Archives are Named
- * Current status:: Current development status of
- GNUTAR{} Authors
- * Reports:: Reporting bugs or suggestions
- node Book Contents
- GNUTAR{}
- and its documentation, and where you should send bug reports
- or comments.
- The second chapter is a tutorial (
- command{tar}. It is
- meant to be self contained, not requiring any reading from subsequent
- chapters to make sense. It moves from topic to topic in a logical,
- progressive order, building on information already explained.
- Although the tutorial is paced and structured to allow beginners to
- learn how to use
- samp{create}, samp{extract}) as well as
- two frequently used options (samp{verbose}). The other
- chapters do not refer to the tutorial frequently; however, if a section
- discusses something which is a complex variant of a basic concept, there
- may be a cross reference to that basic concept. (The entire book,
- including the tutorial, assumes that the reader understands some basic
- concepts of using a Unix-type operating system;
- command{tar} options and option syntax.
- acronym{GNU} Project Manuals Concept [tm] more
- than the reality. should think about whether this makes sense to say
- here, or not.} The other chapters are meant to be used as a
- reference. Each chapter presents everything that needs to be said
- about a specific topic.
- One of the chapters (
- acronym{GNU} manuals, and is mostly self-contained.
- In addition, one section of this manual (
- command{tar} sources.
- In general, we give both long and short (abbreviated) option names
- at least once in each section where the relevant option is covered, so
- that novice readers will become familiar with both styles. (A few
- options have no short versions, and the relevant sections will
- indicate this.)
- section Some Definitions
- cindex tar archive
- The command{tar}
- archives. An
- command{tar}
- to
- cindex member
- cindex file name
- dfn{members}. Within this
- manual, we use the term
- command{ls},
- dfn{member} to refer only to the members of an archive. Similarly, a
- dfn{member name} is the name of an archive member within the
- archive.
- cindex unpacking
- The term
- dfn{extracting the
- archive}. The term
- dfn{list} the members in a given archive
- (this is often thought of as ``printing'' them to the standard output,
- or the command line), or
- command{tar}.
- section What
- cindex tar
- The command{tar}
- archives, as well as various other kinds of manipulation. For example,
- you can use
- command{tar} archives were used to store files conveniently on
- magnetic tape. The name
- code{t}ape command{tar} can
- direct its output to available devices, files, or other programs (using
- pipes).
- FIXME{the following table entries need a bit of work..}
- You can use
- table
- item Storage
- Often,
- acronym{GNU} Project distributes its software bundled into
- command{tar} archive. Even when the basic transfer
- mechanism can keep track of names, as FTP can, the nuisance of handling
- multiple files, directories, and multiple links makes
- command{tar} can be used to move archives in
- all dimensions, even time!)
- command{tar} is capable of preserving
- file information and directory structure,
- GNUTAR{} has special features that allow it to be
- used to make incremental and full dumps of all the files in a
- file system.
- end table
- section How
- command{tar} archives are given names ending with
- command{tar} to operate properly,
- but this manual follows that convention in order to accustom readers to
- it and to make examples more clear.
- cindex entry
- command{tar} archives as ``
- command{tar}, this causes no difficulty. However, in
- this manual, we consistently refer to ``archives'' and ``archive
- members'' to make learning to use
- node Current status
- GNUTAR{}
- itemize
- item Improve compatibility between command{tar}
- implementations.
- acronym{POSIX} archives.
- item Merge with the code{paxutils} project.
- table
- item Use of short option
- GNUTAR{} understood
- option{--old-archive}.
- option{--no-same-owner}. This is compatible with
- UNIX98
- option{-o} option retains its
- old semantics when it is used with one of archive-creation commands.
- Users are encouraged to use
- acronym{GNU} Automake
- up to and including 1.8.4 invoke tar with this option to produce
- distribution tarballs.
- GNUTAR{} will understand
- option{--no-same-owner}.
- option{-l}
- Earlier versions of option{-l} option as a
- synonym for
- GNUTAR{} will understand this option as a synonym for
- item Use of options option{--old-archive}
- These options are deprecated. Please use
- item Use of option
- option{--format=posix} instead.
- node Authors
- GNUTAR{} Authors
- acronym{GNU} enhancements were
- written by Jay Fenlason, then Joy Kendall, and the whole package has
- been further maintained by Thomas Bushnell, n/BSG, Fran
- command{tar} is a collective work, and owes much to
- all those people who reported problems, offered solutions and other
- insights, or shared their thoughts and suggestions. An impressive, yet
- partial list of those contributors can be found in the
- GNUTAR{} distribution.
- FIXME{History is more important, and surely more interesting, than
- actual names. Quoting names without history would be meaningless. FP}
- Jay Fenlason put together a draft of a
- GNUTAR{}.
- Fran
- FIXME{update version number as necessary; i'm being
- optimistic!}
- ref{Backups}.
- In July, 2003
- url{http:
- active development and maintenance work has started
- again. Currently
- acronym{POSIX} archives was added by Sergey Poznyakoff.
- section Reporting bugs or suggestions
- cindex reporting bugs
- If you find problems or have suggestions about this program or manual,
- please report them to
- FIXME{Be more specific, I'd
- like to make this node as detailed as 'Bug reporting' node in Emacs
- manual}.
- chapter Tutorial Introduction to
- command{tar}
- operations: option{--list}, and
- command{tar}, then you
- may not need to read this chapter. This chapter omits most complicated
- details about how
- menu
- * assumptions::
- * stylistic conventions::
- * basic tar options:: Basic
- end menu
- section Assumptions this Tutorial Makes
- This chapter is paced to allow beginners to learn about
- itemize
- item
- Before you start to work through this tutorial, you should understand
- what the terms ``archive'' and ``archive member'' mean
- (
- FIXME{and what
- else?}
- command{tar} commands in. When we show path names,
- we will assume that those paths are relative to your home directory.
- For example, my home directory path is
- file{practice}.
- xref{Media}, for complete information on using
- FIXME{this is a cop out. need to add some simple tape drive info.}
- node stylistic conventions
- samp{$} represents a typical shell prompt. It
- precedes lines you should type; to make this more clear, those lines are
- shown in
- code{this font}, or
- sometimes
- c When we have lines which are too long to be
- node basic tar options
- command{tar} Operations and Options
- command{tar} fall into one of two classes:
- operations, and options.
- Some arguments fall into a class called
- command{tar};
- you may
- dfn{operating modes}. You are in a particular operating mode when you
- have specified the operation which specifies it; there are eight
- operations in total, and thus there are eight operating modes.
- The other arguments fall into the class known as
- command{tar} at
- that time). Some options are used so frequently, and are so useful for
- helping you type commands more carefully that they are effectively
- ``required''. We will discuss them in this chapter.
- You can write most of the
- FIXME{make sure this is still the case,
- at the end}We will indicate those abbreviations appropriately to get
- you used to seeing them. (Note that the ``old style'' option forms
- exist in
- command{tar}. We present a full discussion of this way of writing
- options and operations appears in
- ref{Mnemonic Options}, and
- command{tar} commands easier.
- For example, instead of typing
- kbd{tar --create --verbose --file=afiles.tar apple angst aspic}
- noindent
- you can type
- kbd{tar -c -v -f afiles.tar apple angst aspic}
- noindent
- or even
- kbd{tar -cvf afiles.tar apple angst aspic}
- noindent
- For more information on option syntax, see
- emph{optional} ``options'' in certain
- general class statements. For example, we just talked about ``short and
- long forms of options and operations''. However, experienced
- command{tar} ``commands''.
- A dfn{command} is the entire command line of user input
- which tells
- command{tar} command''. When
- the word ``command'' is used specifically like this, a person is usually
- referring to the emph{operation}, not the whole line.
- Again, use context to figure out which of the meanings the speaker
- intends.
- section The Three Most Frequently Used Operations
- Here are the three most frequently used operations (both short and long
- forms), as well as a brief description of their meanings. The rest of
- this chapter will cover how to use these operations in detail. We will
- present the rest of the operations in the next chapter.
- option
- itemx -c
- Create a new
- item --list
- item --extract
- end table
- section Two Frequently Used Options
- To understand how to run
- command{tar}:
- option{--verbose}. (You are usually not
- command{tar}, but they can be very
- useful in making things more clear and helping you avoid errors.)
- end menu
- unnumberedsubsec The
- table
- item --file=
- itemx -f
- end table
- You can specify an argument for the
- command{tar}; this option determines the name of the archive file
- that
- command{tar} will use a
- default, usually some physical tape drive attached to your machine.
- If there is no tape drive attached, or the default is not meaningful,
- then
- smallexample
- tar: can't open /dev/rmt8 : No such device or address
- tar: can't open /dev/rsmt0 : I/O error
- noindent
- To avoid confusion, we recommend that you always specify an archive file
- name by using command{tar} commands.
- For more information on using the
- ref{file}.
- unnumberedsubsec The
- table
- item --verbose
- command{tar} is running.
- value{op-verbose} shows details about the results of running
- command{tar} as
- it writes files into the archive, you can use the
- option{--verbose} at all times; when you are more accustomed to
- option{--verbose} at times to help make something
- clear, and we will give many examples both using and not using
- option{--verbose} on the command line
- will show a full,
- FIXME{Describe the
- exact output format, e.g., how hard links are displayed.}
- Other times,
- option{--verbose} twice in a command to get a listing such as that
- in the former case. For example, instead of saying
- kbd{tar -cvf afiles.tar apple angst aspic}
- noindent
- above, you might say
- kbd{tar -cvvf afiles.tar apple angst aspic}
- noindent
- This works equally well using short or long forms of options. Using
- long forms, you would simply write out the mnemonic form of the option
- twice, like this:
- kbd{tar --create --verbose --verbose
- end smallexample
- w{
- node help tutorial
- option{--help} Option
- option
- option{--help} option to
- command{tar} available on your system.
- node create
- UNREVISED
- One of the basic operations of value{op-create}, which
- you use to create a
- option{--create} first because, in order to learn about the other
- operations, you will find it useful to have an archive available to
- practice on.
- To make this easier, in this section you will first create a directory
- containing three files. Then, we will show you how to create an
- file{blues}, file{jazz}. The archive is called
- option{--create}
- in
- command{tar} works.
- end menu
- subsection Preparing a Practice Directory for Examples
- To follow along with this and future examples, create a new directory
- called file{blues},
- file{jazz}. The files can contain any information you like:
- ideally, they should contain information which relates to their names,
- and be of different lengths. Our examples assume that
- command{cd} to the directory named file{practice}
- is now your emph{Please note}: Although
- the full path name of this directory is
- var{homedir}/practice}, in our examples we will refer to
- this directory as var{homedir} is presumed.
- In general, you should check that the files to be archived exist where
- you think they do (in the working directory) by running
- samp{collection.tar}), or that you don't care about its contents.
- Whenever you use command{tar} will erase the current
- contents of the file named by command{tar}
- will not tell you if you are about to overwrite an archive unless you
- specify an option which does this (
- value{op-append}; see
- node Creating the archive
- file{blues}, file{jazz} into an
- archive named
- smallexample
- $
- end smallexample
- The order of the arguments is not very important,
- smallexample
- $
- end smallexample
- command{tar}, to avoid errors).
- Note that the part of the command which says,
- option{--file=collection.tar}} is considered to be
- kbd{collection.tar}, then that string would become the name of the
- archive file you create.
- The order of the options becomes more important when you begin to use
- short forms. With short forms, if you type commands in the wrong order
- (even if you type them correctly in all other ways), you may end up with
- results you don't expect. For this reason, it is a good idea to get
- into the habit of typing options in the order that makes inherent sense.
- option{--create}
- is the operation which creates the new archive
- (option{--file} is the option which lets
- you give it the name you chose. The files, file{folk},
- and file{collection.tar}
- (they are option{--create} operation).
- emph{archive members}, not files.
- (
- emph{must} specify which files you
- want placed in the archive. If you do not specify any archive
- members,
- command{ls}), you will
- find the archive file listed as well as the files you saw previously:
- end smallexample
- samp{collection.tar} did not destroy the copies of
- the files in the directory.
- Keep in mind that if you don't indicate an operation,
- command{tar}
- will complain. You must have write access to the working directory,
- or else you will not be able to create an archive in that directory.
- value{op-create} to add files to
- an existing archive; it will delete the archive and write a new one.
- Use xref{append}.
- subsection Running option{--verbose}
- If you include the
- command{tar} will list the files it is acting on as it is working. In
- verbose mode, the
- smallexample
- $
- end smallexample
- This example is just like the example we showed which did not use
- command{tar} generated the remaining lines
- end iftex
- end ifinfo
- In the rest of the examples in this chapter, we will frequently use
- command{tar} responses that
- you would otherwise not see, and which are important for you to
- understand.
- subsection Short Forms with
- value{op-create} operation is one of the most
- basic uses of
- ref{Styles}; for now, here is what the
- previous example (including the
- smallexample
- $
- end smallexample
- FIXME{i don't like how this is worded:} One difference between using
- short and long option forms is that, although the exact placement of
- arguments following options is no more specific when using short forms,
- it is easier to become confused and make a mistake when using short
- forms. For example, suppose you attempted the above example in the
- following way:
- kbd{tar -cfv collection.tar blues folk jazz}
- noindent
- In this case, file{v},
- containing the files file{folk}, and
- samp{v} is the closest ``file name'' to the
- command{tar} will try
- to add a file called file{v} archive file;
- if the file command{tar} will
- report an error indicating that this file does not exist. If the file
- command{tar} will add this file to the archive.
- Because the command{tar} will not
- run under
- smallexample
- $
- end smallexample
- smallexample
- $
- end smallexample
- option{-f}, but doing that could sacrifice
- valuable data.
- For this reason, we recommend that you pay very careful attention to
- the order of options and placement of file and archive names,
- especially when using short option forms. Not having the option name
- written out mnemonically can affect how well you remember which option
- does what, and therefore where different names have to be placed.
- (Placing options in an unusual order can also cause
- env{POSIXLY_CORRECT}.)
- subsection Archiving Directories
- cindex Directories, Archiving
- You can archive a directory by specifying its directory name as a
- file name argument to
- smallexample
- $
- end smallexample
- file{practice},
- i.e., your home directory. Once in the superior directory, you can
- specify the subdirectory,
- file{practice} in the new archive file
- smallexample
- $
- end smallexample
- command{tar} should output:
- end smallexample
- Note that the archive thus created is not in the subdirectory
- command{tar} was invoked. Before trying to archive a
- directory from its superior directory, you should make sure you have
- write access to the superior directory itself, not only the directory
- you are trying archive with
- command{tar} from the root directory;
- file{collection.tar}, the original archive file, has itself
- been archived.
- file{music.tar} is
- extracted, the archive file
- command{tar} a command such as
- kbd{tar --create --file=foo.tar .}
- noindent
- samp{tar: ./foo.tar is the archive; not
- dumped}. This happens because
- file{foo.tar} in the current directory before putting any files into
- it. Then, when
- file{.} to the archive, it notices that the file
- file{foo.tar}, and skips
- it. (It makes no sense to put an archive into itself.)
- emph{Please
- note:} Other versions of
- GNUTAR{}.)
-
- node list
- value{op-list} operation
- to get the member names as they currently appear in the archive, as well
- as various attributes of the files at the time they were archived. For
- example, you can examine the archive
- smallexample
- $
- end smallexample
- command{tar} would then be:
- end smallexample
- noindent
- The archive
- smallexample
- ./birds
- baboon
- ./box
- noindent
- Be sure to use a value{op-create}
- to specify the name of the archive.
- If you use the option{--list}, then
- w{
- value{op-verbose} mode, the example above would look
- like:
- kbd{tar --list --verbose --file=collection.tar folk}
- -rw-rw-rw- myself user 62 1990-05-23 10:55 folk
- cindex listing member and file names
- kbd{tar --list
- --verbose} does not necessarily match that produced by
- GNUTAR{}, unless told explicitly not to do so, removes some directory
- prefixes from file names before storing them in the archive
- (
- GNUTAR{} shows
- dfn{member names} when listing it. Consider this
- example:
- group
- $
- kbd{tar tf archive}
- etc/mail/
- etc/mail/sendmail.cf
- etc/mail/aliases
- end smallexample
- option{--show-stored-names} described
- This default behavior can sometimes be inconvenient. You can force
- option{--show-stored-names} option.
- option
- emph{file}) names when creating the archive.
- cindex File name arguments, using
- cindex
- samp{list}. In this case,
- w{
- file{apple}.
- command{tar} preserves paths, file names must be specified as they appear
- in the archive (ie., relative to the directory from which the archive
- was created). Therefore, it is essential when specifying member names
- to
- w{
- samp{tar: birds: Not found in archive}, because there is
- no member named file{./birds}. While the
- names file{./birds} name the same file,
- xref{absolute}.
- However, kbd{tar --list --file=collection.tar folk}} would respond
- with file{folk} is in the archive file
- option{--list} with no file
- names as arguments,
- menu
- * list dir::
- node list dir
- value{op-list}. To find out file attributes, include the
- file{practice}, in
- the archive file
- smallexample
- $
- end smallexample
- smallexample
- drwxrwxrwx myself user 0 1990-05-31 21:49 practice/
- -rw-rw-rw- myself user 42 1990-05-21 13:29 practice/blues
- -rw-rw-rw- myself user 62 1990-05-23 10:55 practice/folk
- -rw-rw-rw- myself user 40 1990-05-21 13:30 practice/jazz
- -rw-rw-rw- myself user 10240 1990-05-31 21:49 practice/collection.tar
- command{tar} acts on
- all the files (including sub-directories) in that directory.
- section How to Extract Members from an Archive
- cindex Extraction
- cindex Resurrecting files from an archive
- Creating an archive is only half the job---there is no point in storing
- files in an archive if you can't retrieve them. The act of retrieving
- members from an archive so they can be used and manipulated as
- unarchived files again is called
- value{op-extract} operation. As with
- value{op-file}.
- Extracting an archive does not modify the archive in any way; you can
- extract it multiple times if you want or need to.
- Using
- value{op-create} and
- menu
- * extracting archives::
- * extracting files::
- * extract dir::
- * extracting untrusted archives::
- * failing commands::
- node extracting archives
- smallexample
- $
- end smallexample
- smallexample
- -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
- -rw-rw-rw- me user 21 1996-09-23 16:44 blues
- -rw-rw-rw- me user 20 1996-09-23 16:44 folk
- node extracting files
- value{op-list}. If you had mistakenly deleted
- one of the files you had placed in the archive
- file{blues}), you can extract it from the archive without
- changing the archive's structure. Its contents will be identical to the
- original file
- file{practice} directory, and list the
- files in the directory. Now, delete the file,
- file{blues} from the archive file
- smallexample
- $
- end smallexample
- file{blues} has been restored, with its original permissions, data modification
- times, and owner.
- code{umask} is compatible with original permissions.}
- (These parameters will be identical to those which
- the file had when you originally placed it in the archive; any changes
- you may have made before deleting the file from the file system,
- however, will
- samp{collection.tar}, is the same as it was before you
- extracted command{tar} with
- FIXME{we hope this will change:}Remember that as with other operations,
- specifying the exact member name is important. kbd{tar --extract
- --file=bfiles.tar birds}} will fail, because there is no member named
- file{./birds}, you must
- specify kbd{tar --extract --file=bfiles.tar ./birds}}. To find the
- exact member names of the members of an archive, use
- pxref{list}).
- You can extract a file to standard output by combining the above options
- with the pxref{Writing to Standard
- Output}).
- If you give the value{op-extract} will
- print the names of the archive members as it extracts them.
- subsection Extracting Files that are Directories
- Extracting directories which are members of an archive is similar to
- extracting other files. The main difference to be aware of is that if
- the extracted directory has the same name as any directory already in
- the working directory, then files in the extracted directory will be
- placed into the directory of the same name. Likewise, if there are
- files in the pre-existing directory with the same names as the members
- which you extract, the files from the extracted archive will replace
- the files already in the working directory (and possible
- subdirectories). This will happen regardless of whether or not the
- files in the working directory were more recent than those extracted
- (there exist, however, special options that alter this behavior
- command{tar} will create the directory.
- We can demonstrate how to use
- file{practice} directory if you
- weren't there, and remove the files file{jazz}. Then,
- go back to the parent directory and extract the archive
- file{music.tar}. To extract only the files you deleted, use the
- following command:
- kbd{tar -xvf music.tar practice/folk practice/jazz}
- practice/folk
- practice/jazz
- noindent
- If you were to specify two command{tar}
- would have displayed more detail about the extracted files, as shown
- in the example below:
- kbd{tar -xvvf music.tar practice/folk practice/jazz}
- -rw-rw-rw- me user 28 1996-10-18 16:31 practice/jazz
- -rw-rw-rw- me user 20 1996-09-23 16:44 practice/folk
- noindent
- Because you created the directory with
- file{practice}
- directory as file{practice} as part
- of the file names when you extract those files from the archive.
- node extracting untrusted archives
- file{untrusted.tar} came from somewhere else on the
- Internet, and you don't necessarily trust its contents, you can
- extract it as follows:
- kbd{mkdir newdir}
- $
- kbd{tar -xvf ../untrusted.tar}
- value{op-list} option, possibly combined
- with
- node failing commands
- smallexample
- $
- end smallexample
- smallexample
- tar: folk: Not found in archive
- tar: jazz: Not found in archive
- $
- noindent
- This is because these files were not originally
- file{..}, where the archive is located; they were in the
- smallexample
- $
- end smallexample
- noindent
- Likewise, if you try to use this command,
- kbd{tar -tvf music.tar folk jazz}
- noindent
- you would get a similar response. Members with those names are not in the
- archive. You must use the correct member names in order to extract the
- files from the archive.
- If you have forgotten the correct names of the files in the archive,
- use kbd{tar --list --verbose}} to list them correctly.
- node going further
- FIXME{need to write up a node here about the things that are going to
- be in the rest of the manual.}
- chapter Invoking
- UNREVISED
- This chapter is about how one invokes the
- pxref{Synopsis}). There are
- numerous options, and many styles for writing them. One mandatory
- option specifies the operation
- pxref{Operation Summary}), other options are meant to detail how
- this operation should be performed (
- pxref{Styles}). On the other hand, operations and options
- are fully described elsewhere, in other chapters. Here, you will find
- only synthetic descriptions for operations and options, together with
- pointers to other parts of the
- command{tar} or else, they globally alter the amount of feedback the user
- receives about what is going on. These are the
- value{op-version} (value{op-verbose} (
- value{op-interactive} options (
- menu
- * Synopsis::
- * using tar options::
- * Styles::
- * All Options::
- * help::
- * verbose::
- * interactive::
- node Synopsis
- command{tar}
- The
- smallexample
- var{option}var{name}]
- kbd{tar dots{} [dots{} [dots{} [dots{}}
- command{tar} to store files in an archive, to extract them from
- an archive, and to do other types of archive manipulation. The primary
- argument to dfn{operation}, specifies
- which action to take. The other arguments to
- dfn{options}, which change the way
- command{tar} is to act on.
- You can actually type in arguments in any order, even if in this manual
- the options always precede the other arguments, to make examples easier
- to understand. Further, the option stating the main operation mode
- (the
- var{name} in the synopsis above is interpreted as an archive member
- name when the main command is one of value{op-delete},
- value{op-list} or
- value{op-list}. For
- value{op-create}, these
- command{tar} command.
- command{tar} will make all file names relative
- (by removing leading slashes when archiving or restoring files),
- unless you specify otherwise (using the
- value{xref-absolute-names}, for more information about
- command{tar} acts recursively on all the files and directories
- beneath that directory. For example, the name
- command{tar}.
- The distinction between file names and archive member names is especially
- important when shell globbing is used, and sometimes a source of confusion
- for newcomers.
- command{tar} itself may glob on archive members, so when
- needed, you must ensure that wildcard characters reach
- samp{*}
- or
- var{name}s are often specified on the command line, they
- can also be read from a text file in the file system, using the
- value{op-append},
- value{op-concatenate} will do nothing, while
- command{tar}
- execution. The other operations of value{op-list},
- value{op-compare}, and
- cindex exit status
- GNUTAR{} may fail for
- many reasons. Some reasons correspond to bad usage, that is, when the
- command{tar} has completed all its work. Some
- errors are such that it would not meaningful, or at least risky, to
- continue processing:
- code{stderr}, after a line stating the nature of
- the error.
- value{op-compare} option, zero means that everything went well, besides
- maybe innocuous warnings. Nonzero means that something went wrong.
- Right now, as of today, ``nonzero'' is almost always 2, except for
- remote operations, where it may be 128.
- section Using
- GNUTAR{} has a total of eight operating modes which
- allow you to perform a variety of tasks. You are required to choose
- one operating mode each time you employ the
- command{tar} command (two lists of four operations each may be found
- at ref{Operations}). Depending on
- circumstances, you may also wish to customize how the chosen operating
- mode behaves. For example, you may wish to change the way the output
- looks, or the format of the files that you wish to archive may require
- you to do something special in order to make the archive look right.
- You can customize and control
- command{tar} with one or more options (such as
- dfn{options} are
- arguments to
- pxref{All Options}.)
- anchor{TAR_OPTIONS}
- The
- code{TAR_OPTIONS} is command{tar} behaves as
- if the two options option{--unlink-first} had been
- specified before any explicit options. Option specifications are
- separated by whitespace. A backslash escapes the next character, so it
- can be used to specify an option containing whitespace or a backslash.
- Note that
- option{-T} and
- var{name}s,
- while the second does not require an argument and is another way to
- write
- command{tar}, and three different styles for writing both: long (mnemonic)
- form, short form, and old style. These styles are discussed below.
- Both the options and the operations can be written in any of these three
- styles.
- node Styles
- command{tar}. The different styles were developed at
- different times during the history of
- value{op-file} takes
- the name of an archive file as an argument. If you do not supply an
- archive file name,
- emph{place} the arguments generally depends on
- which style of options you choose. We will detail specific information
- relevant to each option style in the sections on the different option
- styles, below. The differences are subtle, yet can often be very
- important; incorrect option placement can cause you to overwrite a
- number of important files. We urge you to note these differences, and
- only use the option style(s) which makes the most sense to you until you
- feel comfortable with the others.
- Some options
- value{op-backup} and
- menu
- * Mnemonic Options:: Mnemonic Option Style
- * Short Options:: Short Option Style
- * Old Options:: Old Option Style
- * Mixing:: Mixing Option Styles
- node Mnemonic Options
- FIXME{have to decide whether or not to replace other occurrences of
- "mnemonic" with "long", or *ugh* vice versa.}
- Each option has at least one long (or mnemonic) name starting with two
- dashes in a row, e.g.,
- option{--compare} and
- option{--cre} can be used in place of
- samp{cre}. (One way to find
- this out is by trying it and seeing what happens; if a particular
- abbreviation could represent more than one option,
- samp{tar --help}
- to see a list of options. Be aware that if you run
- command{tar} will perform the command as ordered.)
- Mnemonic options are meant to be obvious and easy to remember, and their
- meanings are generally easier to discern than those of their
- corresponding short options (see below). For example:
- kbd{tar --create --verbose --blocking-factor=20 --file=/dev/rmt0}
- noindent
- gives a fairly good set of hints about what the command does, even
- for those not fully acquainted with
- option{--file} option (which
- tells the name of the
- file{archive.tar} as argument by using any of the following notations:
- option{--file archive.tar}.
- In contrast, optional arguments must always be introduced using
- an equal sign. For example, the
- option{--backup=
- node Short Options
- option{-t}
- (which is equivalent to
- w{
- option{-farchive.tar} instead of using
- option{--file=
- w{var{archive-name}}} denote the option which indicates a
- specific archive, here named
- emph{without any intervening
- white space characters}.
- Short options' letters may be clumped together, but you are not
- required to do this (as compared to old options; see below). When
- short options are clumped as a set, use one (single) dash for them
- all, e.g., samp{
- footnote{Clustering many
- options, the last of which has an argument, is a rather opaque way to
- write options. Some wonder if code{getopt} should not
- even be made helpful enough for considering such usages as invalid.}.
- When the options are separated, the argument for each option which requires
- an argument directly follows that option, as is usual for Unix programs.
- For example:
- kbd{tar -c -v -b 20 -f /dev/rmt0}
- node Old Options
- UNREVISED
- Like short options, old options are single letters. However, old options
- must be written together as a single clumped set, without spaces separating
- them or dashes preceding them
- command{tar} program name and some white space; old options cannot appear
- anywhere else. The letter of an old option is exactly the same letter as
- the corresponding short option. For example, the old option
- option{-t}, and consequently, the same as the
- mnemonic option w{
- option{-v} in addition to the operation
- FIXME{bob suggests having an uglier example. :-) }
- When options that need arguments are given together with the command,
- all the associated arguments follow, in the same order as the options.
- Thus, the example given previously could also be written in the old
- style as follows:
- kbd{tar cvbf 20 /dev/rmt0}
- noindent
- Here, option{-b} and
- option{-f}.
- On the other hand, this old style syntax makes it difficult to match
- option letters with their corresponding arguments, and is often
- confusing. In the command samp{tar cvbf 20 /dev/rmt0}}, for example,
- option{-b},
- option{-f}, and
- w{
- command{tar} options can surprise even experienced
- users. For example, the two commands:
- kbd{tar cfz archive.tar.gz file}
- end smallexample
- file{archive.tar.gz} as
- the value for option samp{z}. The
- second example, however, uses
- samp{f} --- probably not what was intended.
- Old options are kept for compatibility with old versions of
- smallexample
- kbd{tar -cf archive.tar.gz -z file}
- end smallexample
- cindex option syntax, traditional
- As far as we know, all acronym{GNU} and
- non-GNUTAR{}
- supports them not only for historical reasons, but also because many
- people are used to them. For compatibility with Unix
- samp{-}. Thus,
- w{
- value{op-create} command to create an archive.
- subsection Mixing Option Styles
- All three styles may be intermixed in a single
- footnote{Before
- command{tar} command. However,
- old style options must be introduced as the first arguments only,
- following the rule for old options (old options must appear directly
- after the
- smallexample
- kbd{tar --create -f archive.tar}
- kbd{tar --file=archive.tar --create}
- kbd{tar -c --file=archive.tar}
- kbd{tar -c -farchive.tar}
- kbd{tar -cfarchive.tar}
- kbd{tar -f archive.tar -c}
- kbd{tar -farchive.tar -c}
- kbd{tar c -f archive.tar}
- kbd{tar cf archive.tar}
- kbd{tar f archive.tar -c}
- end smallexample
- On the other hand, the following commands are
- smallexample
- kbd{tar -fc archive.tar}
- kbd{tar -farchive.tarc}
- end smallexample
- command{tar} archive would be a file named
- samp{c}, samp{archive.tarc},
- respectively. The first two examples also specify a single non-option,
- samp{archive.tar}. The last
- example contains only old style option letters (repeating option
- samp{.},
- samp{i}), with no argument value.
- node All Options
- command{tar} Options
- The coming manual sections contain an alphabetical listing of all
- command{tar} commands in scripts.
- end menu
- subsection Operations
- option
- itemx -r
- Appends files to the end of the archive.
- item --catenate
- option{--concatenate}.
- item --compare
- xref{compare}.
- itemx -A
- Appends other
- xref{concatenate}.
- itemx -c
- Creates a new xref{create}.
- xref{delete}.
- itemx -d
- Same xref{compare}.
- itemx -x
- Extracts members from the archive into the file system.
- item --get
- option{--extract}.
- item --list
- xref{list}.
- itemx -u
- option{--compare} and
- value{op-compare} does a lot more than
- xref{update}.
- node Option Summary
- command{tar} Options
- option
- itemx -P
- Normally when creating an archive,
- samp{/} from member names. This option disables that behavior.
- item --after-date
- (See pxref{after})
- xref{controlling pattern-matching with exclude}.
- itemx --atime-preserve=replace
- value{op-atime-preserve-replace} remembers the access time of a file
- before reading it, and then restores the access time afterwards. This
- may cause problems if other programs are reading the file at the same
- time, as the times of their accesses will be lost. On most platforms
- restoring the access time also requires
- value{op-atime-preserve-system} avoids changing time stamps on files,
- without interfering with time stamp updates
- caused by other programs, so it works better with incremental backups.
- However, it requires a special
- command{tar} knows that it does not work, and if you use
- command{tar} complains and
- exits right away. But other times
- option{--atime-preserve} with no operand defaults to
- value{op-atime-preserve-system} improves.
- If your operating system does not support
- command{mount} command. For example,
- you can mount the file system read-only, or access the file system via
- a read-only loopback mount, or use the
- item --backup=
- command{tar} will
- back them up using simple or numbered backups, depending upon
- xref{backup}.
- itemx -R
- With this option present,
- FIXME-xref{}
- var{blocking}
- var{blocking}
- Sets the blocking factor var{blocking} x 512 bytes per
- record.
- item --bzip2
- command{tar} to read or write archives through
- xref{gzip}.
- command{tar} to print periodic checkpoint messages as it
- reads through the archive. Its intended for when you want a visual
- indication that
- option{--verbose} output.
- item --check-links
- command{tar} will check the number of links
- dumped for each processed file. If this number does not match the
- total number of hard links for the file, a warning message will be
- output.
- Future versions will take
- option{--check-links}. However, current release still retains the old
- semantics for
- xref{Current status}, for more information.
- itemx --uncompress
- command{tar} will use the
- FIXME-xref{}
- option{--interactive}.)
- item --dereference
- command{tar} archive,
- FIXME-xref{}
- var{dir}
- var{dir}
- When this option is specified,
- var{dir} before performing any operations. When this option is used
- during archive creation, it is order sensitive.
- item --exclude=
- command{tar} will skip files that match
- xref{exclude}.
- var{file}
- var{file}
- Similar to command{tar} will use the list of
- patterns in the file xref{exclude}.
- xref{exclude}.
- var{archive}
- var{archive}
- var{archive} as the
- command{tar}'s compilation dependent
- default.
- item --files-from=
- itemx -T
- command{tar} will use the contents of
- xref{files}.
- command{tar} to interpret the filename given to
- xref{local and remote archives}.
- var{format}
- Selects output archive format.
- table
- item v7
- Creates an archive that is compatible with Unix V7
- item oldgnu
- Creates an archive that is compatible with GNU
- item gnu
- Creates archive in GNU tar 1.13 format. Basically it is the same as
- item ustar
- Creates a
- item posix
- Creates a
- end table
- item --group=
- command{tar} archive will have a group id of
- var{group} is first decoded
- as a group symbolic name, but if this interpretation fails, it has to be
- a decimal numeric group ID.
- value{op-owner} option.
- itemx --gunzip
- itemx -z
- This option tells
- command{gzip}, allowing
- xref{gzip}.
- command{tar} will print out a short message summarizing the operations and
- options to xref{help}.
- xref{controlling pattern-matching
- with exclude}.
- xref{Writing to an External Program}.
- xref{Reading}.
- itemx -i
- With this option,
- xref{Reading}.
- itemx -G
- Used to inform
- acronym{GNU}-format incremental backup archive. It is intended
- primarily for backwards compatibility only.
- item --index-file=
- var{file} instead of to standard output.
- var{script-file}
- var{script-file}
- var{script-file}
- When var{script-file} is run
- at the end of each tape. If
- command{tar} fails immediately.
- var{script-file}.
- itemx --confirmation
- command{tar} should ask the user for confirmation before
- performing potentially destructive options, such as overwriting files.
- item --keep-newer-files
- Do not replace existing files that are newer than their archive copies
- when extracting files from an archive.
- itemx -k
- Do not overwrite existing files when extracting files from an archive.
- item --label=
- itemx -V
- command{tar} to write
- command{tar} will only operate on archives that have a label matching
- the pattern specified in xref{Tape Files}.
- var{snapshot-file}
- var{snapshot-file}
- During a
- command{tar} creates is a new
- var{snapshot-file} to determine which files to backup.
- With other operations, informs
- FIXME{incremental and listed-incremental}.
- var{permissions}
- When adding files to an archive,
- var{permissions} for the archive members, rather than the permissions
- from the files. The program command{tar}
- option share the same syntax for what
- xref{File permissions, Permissions, File permissions, fileutils,
- var{permissions} might be plainly specified as an octal number.
- However, by using generic symbolic modifications to mode bits, this allows
- more flexibility. For example, the value
- item --multi-volume
- command{tar} that it should create or otherwise operate on a
- multi-volume xref{Using Multiple Tapes}.
- item -n
- command{tar} determines automatically whether
- the archive can be seeked or not. This option is intended for use
- in cases when such recognition fails.
- var{date}
- var{date}
- command{tar} will only add files that have changed
- since var{date} begins with samp{.}, it
- is taken to be the name of a file whose data modification time specifies
- the date.
- item --newer-mtime=
- option{--newer}, but add only files whose
- contents have changed (as opposed to just
- item --no-anchored
- An exclude pattern can match any subsequence of the name's components.
- item --no-ignore-case
- Use case-sensitive matching when excluding files.
- item --no-ignore-command-error
- Print warnings about subprocesses terminated with a non-zero exit
- code.
- item --no-recursion
- With this option,
- xref{recurse}.
- itemx -o
- When extracting an archive, do not attempt to preserve the owner
- specified in the
- item --no-same-permissions
- When extracting an archive, subtract the user's umask from files from
- the permissions specified in the archive. This is the default behavior
- for ordinary users.
- xref{controlling pattern-matching with exclude}.
- samp{/} when excluding files.
- item --null
- When option{--files-from} option, this option
- instructs option{NUL}, so
- xref{nul}.
- command{tar} that it should use numeric user
- and group IDs when creating a
- xref{Attributes}.
- option{--no-same-owner}, i.e. it prevents
- option{-o} is a synonym for
- GNUTAR{}, and will be
- removed in the future releases.
- item --occurrence[=
- option{--delete}, option{--extract} or
- option{-T} option.
- This option instructs var{number}th
- occurrence of each named file.
- smallexample
- tar -x -f archive.tar --occurrence filename
- noindent
- will extract the first occurrence of file{archive.tar}
- and will terminate without scanning to the end of the archive.
- option{--format=v7}.
- itemx -l
- Used when creating an archive. Prevents
- GNUTAR{} understood
- option{--one-file-system}. Although such usage is still
- allowed in the present version, it is
- GNUTAR{} will use
- option{--check-links}.
- item --overwrite
- Overwrite existing files and directory metadata when extracting files
- from an archive.
- item --overwrite-dir
- Overwrite the metadata of existing directories when extracting files
- from an archive.
- item --owner=
- command{tar} should use
- var{user} is first decoded as a user symbolic name, but if
- this interpretation fails, it has to be a decimal numeric user ID.
- samp{0} usually means
- samp{0} as the value to offer in
- their distributions for the owner of files, because the
- item --pax-option=
- acronym{POSIX.1-2001} archives
- (command{tar} handles the
- extended header keywords.
- table
- item delete=
- command{tar} to omit from extended header records
- that it produces any keywords matching the string
- var{pattern} in the extended
- header records. In both cases, matching is performed using the pattern
- matching notation described in FIXME-xref{see
- man 7 glob}. For example:
- end smallexample
- would suppress security-related information.
- var{string}
- This keyword allows user control over the name that is written into the
- ustar header blocks for the extended headers. The name is obtained
- from
- multitable
- headitem Meta-character
- item %d
- command{dirname} utility on the translated pathname.
- tab The filename of the file, equivalent to the result
- of the
- item %p command{tar} process.
- tab A
- end multitable
- Any other var{string} produce undefined
- results.
- If no option command{tar}
- will use the following default value:
- end smallexample
- var{string}
- This keyword allows user control over the name that is written into
- the ustar header blocks for global extended header records. The name
- shall will be obtained from the contents of
- multitable
- headitem Meta-character
- item %n
- item %p command{tar} process.
- tab A
- end multitable
- Any other
- samp{globexthdr.name=string} is specified,
- smallexample
- $TMPDIR/GlobalHead.%p.%n
- noindent
- where var{TMPDIR}
- environment variable. If command{tar}
- uses
- item var{value}
- When used with one of archive-creation commands, these keyword/value pairs
- will be included at the beginning of the archive in a global extended
- header record. When used with one of archive-reading commands,
- item var{value}
- When used with one of archive-creation commands, these keyword/value pairs
- will be included as records at the beginning of an extended header for
- each file. This is effectively equivalent to var{value}
- form except that it creates no global extended header records.
- When used with one of archive-reading commands,
- smallexample
- tar --format=posix --create \
- --file archive --pax-option gname:=user .
- end table
- itemx --old-archive
- Synonym for
- item --posix
- Same as
- item --preserve
- Synonymous with specifying both
- option{--same-order}.
- item --preserve-order
- (See pxref{Reading}.)
- itemx --same-permissions
- command{tar} is extracting an archive, it normally subtracts the
- users' umask from the permissions specified in the archive and uses
- that number as the permissions to create the destination file.
- Specifying this option instructs
- xref{Setting Access Permissions}.
- itemx -B
- Specifies that
- xref{Reading}.
- var{size}
- Instructs var{size} bytes per record when accessing the
- archive.
- item --recursion
- With this option,
- xref{recurse}.
- xref{Recursive Unlink}.
- command{tar} to remove the source file from the file system after
- appending it to an archive.
- item --restrict
- Disable use of some potentially harmful
- pxref{Using Multiple Tapes}).
- var{cmd}
- Notifies var{cmd} instead of
- the default pxref{Remote Tape Server}).
- var{cmd}
- Notifies var{cmd} to communicate with remote
- devices.
- item --same-order
- itemx -s
- This option is an optimization for
- command{tar} that the list of file
- arguments has already been sorted to match the order of files in the
- archive.
- item --same-owner
- When extracting an archive,
- command{tar} archive with this option present.
- This is the default behavior for the superuser; this option has an
- effect only for ordinary users.
- item --same-permissions
- (See pxref{Setting Access Permissions}.)
- command{tar} and exits
- successfully. This option is intended for use in shell scripts.
- Here is an example of what you can see using this option:
- end smallexample
- command{tar} to mention directories its skipping over when
- operating on a xref{show-omitted-dirs}.
- xref{listing member and file names}.
- itemx -S
- Invokes a
- xref{sparse}.
- var{name}
- var{name}
- This option affects extraction only;
- var{name}.
- item --strip-components=
- var{number} of leading components from file names before
- extraction.option{--strip-path} in
- version 1.14.} For example, if archive
- file{/some/file/name}, then running
- end smallexample
- file{name}.
- var{suffix}
- Alters the suffix
- samp{~}.
- item --tape-length=
- itemx -L
- command{tar} is writing as being
- var{num} x 1024} bytes long.
- item --test-label
- Reads the volume label. If an argument is specified, test whether it
- matches the volume label.
- item --to-command=
- command{tar} will pipe extracted files to the
- standard input of xref{Writing to an External Program}.
- itemx -O
- During extraction,
- xref{Writing to Standard Output}.
- xref{verbose}.
- itemx -m
- Sets the data modification time of extracted files to the extraction time,
- rather than the data modification time stored in the archive.
- item --uncompress
- (See pxref{gzip})
- option{--gzip}.
- item --unlink-first
- command{tar} to remove the corresponding file from the file
- system before extracting it from the archive.
- item --use-compress-program=
- command{tar} to access the archive through
- xref{gzip}.
- acronym{UTC}. This option implies
- item --verbose
- command{tar} should be more verbose about the operations its
- performing. This option can be specified multiple times for some
- operations to increase the amount of information displayed.
- item --verify
- xref{verify}.
- command{tar} will print an informational message about what version
- it is and a copyright message, some credits, and then exit.
- item --volno-file=
- option{--multi-volume}.
- var{file}.
- item --wildcards
- Use wildcards when excluding files.
- item --wildcards-match-slash
- Wildcards match
- xref{controlling pattern-matching with exclude}.
- node Short Option Summary
- table
- item -A
- item -B
- item -C
- item -F
- item -G
- item -K
- item -L
- item -M
- item -N
- item -O
- item -P
- item -R
- item -S
- item -T
- item -U
- item -V
- item -W
- item -X
- item -Z
- item -b
- item -c
- item -d
- item -f
- item -g
- item -h
- item -i
- item -j
- item -k
- item -l
- command{tar}, and will be changed in future releases.
- item -m
- item -o
- When creating ---
- option{--portability}.
- The later usage is deprecated. It is retained for compatibility with
- the earlier versions of
- option{-o} will be equivalent to
- item -p
- item -r
- item -s
- item -t
- item -u
- item -v
- item -w
- item -x
- item -z
- end table
- section
- GNUTAR{}, indeed. The
- GNUTAR{}, with the precise version of
- command{tar} identifies itself and
- prints the version number to the standard output, then immediately
- exits successfully, without doing anything else, ignoring all other
- options. For example, samp{tar --version}} might return:
- acronym{GNU} tar)
- end smallexample
- samp{tar} in the result above is the program
- name in the package (for example,
- samp{tar} is the name of the package
- itself, containing possibly many programs. The package is currently
- named
- footnote{There are plans to merge the
- command{tar} packages into a single one which would be called
- value{op-version} would not yield samp{tar (
- command{tar} option, without resorting to this
- manual, for once you have carefully read it.
- value{op-help} option. By using this option,
- smallexample
- $
- end smallexample
- command{less} for a pager. Other
- popular pagers are command{pg}. If you know about some
- value{op-help} output, another common idiom is doing:
- var{keyword}
- noindent
- for getting only the pertinent lines.
- The perceptive reader would have noticed some contradiction in the
- previous paragraphs. It is written that both
- value{op-help} print something, and have all other options ignored. In
- fact, they cannot ignore each other, and one of them has to win. We do
- not specify which is stronger, here; experiment if you really wonder!
- The short help output is quite succinct, and you might have to get
- back to the full documentation for precise points. If you are reading
- this paragraph, you already have the
- GNUTAR{}
- distribution, provided you have
- w{file{doc/tar.dvi} the
- usual way (contact your local guru to know how). If
- w{
- command{info} program handy, use the Info reader provided within
- samp{tar} from the main Info menu.
- There is currently no GNUTAR{}.
- If you observe such a
- GNUTAR{}, or it has not
- been produced by GNUTAR{}
- documentation is provided in Texinfo format only, if we
- except, of course, the short result of
- node verbose
- command{tar} progress
- cindex Status information
- cindex Verbose operation
- cindex Error message, block number of
- command{tar} program
- cindex Information during operation
- command{tar}
- Typically,
- command{tar}
- with many options, particularly ones with complicated or
- difficult-to-predict behavior, it is possible to make serious mistakes.
- command{tar}
- easier. These options cause
- value{op-list} command to list an archive prints just
- the file names (one per line) and the other commands are silent.
- When used with most operations, the
- command{tar} to print the name of each file or archive member as it
- is processed. This and the other options which make
- command{tar}.
- With value{op-extract},
- command{tar} to print a longer listing (reminiscent
- of value{op-list} already prints
- the names of the members, value{op-list}
- causes samp{ls -l} type listing of the files
- in the archive. The following examples both extract members with
- long list output:
- kbd{tar --extract --file=archive.tar --verbose --verbose}
- $
- end smallexample
- Verbose output appears on the standard output except when an archive is
- being written to the standard output, as with
- samp{tar cfv -}, or even
- command{tar} writes verbose output to the standard error stream.
- If var{file}} is specified,
- var{file} rather than to standard output or standard
- error.
- The
- value{op-create}---causes
- value{op-checkpoint} option prints an occasional message
- as
- value{op-block-number}, but do want visual confirmation that
- FIXME{There is some confusion here. It seems that -R once wrote a
- message at
- anchor{show-omitted-dirs}
- The
- value{op-list} or
- value{op-exclude} option, or
- some other reason.
- If command{tar} prints, along with
- every message it would normally produce, the block number within the
- archive where the message was triggered. Also, supplementary messages
- are triggered when reading blocks full of NULs, or when hitting end of
- file on the archive. As of now, if the archive if properly terminated
- with a NUL block, the reading of the file may stop before end of file
- is met, so the position of end of file will not usually show when
- GNUTAR{}
- drains the archive before exiting when reading the
- archive from a pipe.
- This option is especially useful when reading damaged archives, since
- it helps pinpoint the damaged sections. It can also be used with
- FIXME-xref{when the node name is set and the
- backup section written.}
- section Asking for Confirmation During Operations
- command{tar} carries out a command without stopping for
- further instructions. In some situations however, you may want to
- exclude some files and archive members from the operation (for instance
- if disk or storage space is tight). You can do this by excluding
- certain files automatically (
- value{op-interactive} option.
- option{--confirmation} for this option.
- When the
- command{tar} first prints a message
- for each such file, telling what operation it intends to take, then asks
- for confirmation on the terminal. The actions which require
- confirmation include adding a file to the archive, extracting a file
- from the archive, deleting a file from the archive, and deleting a file
- from disk. To confirm the action, you must type a line of input
- beginning with
- samp{y},
- command{tar} is reading the archive from the standard input,
- file{/dev/tty} to support the interactive
- communications.
- Verbose output is normally sent to standard output, separate from
- other error messages. However, if the archive is produced directly
- on standard output, then verbose output is mixed with errors on
- node operations
- GNUTAR{} Operations
- end menu
- section Basic
- command{tar} operations, value{op-list} and
- table
- item
- value{op-append} for adding
- all members. Some applications would not welcome making an exception
- in the way of adding the first archive member. On the other hand,
- many people reported that it is dangerously too easy for
- footnote{This is well
- described in
- enumerate
- code{create} instead of
- kbd{c} and
- dfn{exploding} an
- archive, they usually mean something else :-).
- code{file}, when the intent was to create
- an archive with a single file in it. This error is likely because a
- tired user can easily add the
- end enumerate
- So, recognizing the likelihood and the catastrophical nature of these
- errors,
- value{op-create} option is
- given, there are no arguments besides options, and
- emph{not} used. To get around the cautiousness of
- value{op-files-from} option,
- a file with no names in it, as shown in the following commands:
- kbd{tar --create --file=empty-archive.tar --files-from=/dev/null}
- end smallexample
- value{op-extract}
- A socket is stored, within a
- item
- GNUTAR{} now shows dates as
- samp{Aug 30 1996}. (One can revert to
- the old behavior by defining file{src/list.c}
- before reinstalling.) But preferably, people should get used to ISO
- 8601 dates. Local American dates should be made available again with
- full date localization support, once ready. In the meantime, programs
- not being localizable for dates should prefer international dates,
- that's really the way to go.
- Look up
- end table
- section Advanced
- GNUTAR{}, you may want
- to learn about further ways in which
- command{tar}
- commands. Additionally, this chapter includes options which allow you to
- define the output from
- FIXME{check this after the chapter is actually revised to make sure
- it still introduces the info in the chapter correctly : ).}
- end menu
- subsection The Five Advanced
- UNREVISED
- In the last chapter, you learned about the first three operations to
- command{tar}: option{--update},
- option{--delete}, and
- file{practice}, the files are samp{blues},
- samp{rock}, and the two archive files you created are
- samp{music.tar}.
- We will also use the archive files
- samp{bfiles.tar}. samp{apple},
- samp{aspic}.
- samp{./birds}, samp{./box}.
- Unless we state otherwise, all practicing you do and examples you follow
- in this chapter will take place in the
- ref{prepare for examples}.
- (Below in this section, we will remind you of the state of the examples
- where the last chapter left them.)
- The five operations that we will cover in this chapter are:
- option
- itemx -r
- Add new entries to an archive that already exists.
- itemx -r
- Add more recent copies of archive members to the end of an archive, if
- they exist.
- itemx --catenate
- item --delete
- Delete items from an archive (does not work on tapes).
- itemx --diff
- end table
- subsection How to Add Files to Existing Archives:
- UNREVISED
- If you want to add files to an existing archive, you don't need to
- create a new archive; you can use
- option{--append}. (A related operation
- is the
- option{--update},
- value{op-append} to add a file that has the same name as an
- archive member to an archive containing that archive member, then the
- old member is not deleted. What does happen, however, is somewhat
- complex. emph{allows} you to have infinite number of files
- with the same name. Some operations treat these same-named members no
- differently than any other set of archive members: for example, if you
- view an archive with
- value{op-extract} to extract the archive,
- only the most recently added copy of a member with the same name as four
- other members would end up in the working directory. This is because
- emph{replace} a file of
- the same name which existed in the directory already, and
- footnote{Unless you give it
- command{tar} with
- option{--occurrence} option. If you run
- file{archive.tar} contained three copies of file
- smallexample
- tar --extract --file archive.tar --occurrence=2 myfile
- noindent
- would extract only the second copy. value{op-occurrence} option.
- cindex Members, replacing with other members
- value{op-delete} to
- delete the member you want to remove from the archive, , and then use
- ref{delete}
- and
- menu
- * appending files:: Appending Files to an Archive
- * multiple::
- node appending files
- UNREVISED
- cindex Appending files to an Archive
- value{op-append} operation, which writes specified files into the
- archive whether or not they are already among the archived files.
- When you use emph{must} specify file name
- arguments, as there is no default. If you specify a file that already
- exists in the archive, another copy of the file will be added to the
- end of the archive. As with other operations, the member names of the
- newly added files will be exactly the same as their names given on the
- command line. The
- option{--append} cannot be performed on some tape drives, unfortunately,
- due to deficiencies in the formats those tape drives use. The archive
- must be a valid
- xref{Media}.
- To demonstrate using
- file{rock} in the
- file{practice} directory. Then, run the
- following file{rock} to
- smallexample
- $
- end smallexample
- value{op-list} operation, you will see that
- smallexample
- $
- end smallexample
- node multiple
- value{op-append} to add copies of files which have been
- updated since the archive was created. (However, we do not recommend
- doing this since there is another
- option{--update};
- option{--append} here for the sake of completeness.)
- file{blues} and then append the changed
- version to
- file{blues} is in the archive
- file{blues} to the
- archive in this way:
- kbd{tar --append --verbose --file=collection.tar blues}
- blues
- noindent
- Because you specified the command{tar} has
- printed the name of the file being appended as it was acted on. Now
- list the contents of the archive:
- kbd{tar --list --verbose --file=collection.tar}
- -rw-rw-rw- me user 28 1996-10-18 16:31 jazz
- -rw-rw-rw- me user 21 1996-09-23 16:44 blues
- -rw-rw-rw- me user 20 1996-09-23 16:44 folk
- -rw-rw-rw- me user 20 1996-09-23 16:44 rock
- -rw-rw-rw- me user 58 1996-10-24 18:30 blues
- noindent
- The newest version of
- file{blues} will be
- replaced by the newer version. You can confirm this by extracting
- the archive and running
- file{blues}
- from the archive, use
- smallexample
- $
- end smallexample
- value{op-extract} and
- value{op-occurrence} option.
- subsection Updating an Archive
- cindex Updating an archive
- In the previous section, you learned how to use
- value{op-update}. The command{tar}
- archive by comparing the date of the specified archive members against
- the date of the file with the same name. If the file has been modified
- more recently than the archive member, then the newer version of the
- file is added to the archive (as with
- option{--update} with magnetic tape drives.
- The operation will fail.
- option{--update} and
- value{op-backup} option.
- menu
- * how to update::
- node how to update
- option{--update}
- You must use file name arguments with the
- command{tar} won't act on any files and
- won't tell you that it didn't do anything (which may end up confusing
- you).
- option{--update} option at work, create a new file,
- file{blues}, using any text editor. Then invoke
- samp{update} operation and the
- smallexample
- $
- end smallexample
- command{tar} prints out the names
- of the files it is working on, which in this case are the names of the
- files that needed to be updated. If you run
- file{blues} and
- samp{blues};
- the one at the end will be newer and larger, since you added text before
- updating it.
- (The reason
- xref{Media}, for more
- information about tapes.
- GNUTAR{}
- options intended specifically for backups are more
- efficient. If you need to run backups, please consult
- node concatenate
- option{--concatenate}
- cindex Concatenating Archives
- Sometimes it may be convenient to add a second archive onto the end of
- an archive rather than adding individual files to the archive. To add
- one or more archives to the end of another archive, you should use the
- option{--concatenate}, name the archives to be concatenated on the
- command line. (Nothing happens if you don't list any.) The members,
- and their member names, will be copied verbatim from those archives. If
- this causes multiple members to have the same name, it does not delete
- any members; all the members with the same name coexist.
- option{--concatenate} works, create two small archives
- called file{folkjazz.tar}, using the relevant
- files from
- smallexample
- $
- kbd{tar -cvf folkjazz.tar folk jazz}
- folk
- jazz
- noindent
- If you like, You can run
- smallexample
- $
- kbd{tar -tvf folkjazz.tar}
- -rw-rw-rw- melissa user 20 1996-09-23 16:44 folk
- -rw-rw-rw- melissa user 65 1997-01-30 14:15 jazz
- command{tar}:
- kbd{cd ..}
- $
- end smallexample
- If you now list the contents of the
- file{jazzfolk.tar}:
- kbd{tar --list --file=bluesrock.tar}
- blues
- rock
- jazz
- folk
- option{--concatenate}, the source and target archives must
- already exist and must have been created using compatible format
- parameters.
- FIXME{is there a way to specify a
- new name?}
- Like
- cindex command{cat}
- command{cat} vs
- command{cat} to
- concatenate two archives instead of using the
- command{cat} is the utility for combining files.
- However,
- option{--concatenate} removes the end-of-archive marker
- from the target archive before each new archive is appended. If you use
- command{tar} format archive. If you need to retrieve files from an
- archive that was added to using the
- value{op-ignore-zeros} option.
- command{cat} shell utility.
- value{op-file} (
- command{tar} uses the value of the
- environment variable
- node delete
- option{--delete}
- cindex Deleting files from an archive
- value{op-delete}
- option. Specify the name of the archive with
- value{op-verbose} option will
- cause
- value{op-extract}, you must give the exact member names when
- using option{--delete} will remove all versions of
- the named file from the archive. The
- option{--delete} has no short form.
- option{--delete} and
- option{--delete} on an archive if the archive device allows you to
- write to any point on the media, such as a disk; because of this, it
- does not work on magnetic tapes. Do not try to delete an archive member
- from a magnetic tape; the action will not succeed, and you will be
- likely to scramble the archive and damage your tape. There is no safe
- way (except by completely re-writing the archive) to delete files from
- most kinds of magnetic tape.
- file{blues} from the archive
- file{practice} directory, make sure you
- are in that directory, and then,
- kbd{tar --list --file=collection.tar}
- blues
- folk
- jazz
- rock
- practice/blues
- practice/folk
- practice/jazz
- practice/rock
- practice/blues
- $
- kbd{tar --list --file=collection.tar}
- folk
- jazz
- rock
- $
- FIXME{I changed the order of these nodes around and haven't had a chance
- to fix the above example's results, yet. I have to play with this and
- follow it and see what it actually does!}
- The
- command{tar} acts as a filter from code{stdout}.
- subsection Comparing Archive Members with the File System
- UNREVISED
- The option{-d}), or
- emph{only} specify archive member names, not file
- names. If you do not name any members, then
- command{tar} reports a difference.
- You have to specify the record size of the archive when modifying an
- archive with a non-default record size.
- file{rock},
- file{funk} in the archive
- file{funk};
- smallexample
- $
- end smallexample
- FIXME{what does this actually depend on? i'm making a guess,
- here.}Depending on the system where you are running
- command{tar} may have a different error message,
- such as:
- end smallexample
- value{op-compare} option is to check whether the
- archive represents the current state of files on disk, more than validating
- the integrity of the archive media. For this later goal,
- node create options
- option{--create}
- The previous chapter described the basics of how to use
- xref{create}. This section described advanced options to be used with
- menu
- * Ignore Failed Read::
- node Ignore Failed Read
- table
- item --ignore-failed-read
- Do not exit with nonzero on unreadable files or directories.
- node extract options
- option{--extract}
- FIXME{i need to get dan to go over these options with me and see if
- there's a better way of organizing them.}
- The previous chapter showed how to use
- command{tar} to
- extract more information than just file contents, such as the owner,
- the permissions, the modification date, and so forth. This section
- presents options to be used with
- ref{extract} for more basic information about the
- menu
- * Reading:: Options to Help Read Archives
- * Writing:: Changing How
- end menu
- subsection Options to Help Read Archives
- cindex Reading incomplete records
- cindex End-of-archive entries, ignoring
- cindex Large lists of file names on small machines
- cindex Running out of space
- command{tar} will request data in full record increments from
- an archive storage device. If the device cannot return a full record,
- value{op-read-full-records} option
- in conjunction with the value{op-list} operations.
- value{op-read-full-records} option is turned on by default when
- command{tar}
- would fail as soon as it read an incomplete record from the pipe.
- If you're not sure of the blocking factor of an archive, you can
- read the archive by specifying
- value{op-blocking-factor}, using a blocking factor larger than what the
- archive uses. This lets you avoid having to determine the blocking factor
- of an archive.
- menu
- * read full records::
- * Ignore Zeros::
- node read full records
- FIXME{need sentence or so of intro here}
- option
- item -B
- Use in conjunction with
- end table
- unnumberedsubsubsec Ignoring Blocks of Zeros
- Normally,
- value{op-ignore-zeros} allows
- value{op-ignore-zeros} option is turned off by default because many
- versions of
- GNUTAR{}
- does not write after the end of an archive, but seeks to
- maintain compatiblity among archiving utilities.
- option
- itemx -i
- To ignore blocks of zeros (i.e., end-of-archive entries) which may be
- encountered while reading an archive. Use in conjunction with
- value{op-list}.
- node Writing
- command{tar} Writes Files
- FIXME{need to mention the brand new option, --backup}
- end menu
- unnumberedsubsubsec Options Controlling the Overwriting of Existing Files
- When extracting files, if
- command{tar} normally overwrites its metadata (ownership,
- permission, etc.). The
- option{--no-overwrite-dir} option.
- value{op-keep-old-files} option. It causes
- value{op-overwrite} option. It causes
- cindex Protecting old files
- Some people argue that
- command{tar} archive, they expect to see a faithful copy of the
- state of the file system when the archive was created. It is debatable
- that this would always be a proper behavior. For example, suppose one
- has an archive in which
- file{usr/local2}. Since then, maybe the site removed the link and
- renamed the whole hierarchy from
- file{/usr/local}. Such things happen all the time. I guess it would
- not be welcome at all that
- emph{also} simultaneously restores the full
- GNUTAR{} is indeed
- able to remove a whole hierarchy to reestablish a symbolic link, for
- example, but value{op-recursive-unlink} is specified
- to allow this behavior. In any case, single files are silently
- removed.
- Finally, the
- command{tar} to remove files unconditionally
- before extracting them.
- unnumberedsubsubsec Overwrite Old Files
- option
- command{tar} to write extracted files into the file system without
- regard to the files already on the system; i.e., files with the same
- names as archive members are overwritten when the archive is extracted.
- It also causes
- value{op-overwrite} option, particularly when
- combined with the
- item --overwrite-dir
- Overwrite the metadata of directories when extracting files from an
- archive, but remove other files before extracting.
- node Keep Old Files
- table
- item --keep-old-files
- value{op-keep-old-files} option prevents
- value{op-keep-old-files} option is meaningless with
- command{tar} from replacing files in the file system during
- extraction.
- node Keep Newer Files
- table
- item --keep-newer-files
- Do not replace existing files that are newer than their archive
- copies. This option is meaningless with
- end table
- unnumberedsubsubsec Unlink First
- option
- itemx -U
- Remove files before extracting over them.
- This can make
- command{tar} down slightly, so it is disabled by default.
- node Recursive Unlink
- table
- item --recursive-unlink
- When this option is specified, try removing files and directory hierarchies
- before extracting over them.
- end table
- If you specify the
- command{tar} removes
- node Data Modification Times
- cindex Data modification times of extracted files
- command{tar} sets the data modification times of extracted
- files to the corresponding times recorded for the files in the archive, but
- limits the permissions of extracted files by the current
- value{op-touch} option in
- conjunction with
- table
- item --touch
- value{op-extract}.
- node Setting Access Permissions
- cindex Permissions of extracted files
- option{--same-permissions}
- in conjunction with the FIXME{Should be
- aliased to ignore-umask.}
- option
- itemx --same-permission
- itemx --ignore-umask
- value{op-extract}.
- node Writing to Standard Output
- cindex Writing extracted files to standard output
- value{op-to-stdout} in
- conjunction with
- table
- item --to-stdout
- value{op-extract}. When this option is used, instead of creating the
- files specified,
- value{op-list}.
- smallexample
- tar -xOzf foo.tgz bigfile | process
- smallexample
- tar -xOzf foo.tgz bigfile1 bigfile2 | process
- option{--to-command} may be more convenient for use with
- multiple files. See the next section.
- unnumberedsubsubsec Writing to an External Program
- You can instruct
- table
- item --to-program=
- var{command}. When this option is used, instead of creating the
- files specified, var{command} and pipes the
- contents of the files to its standard output.
- code{sh -c}. Notice, that
- end table
- The command can obtain the information about the file it processes
- from the following environment variables:
- var
- item TAR_FILETYPE
- Type of the file. It is a single letter with the following meaning:
- columnfractions 0.10 0.90
- tab Regular file
- tab Directory
- tab Symbolic link
- tab Hard link
- tab Block device
- tab Character device
- vrindex TAR_MODE, to-command environment
- vrindex TAR_FILENAME, to-command environment
- vrindex TAR_REALNAME, to-command environment
- vrindex TAR_UNAME, to-command environment
- vrindex TAR_GNAME, to-command environment
- vrindex TAR_ATIME, to-command environment
- vrindex TAR_MTIME, to-command environment
- vrindex TAR_CTIME, to-command environment
- vrindex TAR_SIZE, to-command environment
- vrindex TAR_UID, to-command environment
- vrindex TAR_GID, to-command environment
- end table
- In addition to these variables,
- GNUTAR{} version number.
- If command{tar} will print
- an error message similar to the following:
- end smallexample
- Here,
- option{--ignore-command-error}:
- option
- item --no-ignore-command-error
- Cancel the effect of any previous
- option{--ignore-command-error} in
- pxref{TAR_OPTIONS}) and wish to temporarily cancel it.
- node remove files
- FIXME{the various macros in the front of the manual think that this
- option goes in this section. i have no idea; i only know it's nowhere
- else in the book...}
- option
- end table
- subsection Coping with Scarce Resources
- cindex Running out of space during extraction
- cindex Space on the disk, recovering from lack of
- menu
- * Starting File::
- * Same Order::
- node Starting File
- table
- item --starting-file=
- itemx -K
- value{op-extract} or
- end table
- If a previous attempt to extract files failed due to lack of disk
- space, you can use
- var{name} of the archive. This assumes, of course, that
- there is now free space, or that you are now extracting into a
- different file system. (You could also choose to suspend
- command{tar} operation. In this case,
- value{xref-incremental},
- value{ref-exclude}.)
- unnumberedsubsubsec Same Order
- option
- itemx --preserve-order
- value{op-compare},
- value{op-extract}.
- FIXME{we don't need/want --preserve to exist any more (from melissa:
- ie, don't want that *version* of the option to exist, or don't want
- the option to exist in either version?}
- value{op-same-order} option tells
- samp{tar -t} on the archive and editing its output.
- This option is probably never needed on modern computer systems.
- section Backup options
- GNUTAR{} offers options for making backups of files
- before writing new versions. These options control the details of
- these backups. They may apply to the archive itself before it is
- created or rewritten, as well as individual extracted members. Other
- command{cp}, command{ln},
- and
- table
- item --backup[=
- opindex --backup
- cindex backups
- Back up files that are about to be overwritten or removed.
- Without this option, the original versions are destroyed.
- Use
- var{method} is not specified, use the value of the
- env{VERSION_CONTROL} is not set,
- use the
- vindex version-control
- samp{version-control};
- the same values for
- var{method}s are:
- samp
- itemx numbered
- r{backup method}
- Always make numbered backups.
- itemx existing
- r{backup method}
- Make numbered backups of files that already have them, simple backups
- of the others.
- itemx simple
- r{backup method}
- Always make simple backups.
- item --suffix=
- opindex --suffix
- vindex SIMPLE_BACKUP_SUFFIX
- Append option{--backup}. If this
- option is not specified, the value of the
- env{SIMPLE_BACKUP_SUFFIX} is not
- set, the default is
- end table
- Some people express the desire to value{op-backup}
- option, by defining some kind of alias or script. This is not as easy
- as one may think, due to the fact that old style options should appear first
- and consume arguments a bit unpredictably for an alias or script. But,
- if you are ready to give up using old style options, you may resort to
- using something like (a Bourne shell function here):
- { /usr/local/bin/tar --backup $*;
- end smallexample
- section Notable
- UNREVISED
- command{tar}ring that directory.}
- findex uuencode
- You can easily use archive files to transport a group of files from
- one system to another: put all relevant files into an archive on one
- computer system, transfer the archive to another system, and extract
- the contents there. The basic transfer medium might be magnetic tape,
- Internet FTP, or even electronic mail (though you must encode the
- archive with
- command{tar} program.
- For example, here is how you might copy a directory's contents from
- one disk to another, while preserving the dates, modes, owners and
- link-structure of all the files therein. In this case, the transfer
- medium is a
- smallexample
- $
- end smallexample
- smallexample
- $ kbd{cd sourcedir; tar --create --file=- . | (cd targetdir; tar --extract --file=-)}}
- noindent
- This is one of the easiest methods to transfer a
- node looking ahead
- command{tar}, and a number of the possible options. The next chapter
- explains how to choose and change file and archive names, how to use
- files to store names of other files which you can then call as
- arguments to
- FIXME{in case it's not obvious, i'm making this up in some sense
- based on my limited memory of what the next chapter *really* does. i
- just wanted to flesh out this final section a little bit so i'd
- remember to stick it in here. :-)}
- If there are too many files to conveniently list on the command line,
- you can list the names in a file, and
- value{xref-files-from}.
- There are various ways of causing
- xref{Choosing}.
- chapter Performing Backups and Restoring Files
- GNUTAR{} is distributed along with the scripts
- which the Free Software Foundation uses for performing backups. There
- is no corresponding scripts available yet for doing restoration of
- files. Even if there is a good chance those scripts may be satisfying
- to you, they are not the only scripts or methods available for doing
- backups and restore. You may well create your own, or use more
- sophisticated packages dedicated to that purpose.
- Some users are enthusiastic about
- file{jdscs.umd.edu} and available on many Unix systems.
- This is free software, and it is available at these places:
- end smallexample
- GNUTAR{}
- distribution.
- bullet
- itemize
- item what are dumps
-
- itemize +
-
- item level 1, level 2 dumps etc
- A level
- var{n}-1 dump (?)
-
- item how to use scripts for dumps (ie, the concept)
-
- item scripts to run after editing backup specs (details)
-
- item Backup Specs, what is it.
-
- item how to customize
-
- end itemize
-
- itemize +
-
- item rtape isn't installed
-
- end itemize
- option{--incremental} option of tar
-
- itemize +
-
- item types of media, different sizes and types, useful for different things
-
- item positioning the tape
- MT writes two at end of write,
- backspaces over one when writing again.
-
- end itemize
- command{tar}
- options which are more specific to usage as a backup tool.
- To
- dfn{backups} are also
- called
- menu
- * Full Dumps:: Using
- command{tar} to Perform Incremental Dumps
- * Backup Levels:: Levels of Backups
- * Backup Parameters:: Setting Parameters for Backups and Restoration
- * Scripted Backups:: Using the Backup Scripts
- * Scripted Restoration:: Using the Restore Script
- node Full Dumps
- command{tar} to Perform Full Dumps
- cindex full dumps
- cindex corrupted archives
- Full dumps should only be made when no other people or programs
- are modifying files in the file system. If files are modified while
- value{op-label} option to give the archive a
- volume label, so you can tell what this archive is even if the label
- falls off the tape, or anything like that.
- Unless the file system you are dumping is guaranteed to fit on
- one volume, you will need to use the
- value{op-one-file-system} option to prevent
- value{op-incremental} (
- command{tar} program (and your
- tapes), it is a good idea to use the
- node Incremental Dumps
- command{tar} to Perform Incremental Dumps
- GNUTAR{} archive that
- stores additional metadata so that exact state of the file system
- can be restored when extracting the archive.
- value{op-listed-incremental} and
- option{--listed-incremental} instructs tar to operate on
- an incremental archive with additional metadata stored in a standalone
- file, called a
- table
- item --listed-incremental=
- itemx -g
- var{file}.
- option{--listed-incremental} together with
- pxref{create}). For example:
- kbd{tar --create \
- --file=archive.1.tar \
- --listed-incremental=/var/log/usr.snar \
- /usr}
- file{archive.1.tar} an incremental backup of
- the
- file{/var/log/usr.snar}. If this file does not exist, it will be
- created. The created archive will then be a
- file{/var/log/usr.snar} exists, it
- determines which files are modified. In this case only these files will be
- stored in the archive. Suppose, for example, that after running the
- above command, you delete file
- file{/usr/local/db} with the following contents:
- kbd{ls /usr/local/db}
- /usr/local/db/data
- /usr/local/db/index
- smallexample
- $
- end smallexample
- file{archive.2.tar} will contain only these
- three members. This archive is called a
- file{/var/log/usr.snar} will be updated with the new data, so if
- you plan to create more
- command{tar}. The above example will then be modified as follows:
- kbd{cp /var/log/usr.snar /var/log/usr.snar-1}
- $
- end smallexample
- Incremental dumps depend crucially on time stamps, so the results are
- unreliable if you modify a file's time stamps during dumping (e.g.,
- with the
- command{tar} extensions and may
- not be readable by non-command{tar} program.
- To extract from the incremental dumps, use
- option{--extract}
- option (command{tar} does
- not need to access snapshot file, since all the data necessary for
- extraction are stored in the archive itself. So, when extracting, you
- can give whatever argument to
- option{--listed-incremental=/dev/null}.
- Alternatively, you can use
- option{--incremental} (
- option{--listed-incremental} when listing or
- extracting incremental backups (for more information, regarding this
- option,
- GNUTAR{} attempts to
- restore the exact state the file system had when the archive was
- created. In particular, it will
- file{/usr}
- file system, one would do
- option{-P} option (
- smallexample
- $
- kbd{tar --extract \
- --listed-incremental=/dev/null \
- --file archive.2.tar}
- option{--list}
- (
- option{--listed-incremental} or
- option{--verbose} options
- option{--verbose} options were selected to avoid breaking usual
- verbose listing output (
- GNUTAR{} up to 1.15.1 used to dump verbatim binary
- contents of the DUMPDIR header (with terminating nulls) when
- option{--listed-incremental} option was
- given, no matter what the verbosity level. This behavior, and,
- especially, the binary output it produced were considered incovenient
- and were changed in version 1.16}:
- kbd{tar --list --incremental --verbose --verbose archive.tar}
- smallexample
- var{file}
- noindent
- where samp{Y}
- if the file is present in the archive,
- samp{D} if the file is a directory (and
- is included in the archive).
- anchor{incremental-op}The option option{-G})
- gives the same behavior as
- option{--list} and
- option{--create} option, it creates an incremental archive without
- creating snapshot file. Thus, it is impossible to create several
- levels of incremental backups with
- node Backup Levels
- dfn{full backup} or
- dfn{incremental dumps}. A
- GNUTAR{} comes with scripts you can use to do full
- and level-one (actually, even level-two and so on) dumps. Using
- scripts (shell programs) to perform backups and restoration is a
- convenient and reliable alternative to typing out file name lists
- and
- file{backup-specs}, which specifies parameters used by the backup
- scripts and by the restore script. This file is usually located
- in xref{Backup Parameters}, for its
- detailed description. Once the backup parameters are set, you can
- perform backups or restoration by running the appropriate script.
- The name of the backup script is
- code{restore}. The following sections describe
- their use in detail.
- value{xref-incremental}, before
- making such an attempt.
- section Setting Parameters for Backups and Restoration
- The file
- command{tar}. You must
- edit
- file{backup-specs} is a shell script, containing
- mainly variable assignments. However, any valid shell construct
- is allowed in this file. Particularly, you may wish to define
- functions within that script (e.g., see
- url{http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#ta
- g_02, the definition of the Shell Command Language}. See also
- code{backup} and
- menu
- * General-Purpose Variables::
- * Magnetic Tape Control::
- * User Hooks::
- * backup-specs example:: An Example Text of
- end menu
- subsection General-Purpose Variables
- code{Backup} scripts
- sends a backup report to this address.
- defvr {Backup variable} BACKUP_HOUR
- The hour at which the backups are done. This can be a number from 0
- to 23, or the time specification in form var{minutes},
- or the string
- code{backup}. Its value may be overridden
- using pxref{Scripted Backups}).
- defvr {Backup variable} TAPE_FILE
- The device var{TAPE_FILE}
- is a remote archive (
- command{mt} is able to access remote devices. If
- pxref{RSH}) is set,
- command{mt}.
- defvr {Backup variable} BLOCKING
- The blocking factor
- value{xref-blocking-factor}.
- defvr {Backup variable} BACKUP_DIRS
- A list of file systems to be dumped (for
- code{restore}). You can include any directory
- name in the list --- subdirectories on that file system will be
- included, regardless of how they may look to other networked machines.
- Subdirectories on other file systems will be ignored.
- The host name specifies which host to run
- GNUTAR{} installed, and
- must be able to access the directory containing the backup scripts and
- their support files using the same file name that is used on the
- machine where the scripts are run (ie. what
- file{/etc/backup/dirs}, but this name may be overridden in
- code{DIRLIST} variable.
- defvr {Backup variable} DIRLIST
- A path to the file containing the list of the file systems to backup
- or restore. By default it is
- end defvr
- code{backup}), or restored
- (for
- file{/etc/backup/files}, but this name may be overridden in
- code{FILELIST} variable.
- defvr {Backup variable} FILELIST
- A path to the file containing the list of the individual files to backup
- or restore. By default it is
- end defvr
- command{mt} binary.
- defvr {Backup variable} RSH
- command{rsh} binary or its equivalent. You may wish to
- set it to
- end defvr
- command{rsh} binary on remote mashines. This will
- be passed via
- GNUTAR{}.
- defvr {Backup variable} VOLNO_FILE
- Name of temporary file to hold volume numbers. This needs to be accessible
- by all the machines which have file systems to be dumped.
- defvr {Backup variable} XLIST
- Name of dfn{exclude file list} is a file
- located on the remote machine and containing the list of files to
- be excluded from the backup. Exclude file lists are searched in
- /etc/tar-backup directory. A common use for exclude file lists
- is to exclude files containing security-sensitive information
- (e.g.,
- code{backup}.
- defvr {Backup variable} SLEEP_TIME
- Time to sleep between dumps of any two successive file systems
- This variable affects only
- end defvr
- GNUTAR{} will display its built-in prompt
- end defvr
- end defvr
- GNUTAR{} executable. If this is not set, backup
- scripts will search
- end defvr
- subsection Magnetic Tape Control
- Backup scripts access tape device using special
- defvr {Backup variable} MT_BEGIN
- The name of
- smallexample
- MT_BEGIN=mt_begin
- mt_begin()
- }
- end defvr
- dfn{rewind} function. The default definition is as
- follows:
- {
- mt -f "$1" rewind
- end smallexample
- defvr {Backup variable} MT_OFFLINE
- The name of the function switching the tape off line. By default
- it is defined as follows:
- {
- mt -f "$1" offl
- end smallexample
- defvr {Backup variable} MT_STATUS
- The name of the function used to obtain the status of the archive device,
- including error count. Default definition:
- {
- mt -f "$1" status
- end smallexample
- node User Hooks
- dfn{User hooks} are shell functions executed before and after
- each dfn{backup
- hooks}, which are executed before and after dumping each file
- system, and
- deffn {User Hook Function} hook var{host} var{fsname}
- Its arguments are:
- var
- item host
- Name or IP address of the host machine being dumped or restored.
- item fsname
- File system name with directory separators replaced with colons. This
- is useful, e.g., for creating unique files.
- end deffn
- Following variables keep the names of user hook functions
- end defvr
- end defvr
- end defvr
- end defvr
- subsection An Example Text of
- file{backup-specs}:
- code{ssh} instead of the less secure
- {
- mts -t $TAPE_FILE
- end smallexample
- section Using the Backup Scripts
- The syntax for running a backup script is:
- var{level} --time=
- end smallexample
- The
- code{--level=0} (this is the default, so
- code{0}).
- code{backup} will also
- try to deduce the requested dump level from the name of the
- script itself. If the name consists of a string
- code{backup}
- to code{level-1} whenever you need to
- create a level one dump.}
- The
- var{Time} may take three forms:
- asis
- var{hh}:
- var{hh} hours
- item
- var{hh} hours
- end table
- You should start a script with a tape or disk mounted. Once you
- start a script, it prompts you for new tapes or disks as it
- needs them. Media volumes don't have to correspond to archive
- files --- a multi-volume archive can be started in the middle of a
- tape that already contains the end of another multi-volume archive.
- The
- pxref{Scripted
- Restoration}).
- The backup scripts write two files on the file system. The first is a
- record file in
- FIXME-xref{incremental and listed-incremental, for a more
- detailed explanation of this file.}
- The second file is a log file containing the names of the file systems
- and files dumped, what time the backup was made, and any error
- messages that were generated, as well as how much space was left in
- the media volume after the last volume of the archive was written.
- You should check this log file after every backup. The file name is
- var{mm-dd-yyyy}-level-var{mm-dd-yyyy}
- represents current date, and
- code{backup}
- script:
- option
- var{level}
- var{level}
- Do backup level
- item -f
- item -v[
- itemx --verbose[=
- var{level}
- is 100, which means the highest debugging level.
- var{start-time}
- var{start-time}
- Wait till
- item -h
- item -L
- item -V
- end table
- section Using the Restore Script
- To restore files that were archived using a scripted backup, use the
- code{restore --all}, it will
- then restore all the file systems and files specified in
- pxref{General-Purpose Variables,BACKUP_DIRS}).
- You may select the file systems (and/or files) to restore by
- giving dfn{patterns} in its command
- line. For example, running
- end smallexample
- samp{albert}. A more
- complicated example:
- end smallexample
- samp{albert}
- as well as
- code{restore} will start restoring files from the lowest
- available dump level (usually zero) and will continue through
- all available dump levels. There may be situations where such a
- thorough restore is not necessary. For example, you may wish to
- restore only files from the recent level one backup. To do so,
- use
- smallexample
- restore --level=1
- code{restore} follows:
- option
- itemx --all
- Restore all file systems and files specified in
- item -l
- itemx --level=
- item -v[
- itemx --verbose[=
- var{level}
- is 100, which means the highest debugging level.
- itemx --help
- Display short help message and exit.
- itemx --license
- Display program license and exit.
- itemx --version
- Display program version and exit.
- FIXME-xref{Media, for a discussion of tape
- positioning.}
- strong{Warning:} The script will delete files from the active file
- system if they were not in the file system when the archive was made.
- value{xref-incremental}, for an explanation of how the script makes
- that determination.
- chapter Choosing Files and Names for
- UNREVISED
- command{tar} enable you to specify a name for your
- archive. Other options let you decide which files to include or exclude
- from the archive, based on when or whether files were modified, whether
- the file names do or don't match specified patterns, or whether files
- are in specified directories.
- end menu
- section Choosing and Naming Archive Files
- cindex Archive Name
- cindex Choosing an archive file
- UNREVISED
- command{tar} uses an archive file name that was compiled when
- it was built on the system; usually this name refers to some physical
- tape drive on the machine. However, the person who installed
- command{tar} where to find (or create) the archive. The
- table
- item --file=
- itemx -f
- end table
- For example, in this
- smallexample
- $
- end smallexample
- file{collection.tar} is the name of the archive. It must directly
- follow the option{-f}
- command{tar} will use this file's name
- for the archive name.
- An archive can be saved as a file in the file system, sent through a
- pipe or over a network, or written to an I/O device such as a tape,
- floppy disk, or CD write drive.
- cindex Archive creation
- If you do not name the archive,
- env{TAPE} as the file name for the archive. If
- that is not available,
- file{/dev/tu00}).
- file{-} as an command{tar} reads the
- archive from standard input (when listing or extracting files), or
- writes it to standard output (when creating an archive). If you use
- var{archive-name} when modifying an archive,
- FIXME{might want a different example here; this is already used in
- "notable tar usages".}
- kbd{cd sourcedir; tar -cf - . | (cd targetdir; tar -xf -)}
- FIXME{help!}
- cindex tar to standard input and output
- smallexample
- var{hostname}:/var{file name}}
- noindent
- option{--file=var{dev}/command{tar}
- will complete the remote connection, if possible, using your username
- as the username on the remote machine.
- anchor{local and remote archives}
- If the archive file name includes a colon (
- samp{var{host}:var{file} is used on the
- host command{rsh}
- program, with a username of
- samp{} sign), then your user name will be used.
- (This is the normal
- command{rsh} access, to
- have the
- GNUTAR{} distribution and by default is installed under
- var{prefix}/libexec/rmt}, were
- value{op-force-local} option.
- file{/dev/null},
- GNUTAR{}, has
- an initial sizing pass which uses this feature.
- section Selecting Archive Members
- cindex Specifying archive members
- command{tar} operates on, when creating or adding to an archive, or which
- archive members
- xref{Operations}.
- To specify file names, you can include them as the last arguments on
- the command line, as follows:
- kbd{tar} var{option1} dots{}] [var{file name-2}
- end smallexample
- If a file name begins with dash (
- option{--add-file} option to preventit from being treated as an
- option.
- If you specify a directory name as a file name argument, all the files
- in that directory are operated on by
- command{tar} is invoked with
- command{tar} operates on all the non-directory files in
- the working directory. If you specify either
- value{op-extract},
- command{tar} does nothing.
- By default,
- command{tar} selects the files or members upon which to
- operate.
- node files
- cindex Reading file names from a file
- cindex File Name arguments, alternatives
- Instead of giving the names of files or archive members on the command
- line, you can put the names into a file, and then use the
- command{tar}. Give the name of the file
- which contains the list of files to include as the argument to
- command{find} utility.
- option
- var{file name}
- var{file name}
- Get names to extract or create from file
- end table
- If you give a single dash as a file name for
- code{--files-from=-} or
- command{tar} with
- code{--files-from=-} and code{-f -}) in the same
- command.
- Any number of
- FIXME{add bob's example, from his message on 2-10-97}
- The following example shows how to use
- file{small-files}. You can then use the
- command{tar} to specify the files from that file,
- file{little.tgz}. (The
- command{tar} compresses the archive with pxref{gzip} for
- more information.)
- kbd{find . -size -400 -print > small-files}
- $
- end smallexample
- option{-T} option, any file name beginning
- with command{tar} option and is
- processed accordingly.GNUTAR{} up to 1.15.1
- recognized only
- option{-C} option:
- group
- $
- kbd{tar -c -f foo.tar --files-from list}
- end smallexample
- command{tar} will first switch to
- file{passwd} and
- file{/lib} directory and will archive
- the file file{foo.tar} will
- contain:
- group
- $
- end group
- noindent
- Notice that the option parsing algorithm used with
- itemize
- item
- When using short (single-letter) option form, its argument must
- immediately follow the option letter, without any intervening
- whitespace. For example:
- item
- When using long option form, the option argument must be separated
- from the option by a single equal sign. No whitespace is allowed on
- any side of the equal sign. For example:
- item
- For both short and long option forms, the option argument can be given
- on the next line after the option name, e.g.:
- group
- --directory
- dir
- end smallexample
- smallexample
- end group
- end itemize
- option{--add-file}
- If you happen to have a file whose name starts with
- option{--add-file} option to prevent it from
- being recognized as an option. For example:
- menu
- * nul::
- node nul
- code{NUL} Terminated File Names
- code{NUL}
- code{NUL} terminated file names
- The value{op-files-from} to read file
- names terminated by a
- option{--files-from}.
- option
- code{NUL} terminated file names, instead of files that
- terminate in a newline.
- value{op-null} option is just like the one in
- command{xargs} and
- option{-print0} predicate of command{find}. In
- value{op-null} also disables special handling for
- file names that begin with dash.
- This example shows how to use
- file{long-files}. The command{find} is just
- like code{NUL}
- rather than with a newline. You can then run
- option{--null} and command{tar} get the
- files from that file,
- file{big.tgz}. The command{tar} will cause
- code{NUL} separator between files.
- kbd{find . -size +800 -print0 > long-files}
- $
- end smallexample
- node exclude
- cindex File names, excluding files by
- cindex Excluding files by file system
- value{op-exclude} or
- table
- item --exclude=
- command{tar} to ignore files that match the
- end table
- value{op-exclude} option prevents any file or member whose name
- matches the shell wildcard (
- file{src} except for files whose names end in
- samp{tar -cf src.tar --exclude='*.o' src}.
- You may give multiple
- table
- item --exclude-from=
- itemx -X
- command{tar} to ignore files that match the patterns listed in
- end table
- option{--exclude-from=
- var{file};
- command{tar} is
- called as samp{tar -c -X foo .}} and the file
- file{*.o}, no files whose names end in
- FIXME{do the exclude options files need to have stuff separated by
- newlines the same as the files-from option does?}
- option
- command{tar} to ignore directories containing a cache directory tag.
- findex exclude-caches
- When creating an archive, the
- command{tar} to exclude all directories that contain a
- file{CACHEDIR.TAG} and having a standard header
- specified in
- menu
- * controlling pattern-matching with exclude::
- * problems with exclude::
- node controlling pattern-matching with exclude
- code{exclude} Options
- Normally, a pattern matches a name if an initial subsequence of the
- name's components matches the pattern, where samp{?}, and
- samp{\} escapes wildcards,
- and wildcards can match
- samp{/} from names
- (
- samp{/} is not trimmed from a user-specified name
- before deciding whether to exclude it.
- However, this matching procedure can be altered by the options listed
- below. These options accumulate. For example:
- end smallexample
- ignores case when excluding
- samp{readme}.
- option
- itemx --no-anchored
- If anchored, a pattern must match an initial subsequence
- of the name's components. Otherwise, the pattern can match any
- subsequence. Default is
- item --ignore-case
- item --wildcards
- samp{*}, samp{[...]}
- are the usual shell wildcards, and
- item --wildcards-match-slash
- samp{*} in
- the pattern can match a samp{/} is
- matched only by
- end table
- The option{--no-recursion} options
- (
- node problems with exclude
- code{exclude} Options
- Some users find
- itemize
- item
- The main operating mode of
- samp{*.o}, but
- explicitly name the file
- samp{dir.o/foo} will be excluded from the archive.
- value{op-exclude} and
- value{op-exclude} when files
- to be excluded are given as a pattern on the command line. Use
- var{file-of-patterns}} to introduce the name of a
- file which contains a list of patterns, one per line; each of these
- patterns can exclude zero, one, or many files.
- value{op-exclude}, be sure to quote the
- GNUTAR{} sees wildcard characters
- like
- samp{*} itself using files at hand, so
- smallexample
- $ var{archive.tar} --exclude '*.o'
- end smallexample
- smallexample
- $ var{archive.tar} --exclude *.o
- end smallexample
- code{regexp}
- syntax, when using exclude options in
- code{regexp} syntax to describe files to be excluded, your command
- might fail.
- command{tar}, what is now the
- var{file-of-patterns}} option was called
- var{pattern}} instead. Now,
- var{pattern}} applies to patterns listed on the command
- line and var{file-of-patterns}} applies to
- patterns listed in a file.
- node Wildcards
- dfn{Globbing} is the operation by which
- samp{*} or
- command{tar} often
- uses wildcard patterns for matching (or globbing) archive members instead
- of actual files in the file system. Wildcard patterns are also used for
- verifying volume labels of
- command{tar}.
- var{pattern} should be written according to shell syntax, using wildcard
- characters to effect globbing. Most characters in the pattern stand
- for themselves in the matched string, and case is significant:
- samp{a}, and not samp{?} in the
- pattern matches any single character in the matched string. The character
- samp{\} says to take the following
- character of the pattern
- samp{?}, samp{[} or
- samp{[}, up to the matching
- dfn{character class} is a list of acceptable characters
- for the next single character of the matched string. For example,
- samp{\} lose their special meaning; for example,
- samp{-},
- samp{[}, samp{?}, or
- samp{-} and emph{first} or
- cindex Excluding characters from a character class
- samp{[}
- is samp{^}, then the meaning of the class is reversed.
- Rather than listing character to match, it lists those characters which
- are
- samp{[var{e}]}, using an hyphen between two
- letters, is meant to represent all characters between
- var{e}, inclusive.
- samp{.}) or forward slashes (
- node after
- cindex Excluding file by age
- cindex Modification time, excluding files by
- UNREVISED
- The command{tar} to only work on files
- whose data modification or status change times are newer than the
- var{date} starts with samp{.}, it is taken to
- be a file name; the data modification time of that file is used as the date.
- If you use this option when creating or appending to an archive,
- the archive will only include new files. If you use
- command{tar} will only extract files newer
- than the
- command{tar} to make the date comparison based on
- modification of the file's data (rather than status
- changes), then use the
- value{op-update} operation in that they allow you to
- specify a particular date against which
- table
- item --after-date=
- itemx --newer=
- itemx -N
- var{date}.
- Acts on files only if their data modification or status change times are
- later than
- var{date} starts with samp{.}, it is taken to be a file
- name; the data modification time of that file is used as the date.
- var{date}
- Acts like
- end table
- These options limit
- ref{Date input formats}; remember that the
- entire date argument must be quoted if it contains any spaces.)
- Gurus would say that
- code{mtime}, the time the contents of the file
- were last modified) and the status change time (
- :)
- fields, while code{mtime}
- field.
- To be precise, emph{both}
- code{ctime} and processes the file if either one is more recent than
- value{op-newer-mtime} only checks
- code{ctime}. Neither uses
- FIXME{Need example of --newer-mtime with quoted argument.}
- strong{Please Note:} value{op-newer-mtime}
- should not be used for incremental backups. Some files (such as those
- in renamed directories) are not selected properly by these options.
- end quotation
- FIXME{which tells -- need to fill this in!}
- section Descending into Directories
- cindex Descending directories, avoiding
- cindex Recursion in directories, avoiding
- FIXME{arrggh! this is still somewhat confusing to me. :-< }
- command{tar} will recursively explore all directories (either
- those given on the command line or through the
- command{tar} to act this way.
- The command{tar}'s recursive descent
- into specified directories. If you specify
- command{find} utility for hunting through levels of directories to
- construct a list of file names which you could then pass to
- command{find} allows you to be more selective when choosing which files to
- archive; see command{find} with
- table
- item --no-recursion
- Prevents
- item --recursion
- Requires
- end table
- When you use GNUTAR{} grabs
- directory entries themselves, but does not descend on them
- recursively. Many people use
- command{tar}
- samp{
- command{find}
- value{op-files-from} option to archive the files
- located via
- value{op-same-permissions} option does not affect them---while users
- might really like it to. Specifying
- command{tar} to grab only the directory entries given to it, adding
- no new files on its own.
- The
- command{tar} to extract only the matched directory entries, not
- the files under those directories.
- The
- pxref{controlling pattern-matching with exclude}).
- The option{--recursion} options apply to
- later options and operands, and can be overridden by later occurrences
- of option{--recursion}. For example:
- kbd{tar -cf jams.tar --norecursion grape --recursion grape/concord}
- noindent
- creates an archive with one entry for
- file{grape/concord}, but no entries under
- file{grape/concord}.
- section Crossing File System Boundaries
- UNREVISED
- command{tar} and specifying
- command{tar} will still archive files explicitly named on the command line
- or through
- table
- item --one-file-system
- command{tar} from crossing file system boundaries when
- archiving. Use in conjunction with any write operation.
- option{--one-file-system} option causes
- command{tar} will not archive that file. If the file is a directory
- itself,
- command{tar} will not cross mount points.
- It is reported that using this option, the mount point is is archived,
- but nothing under it.
- This option is useful for making full or incremental archival backups of
- a file system. If this option is used in conjunction with
- menu
- * directory:: Changing Directory
- * absolute:: Absolute File Names
- node directory
- FIXME{need to read over this node now for continuity; i've switched
- things around some.}
- cindex Directory, changing mid-stream
- UNREVISED
- To change the working directory in the middle of a list of file names,
- either on the command line or in a file specified using
- value{op-directory}. This will change the
- working directory to the directory
- table
- item --directory=
- itemx -C
- end table
- For example,
- kbd{tar -c -f jams.tar grape prune -C food cherry}
- noindent
- will place the files file{prune} from the current
- directory into the archive
- file{cherry} from the directory
- file{cherry} is recorded in the archive under the
- precise name emph{not}
- samp{tar
- --extract}, all three files will be written in the current directory.
- Contrast this with the command,
- kbd{tar -c -f jams.tar grape prune -C food red/cherry}
- noindent
- which records the third file in the archive under the name
- samp{tar --extract}, the third file will be written in a subdirectory
- named
- option{--directory} option to make the archive
- independent of the original name of the directory holding the files.
- The following command places the files
- file{/etc/hosts}, and
- file{foo.tar}:
- kbd{tar -c -f foo.tar -C /etc passwd hosts -C /lib libc.a}
- noindent
- However, the names of the archive members will be exactly what they were
- on the command line: file{hosts}, and
- option{--directory} options are interpreted consecutively. If
- command{tar}, due to a previous
- option{--files-from} (
- command{tar} options (including
- smallexample
- end group
- noindent
- To use it, you would invoke
- smallexample
- $
- end smallexample
- Notice also that you can only use the short option variant in the file
- list, i.e., always use option{--directory}.
- The interpretation of
- value{op-null} option.
- subsection Absolute File Names
- table
- item -P
- file{..} file name component.
- GNUTAR{} drops a leading
- file{..}
- component. This option turns off this behavior.
- When
- samp{/}) from the member name. This causes absolute
- member names in the archive to be treated as relative file names. This
- allows you to have such members extracted wherever you want, instead of
- being restricted to extracting the member in the exact directory named
- in the archive. For example, if the archive member has the name
- command{tar} will extract it as if the name were
- really
- file{..} can cause problems when extracting, so
- command{tar} programs do not do this. As a result, if you
- create an archive whose member names start with a slash, they will be
- difficult for other people with a non-
- GNUTAR{} also strips
- leading slashes from member names when putting members into the
- archive. For example, if you ask
- file{/bin/ls} to an archive, it will do so, but the member name will
- be footnote{A side effect of this is that when
- option{--verbose} the resulting output
- is not, generally speaking, the same as the one you'd get running
- xref{listing member and file names},
- for the information on how to handle this case.}
- If you use the command{tar} will do
- none of these transformations.
- To archive or extract files relative to the root directory, specify
- the
- command{tar} acts on files relative to the working
- directory---ignoring superior directory names when archiving, and
- ignoring leading slashes when extracting.
- When you specify command{tar} stores file names
- including all superior directory names, and preserves leading slashes.
- If you only invoked
- value{op-absolute-names} option, but using this option may be
- more convenient than switching to root.
- FIXME{Is write access an issue?}
- option
- end table
- command{tar} prints out a message about removing the
- GNUTAR{}
- invocation. It represents something which ought to be told; ignoring
- what it means can cause very serious surprises, later.
- Some people, nevertheless, do not want to see this message. Wanting to
- play really dangerously, one may of course redirect
- command{sh}:
- kbd{tar -c -f archive.tar /home 2> /dev/null}
- noindent
- Another solution, both nicer and simpler, would be to change to
- the
- smallexample
- $
- kbd{tar -c -f archive.tar -C / home}
- include getdate.texi
- chapter Controlling the Archive Format
- Due to historical reasons, there are several formats of tar archives.
- All of them are based on the same principles, but have some subtle
- differences that often make them incompatible with each other.
- GNU tar is able to create and handle archives in a variety of formats.
- The most frequently used formats are (in alphabetical order):
- asis
- GNUTAR{} versions up to 1.13.25. This format derived
- from an early
- samp{gnu} format are able to hold pathnames of unlimited
- length.
- GNUTAR{} of versions prior to 1.12.
- enumerate
- item The maximum length of a symbolic link is limited to 99 characters.
- item Maximum value of user or group ID is limited to 2097151 (7777777
- octal)
- end enumerate
- This format has traditionally been used by Automake when producing
- Makefiles. This practice will change in the future, in the meantime,
- however this means that projects containing filenames more than 99
- characters long will not be able to use value{VERSION} and
- Automake prior to 1.9.
- acronym{POSIX.1-1988} specification. It stores
- symbolic ownership information. It is also able to store
- special files. However, it imposes several restrictions as well:
- item The maximum length of a file name is limited to 256 characters,
- provided that the filename can be split at directory separator in
- two parts, first of them being at most 155 bytes long. So, in most
- cases the maximum file name length will be shorter than 256
- characters.
- item Maximum size of a file the archive is able to accomodate
- is 8GB
- item Maximum number of bits in device major and minor numbers is 21.
- item star
- Format used by Jcommand{star}
- implementation. samp{star} archives but
- currently does not produce them.
- acronym{POSIX.1-2001} specification. This is the
- most flexible and feature-rich format. It does not impose any
- restrictions on file sizes or filename lengths. This format is quite
- recent, so not all tar implementations are able to handle it properly.
- However, this format is designed in such a way that any tar
- implementation able to read
- samp{posix} archives as well, with the only exception that any
- additional information (such as long file names etc.) will in such
- case be extracted as plain text files along with the files it refers to.
- This archive format will be the default format for future versions
- of
- end table
- The following table summarizes the limitations of each of these
- formats:
- columnfractions .10 .20 .20 .20 .20
- tab UID tab Path Name
- item gnu tab Unlimited tab 63
- tab 1.8e19 tab Unlimited
- item v7 tab 8GB tab n/a
- tab 2097151 tab 256
- item posix tab Unlimited tab Unlimited
- GNUTAR{} is defined at compilation
- time. You may check it by running
- GNUTAR{} is configured
- to create archives in
- samp{posix}.
- command{tar} Archives More Portable
- * Compression:: Using Less Space through Compression
- * Attributes:: Handling File Attributes
- * Standard:: The Standard Format
- * Extensions::
- command{tar} and
- end menu
- section Making
- command{tar} archive on a particular system that is meant to be
- useful later on many other machines and with other versions of
- command{tar} archive formats
- have been evolving since the first versions of Unix. Many such formats
- are around, and are not always compatible with each other. This section
- discusses a few problems, and gives some advice about making
- command{tar}
- archives to contain only regular files and directories, avoiding
- other kind of special files. Do not attempt to save sparse files or
- contiguous files as such. Let's discuss a few more problems, in turn.
- menu
- * Portable Names:: Portable Names
- * dereference:: Symbolic Links
- * old:: Old V7 Archives
- * ustar:: Ustar Archives
- * gnu:: GNU and old GNU format archives.
- * posix::
- end menu
- subsection Portable Names
- Use portable file and member names. A name is portable if it contains
- only ASCII letters and digits, samp{.},
- samp{-}; it cannot be empty, start with samp{//}, or
- contain
- command{tar} archives to be read under
- MSDOS, you should not rely on case distinction for file names, and you
- might use the command{doschk} program for helping you
- further diagnosing illegal MSDOS names, which are even more limited
- than System V's.
- subsection Symbolic Links
- cindex Symbolic link as file name
- Normally, when
- command{tar} archive is a faithful record of the file system contents.
- value{op-create}, and causes
- command{tar}
- encounters a symbolic link, it will archive the linked-to file,
- instead of simply recording the presence of a symbolic link.
- The name under which the file is stored in the file system is not
- recorded in the archive. To record both the symbolic link name and
- the file name in the system, archive the file under both names. If
- all links were recorded automatically by
- command{tar} while creating
- the same archive, an entire second copy of it will be stored. (This
- value{op-dereference}: many systems do not support
- symbolic links, and moreover, your distribution might be unusable if
- it contains unresolved symbolic links.
- subsection Old V7 Archives
- cindex Old style format
- command{tar} cannot handle additional
- information recorded by newer
- value{op-format-v7} option in
- conjunction with the command{tar} also
- accepts samp{op-old-archive} for this
- option). When you specify it,
- value{op-format-v7}
- unless the archive was created using this option.
- In most cases, a emph{old}
- command{tar}s are
- able to read old format archives, so it might be safer for you to
- always use
- node ustar
- acronym{POSIX}.1-1988 specification is called
- xref{Formats,ustar}, for the detailed
- description of
- code{ustar} format is a good choice for archives intended to be read
- with other implementations of
- code{ustar} format, use
- value{op-create}.
- subsection GNUTAR{} format
- acronym{POSIX} 1003.1 acronym{GNU} extensions to
- command{tar} header record which were
- specified in that
- acronym{POSIX} have allocated the same parts of the header record for
- other purposes. As a result,
- acronym{POSIX} specification, and with
- command{tar} will be configured to create
- this format by default. This will change in the future releases, since
- we plan to make
- GNUTAR{} archive, use option
- node posix
- GNUTAR{} and command{tar}
- The version GNUTAR{} is able
- to read and create archives conforming to
- acronym{POSIX} conformant archive will be created if
- value{op-format-posix} option.
- subsection Checksumming Problems
- SunOS and HP-UX
- GNUTAR{} and containing non-ASCII file names, that
- is, file names having characters with the eight bit set, because they
- use signed checksums, while
- acronym{POSIX} standards. On
- reading,
- GNUTAR{} compute checksums both ways, and accept
- any on read, so
- GNUTAR{} produces the standard
- checksum, however, raising incompatibilities with Sun. That is to
- say,
- emph{produce} incorrect archives to be read by buggy
- command{tar} now read standard
- archives, so maybe Sun did a similar patch, after all?
- The story seems to be that when Sun first imported
- code{char}'s in their compiler. So they
- started computing checksums wrongly. When they later realized their
- mistake, they merely decided to stay compatible with it, and with
- themselves afterwards. Presumably, but I do not really know, HP-UX
- has chosen that their
- command{tar} format. In any
- case, it now falls on the shoulders of SunOS and HP-UX users to get
- a
- node Large or Negative Values
- cindex large values
- cindex negative time stamps
- command{tar} format uses fixed-sized unsigned octal strings
- to represent numeric values. User and group IDs and device major and
- minor numbers have unsigned 21-bit representations, and file sizes and
- times have unsigned 33-bit representations.
- acronym{POSIX} representations when possible, but for values
- outside the
- acronym{POSIX}
- acronym{POSIX}
- acronym{POSIX}
- sc{utc}. However, many current
- hosts use a signed 32-bit
- sc{utc}; so
- portable archives must avoid these time stamps for many years to come.
- Portable archives should also avoid time stamps before 1970. These time
- stamps are a common code{time_t}
- representations are negative. Many traditional
- code{time_t}; hence they
- generate archives that are not portable to hosts with differing
- GNUTAR{} recognizes this
- situation when it is run on host with a signed 32-bit
- node Compression
- menu
- * gzip:: Creating and Reading Compressed Archives
- * sparse:: Archiving Sparse Files
- node gzip
- cindex Compressed archives
- GNUTAR{} is able to create and read compressed archives. It supports
- command{bzip2} compression programs. For backward
- compatibilty, it also supports
- command{compress}! Besides, it is less
- effective than command{bzip2}.
- Creating a compressed archive is simple: you just specify a
- option{-z} (
- command{gzip} compressed archive,
- option{--bzip2}) to create a
- option{-Z} (command{compress} program.
- For example:
- kbd{tar cfz archive.tar.gz .}
- GNUTAR{} recognizes its format
- automatically. Thus, the following commands will list and extract the
- archive created in previous example:
- kbd{tar tf archive.tar.gz}
- # Extract the compressed archive
- $
- end smallexample
- The only case when you have to specify a decompression option while
- reading the archive is when reading from a pipe or from a tape drive
- that does not support random access. However, in this case
- smallexample
- $
- end smallexample
- If you see such diagnostics, just add the suggested option to the
- invocation of
- smallexample
- $
- end smallexample
- Notice also, that there are several restrictions on operations on
- compressed archives. First of all, compressed archives cannot be
- modified, i.e., you cannot update (
- value{op-delete}) members from them. Likewise, you cannot append
- another
- value{op-append}). Secondly, multi-volume archives cannot be
- compressed.
- The following table summarizes compression options used by
- table
- item -z
- itemx --ungzip
- Filter the archive through
- option{--gzip} and
- command{tar} program to enforce the specified (or default) record
- size. The default compression parameters are used; if you need to
- override them, set
- smallexample
- $
- end smallexample
- value{op-gzip} option and run
- smallexample
- $
- end smallexample
- command{gzip}'ed files have no
- redundancy, for maximum compression. The adaptive nature of the
- compression scheme means that the compression tables are implicitly
- spread all over the archive. If you lose a few blocks, the dynamic
- construction of the compression tables becomes unsynchronized, and there
- is little chance that you could recover later in the archive.
- There are pending suggestions for having a per-volume or per-file
- compression in
- item -j
- code{bzip2}. Otherwise like
- item -Z
- itemx --uncompress
- Filter the archive through
- value{op-gzip}.
- The
- command{compress}, because there is a patent covering the algorithm it
- uses. You could be sued for patent infringement merely by running
- item --use-compress-program=
- var{prog}. Use this option if you
- have a compression program that
- var{prog} should comply:
- First, when called without options, it should read data from standard
- input, compress it and output it on standard output.
- Secondly, if called with
- end table
- value{op-gzip}, but I'd also like
- the output to be fed through a program like
- command{ecc} (actually, right now that's
- command{tar} through
- command{tar} use
- command{ecc} but if (as the comments say) it can't
- deal with loss of block sync, I'm tempted to throw some time at adding
- that capability. Supposing I were to actually do such a thing and
- get it (apparently) working, do you accept contributed changes to
- utilities like that? (Leigh Clayton
- value{op-use-compress-prog} option?
- I never tried it myself, but I suspect you may want to write a
- option{-d} option, for when
- extraction is needed rather than creation.
- It has been reported that if one writes compressed data (through the
- value{op-compress} options) to a DLT and tries to use
- the DLT compression mode, the data will actually get bigger and one will
- end up with less space on the tape.}
- subsection Archiving Sparse Files
- UNREVISED
- option
- itemx --sparse
- Handle sparse files efficiently.
- value{op-sparse}
- option is useful when many
- acronym{GNU} options. For now, it is an option needing to be specified on
- the command line with the creation or updating of an archive.
- Files in the file system occasionally have ``holes.'' A hole in a file
- is a section of the file's contents which was never written. The
- contents of a hole read as all zeros. On many operating systems,
- actual disk storage is not allocated for holes, but they are counted
- in the length of the file. If you archive such a file,
- command{tar}
- attempt to recognize the holes in a file, use
- value{op-sparse} option, then, for any file using less
- disk space than would be expected from its length,
- value{op-sparse} is not needed on extraction) any such files have
- holes created wherever the continuous stretches of zeros were found.
- Thus, if you use command{tar} archives won't take
- more space than the original.
- A file is sparse if it contains blocks of zeros whose existence is
- recorded, but that have no space allocated on disk. When you specify
- the value{op-create}
- operation,
- command{tar} finds a file to be sparse, it uses a sparse representation of
- the file in the archive.
- value{op-sparse} is useful when archiving files, such as dbm files,
- likely to contain many nulls. This option dramatically
- decreases the amount of space needed to store such an archive.
- strong{Please Note:} Always use
- value{op-sparse} while making file
- system backups as a matter of course, you can be assured the archive
- will never take more space on the media than the files take on disk
- (otherwise, archiving a disk filled with sparse files might take
- hundreds of tapes).
- end quotation
- value{op-sparse} option when reading an archive.
- option
- itemx -S
- Files stored sparsely in the file system are represented sparsely in
- the archive. Use in conjunction with write operations.
- GNUTAR{} still has to read whole disk file to
- locate the
- file{core} file of over 400 megabytes, but with only about
- 3 megabytes of actual data, took about 9 minutes on a Sun Sparcstation
- ELC, with full CPU utilization.)
- This reading is required in all cases and is not related to the fact
- the emph{not}
- using the option, you are not saving time
- value{op-sparse} is selected while creating
- an archive, the current
- command{dump} do not have to read the entire file; by
- examining the file system directly, they can determine in advance
- exactly where the holes are and thus avoid reading through them. The
- only data it need read are the actual allocated data blocks.
- file{comp.unix.internals}, on
- 1990-12-10:
- code{st_blocks} at
- best tells you how many holes there are; it doesn't tell you
- code{st_blocks} is (care
- to name one that does?), they may also care where the holes are (I have
- no examples of this one either, but it's equally imaginable).
- I conclude from this that good archivers are not portable. One can
- arguably conclude that if you want a portable program, you can in good
- conscience restore files with as many holes as possible, since you can't
- get it right.
- node Attributes
- UNREVISED
- When
- value{op-atime-preserve} option, which can either
- reset the access time retroactively or avoid changing it in the first
- place.
- Handling of file attributes
- option
- itemx --atime-preserve=replace
- value{op-atime-preserve-replace} works on most systems, but it also
- restores the data modification time and updates the status change
- time. Hence it doesn't interact with incremental dumps nicely
- (
- command{tar} is
- running.
- command{tar} knows for sure it won't work, it
- complains right away.
- Currently
- value{op-atime-preserve-replace}, but this is intended to change to
- item -m
- command{tar} leaves the data modification times
- of the files it extracts as the times when the files were extracted,
- instead of setting it to the times recorded in the archive.
- This option is meaningless with
- item --same-owner
- Create extracted files with the same ownership they have in the
- archive.
- This is the default behavior for the superuser,
- so this option is meaningful only for non-root users, when
- code{suid} or
- command{tar} writes the user id and user name
- separately. If it can't find a user name (because the user id is not
- in
- code{chmod} like when you use
- FIXME{same-owner?}it tries to look the name (if one was written)
- up in
- item --no-same-owner
- item --numeric-owner
- The
- emph{always} saved into
- value{op-old-archive} is used. Numeric ids could be
- used when moving archives between a collection of machines using
- a centralized management for attribution of numeric ids to users
- and groups. This is often made through using the NIS capabilities.
- When making a
- command{tar} archive out of this directory, before cleaning
- everything out. Of course, we could add a lot of options to
- GNUTAR{} is
- already crowded with options and moreover, the approach just explained
- gives you a great deal of control already.
- itemx --same-permissions
- command{tar} to set the modes (access permissions) of
- extracted files exactly as recorded in the archive. If this option
- is not used, the current
- command{tar} is executed by a superuser.
- This option is meaningless with
- item --preserve
- Same as both value{op-same-order}.
- The
- value{op-same-permissions} plus
- FIXME{I do not see the purpose of such an option. (Neither I. FP.)}
- node Standard
- UNREVISED
- While an archive may contain many files, the archive itself is a
- single ordinary file. Like any other file, an archive file can be
- written to a storage device such as a tape or disk, sent through a
- pipe or over a network, saved on the active file system, or even
- stored in another archive. An archive file is not easy to read or
- manipulate without using the
- acronym{GNU} Emacs.
- Physically, an archive consists of a series of file entries terminated
- by an end-of-archive entry, which consists of two 512 blocks of zero
- bytes. A file
- entry usually describes one of the files in the archive (an
- command{tar} uses to detect file corruption, and
- information about file types.
- Archives are permitted to have more than one member with the same
- member name. One way this situation can occur is if more than one
- version of a file has been stored in the archive. For information
- about adding new versions of a file to an archive, see
- FIXME-xref{To learn more about having more than one archive member with the
- same name, see -backup node, when it's written.}
- In addition to entries describing archive members, an archive may
- contain entries which
- value{xref-label}, for an example of such an archive entry.
- A
- code{BLOCKSIZE} bytes. Although this format may be thought
- of as being on magnetic tape, other media are often used.
- Each file archived is represented by a header block which describes
- the file, followed by zero or more blocks which give the contents
- of the file. At the end of the archive file there are two 512-byte blocks
- filled with binary zeros as an end-of-file marker. A reasonable system
- should write such end-of-file marker at the end of an archive, but
- must not assume that such a block exists when reading an archive. In
- particular
- dfn{blocked} for physical I/O operations.
- Each record of var{n} is set by the
- command{tar}) is written with a single
- samp{write ()}} operation. On magnetic tapes, the result of
- such a write is a single record. When writing an archive,
- the last record of blocks should be written at the full size, with
- blocks after the zero block containing all zeros. When reading
- an archive, a reasonable system should properly handle an archive
- whose last record is shorter than the rest, or which contains garbage
- records after a zero block.
- The header block is defined in C as follows. In the
- file{src/tar.h}:
- include header.texi
- command{tar} format
- does not distinguish text files from binary files, and no translation
- of file contents is performed.
- The code{linkname}, code{uname}, and
- var{w} contains
- code{name} field is the file name of the file, with directory names
- (if any) preceding the file name, separated by slashes.
- code{mode} field provides nine bits specifying file permissions
- and three bits to specify the Set UID, Set GID, and Save Text
- (
- emph{other} permission.
- The code{gid} fields are the numeric user and group
- ID of the file owners, respectively. If the operating system does
- not support numeric user or group IDs, these fields should be ignored.
- The
- FIXME-xref{Modifiers, in
- particular the
- code{mtime} field is the data modification time of the file at
- the time it was archived. It is the ASCII representation of the octal
- value of the last time the file's contents were modified, represented
- as an integer number of
- seconds since January 1, 1970, 00:00 Coordinated Universal Time.
- The
- code{chksum} field is treated as
- if it were all blanks.
- The
- command{tar} issues a warning to the standard error.
- The code{ctime} fields are used in making incremental
- backups; they store, respectively, the particular file's access and
- status change times.
- The value{op-multi-volume} option, when
- making a multi-volume archive. The offset is number of bytes into
- the file that we need to restart at to continue the file on the next
- tape, i.e., where we store the location that a continued file is
- continued at.
- The following fields were added to deal with sparse files. A file
- is
- command{tar} uses to
- detect a sparse file, and once such a file is detected, it is treated
- differently from non-sparse files.
- Sparse files are often
- samp{ls
- -l} is done on them, when in truth, there may be a very small amount
- of important data contained in the file. It is thus undesirable
- to have
- code{sp} is an array of code{struct
- sparse} contains two 12-character strings which represent an offset
- into the file and a number of bytes to be written at that offset.
- The offset is absolute, and not relative to the offset in preceding
- array element.
- The header can hold four of these
- code{isextended} flag is set when an
- code{extended_header} structure is used for sparse files which
- need more sparse structures than can fit in the header. The header can
- fit 4 such structures; if more are needed, the flag
- code{extended_header}.
- Each
- code{isextended} flag
- that the header had. There can be an indeterminate number of such
- table
- item
- itemx
- command{tar}, a
- code{AREGTYPE} should be silently recognized as a regular file.
- New archives should be created using
- command{tar} treats a regular file whose name
- ends with a slash as a directory.
- code{LNKTYPE}
- This flag represents a file linked to another file, of any type,
- previously archived. Such files are identified in Unix by each
- file having the same device and inode number. The linked-to name is
- specified in the
- item
- code{linkname} field with a trailing null.
- code{CHRTYPE}
- code{BLKTYPE}
- These represent character special files and block special files
- respectively. In this case the code{devminor}
- fields will contain the major and minor device numbers respectively.
- Operating systems may map the device specifications to their own
- local specification, or may ignore the entry.
- code{DIRTYPE}
- This flag specifies a directory or sub-directory. The directory
- name in the
- code{size} field
- will contain the maximum number of bytes (which may be rounded to
- the nearest disk block allocation unit) which the directory may
- hold. A
- code{size} field.
- code{FIFOTYPE}
- This specifies a FIFO special file. Note that the archiving of a
- FIFO file archives the existence of this file and not its contents.
- code{CONTTYPE}
- This specifies a contiguous file, which is the same as a normal
- file except that, in operating systems which support it, all its
- space is allocated contiguously on the disk. Operating systems
- which do not allow contiguous allocation should silently treat this
- type as a normal file.
- code{A} code{Z}
- These are reserved for custom implementations. Some of these are
- used in the
- end table
- Other values are reserved for specification in future revisions of
- the P1003 standard, and should not be used by any
- code{magic} field indicates that this archive was output in
- the P1003 archive format. If this field contains
- code{uname} and
- code{uid} and
- cite{Archive/Interchange File Format}; and
- IEEE Std 1003.2-1992, pages 380-388 (section 4.48) and pages 936-940
- (section E.4.48) for
- node Extensions
- acronym{GNU} Extensions to the Archive Format
- acronym{GNU} format uses additional file types to describe new types of
- files in an archive. These are listed below.
- code
- itemx 'D'
- This represents a directory and a list of files created by the
- code{size} field gives the total
- size of the associated list of files. Each file name is preceded by
- either a samp{N}.
- (The file is a directory, or is not stored in the archive.) Each file
- name is terminated by a null. There is an additional null after the
- last file name.
- itemx 'M'
- This represents a file continued from another volume of a multi-volume
- archive created with the
- code{size} field gives the
- maximum size of this piece of the file (assuming the volume does
- not end before the file is written out). The
- code{size} plus
- item GNUTYPE_SPARSE
- item GNUTYPE_VOLHDR
- value{op-label} option when the archive was created. The
- code{name} given after the
- code{size} field is zero. Only the first file in each volume
- of an archive should have this type.
- acronym{GNU} format archive on a
- non-value{op-incremental},
- value{op-sparse}, or
- command{tar} does not
- use the
- command{tar} should be able to read the archive. Otherwise, the
- node cpio
- command{tar} and
- UNREVISED
- command{cpio} archive formats, like
- acronym{GNU}
- command{cpio} implementations
- may crash unexplainedly trying to read them.
- command{cpio} doesn't handle symbolic links in the form in which it comes
- in System V prior to SVR4, and some vendors may have added symlinks
- to their system without enhancing
- command{cpio} that Berkeley picked up from AT&T and put
- into a later BSD release---I think I gave them my changes).
- (SVR4 does some funny stuff with command{cpio}
- can handle
- command{tar} as a result.)
- command{tar} doesn't.
- command{cpio} comes only with System III, System V, and later BSD
- (4.3-tahoe and later).
- command{cpio}s way requires you to play some games (in its "binary"
- format, i-numbers are only 16 bits, and in its "portable ASCII" format,
- they're 18 bits---it would have to play games with the "file system ID"
- field of the header to make sure that the file system ID/i-number pairs
- of different files were always different), and I don't know which
- command{tar}s way of handling multiple hard links to a file places only
- one copy of the link on the tape, but the name attached to that copy
- is the command{cpio}s
- way puts one copy for every link, but you can retrieve it using any
- of the names.
- end quotation
- See the attached manual pages for command{cpio} format.
- command{tar} header for a file;
- quotation
- If anyone knows why command{tar} was present
- at the unix scene,
- command{cpio} first showed up in PWB/UNIX 1.0; no
- generally-available version of UNIX had
- emph{within AT&T}
- had
- command{cpio} knew about it.
- On restore, if there is a corruption on a tape
- command{cpio} will skip over it and try to restore the
- rest of the files.
- The main difference is just in the command syntax and header format.
- quotation
- Is there any differences between the ability to recover crashed
- archives between the two of them. (Is there any chance of recovering
- crashed archives at all.)
- command{tar} since the blocking
- lets you find a header with some variation of var{nn}}.
- However, modern
- quotation
- If anyone knows why command{tar} was present
- at the unix scene, please tell me about this too.
- command{tar}
- always uses 512 bytes per file header) and it knows how to archive
- special files.
- You might want to look at the freely available alternatives. The
- major ones are GNUTAR{}, and
- command{tar}red as sparse files (which you can
- easily test, because the resulting archive gets smaller, and
- command{cpio} can no longer read it).
- chapter Tapes and Other Archive Media
- command{tar} on tape drives. Since
- the creation and manipulation of archives located on magnetic tape was
- the original purpose of
- dfn{error
- count} (number of non-usable bits) of more than 10k.
- Magnetic media are written and erased using magnetic fields, and
- should be protected from such fields to avoid damage to stored data.
- Sticking a floppy disk to a filing cabinet using a magnet is probably
- not a good idea.
- end menu
- section Device Selection and Switching
- table
- item -f [var{file}
- var{hostname}:]
- var{file} on
- end table
- This option is used to specify the file name of the archive
- samp{-},
- samp{-} file name is given when updating an
- archive,
- samp{:}, it is interpreted as
- var{hostname} contains an
- samp{}), it is treated as
- command{tar} will invoke the command
- command{remsh}) to start up an
- command{rsh}.
- Naturally, the remote machine must have an executable
- command{tar}; it's compiled and installed by default.
- The exact path to this utility is determined when configuring the package.
- It is var{prefix}/libexec/rmt}, where
- value{op-rmt-command} option (
- xref{Remote
- Tape Server}, for the description of
- env{TAPE}
- is set, its value is used; otherwise, old versions of
- command{tar} was
- compiled). The default is normally set up to be the
- GNUTAR{} uses
- standard input and standard output as the default device, and I will
- not try anymore supporting automatic device detection at installation
- time. This was failing really in too many cases, it was hopeless.
- This is now completely left to the installer to override standard
- input and standard output for default device, if this seems
- preferable. Further, I think
- command{tar} are done with pipes or disks, not really tapes,
- cartridges or diskettes.
- Some users think that using standard input and output is running
- after trouble. This could lead to a nasty surprise on your screen if
- you forget to specify an output file name---especially if you are going
- through a network or terminal server capable of buffering large amounts
- of output. We had so many bug reports in that area of configuring
- default tapes automatically, and so many contradicting requests, that
- we finally consider the problem to be portably intractable. We could
- of course use something like
- emph{also} running after various kind of trouble, going from hung
- processes to accidental destruction of real tapes. After having seen
- all this mess, using standard input and output as a default really
- sounds like the only clean choice left, and a very useful one too.
- samp{DEFTAPE} in
- table
- item --force-local
- Archive file is local even if it contains a colon.
- var{command}
- Use remote command{rsh}. This option exists
- so that people who use something other than the standard
- command{rsh}) can access a remote device.
- When this command is not used, the shell command found when
- the
- file{/usr/ucb/rsh},
- file{/usr/bin/rsh}, file{/usr/bin/nsh}.
- The installer may have overridden this by defining the environment
- variable emph{at installation time}.
- item -M
- command{tar} to write a
- xref{Multi-Volume Archives}.
- var{num}
- var{num}
- Change tape after writing
- item -F
- itemx --info-script=
- itemx --new-volume-script=
- file{file} at end of each tape. This implies
- xref{info-script}, for a detailed
- description of this option.
- node Remote Tape Server
- cindex remote tape drive
- command{tar}
- uses the remote tape server written at the University of California at
- Berkeley. The remote tape server must be installed as
- var{prefix}/libexec/rmt} on any machine whose tape drive you
- want to use. command{rmt} by running an
- command{remsh} to the remote machine, optionally
- using a different login name if one is supplied.
- A copy of the source for the remote tape server is provided. It is
- Copyright
- cindex absolute file names
- Unless you use the GNUTAR{}
- will not allow you to create an archive that contains
- absolute file names (a file name beginning with
- command{tar} will automatically remove the leading
- command{tar} program,
- command{tar} tape to an operator to restore;
- the operator used Sun GNUTAR{},
- and the result was that it replaced large portions of
- our
- file{/usr/bin/computoy},
- file{usr/bin/computoy},
- relative to the current directory. If you want to extract the files in
- an archive to the same absolute names that they had when the archive
- was created, you should do a
- value{op-absolute-names}
- option, or use the command dots{}}.
- command{tar} must be able to backspace the
- archive in order to reread or rewrite a record that was just read (or
- written). This is currently possible only on two kinds of files: normal
- disk files (or any other file that can be backspaced with
- code{MTIOCTOP}
- value{op-append},
- value{op-concatenate}, and
- command{tar} will work on them
- once
- value{op-multi-volume},
- value{op-incremental} options may not be readable by other version
- of
- command{dd}, if
- it can be done at all. Other versions of
- command{tar} may create normal files instead of directories archived
- with the
- node Common Problems and Solutions
- ifclear PUBLISH
- command{tar}:
- directory checksum error
- header format error
- errors from media/system:
- i/o error
- device busy
- end ifclear
- section Blocking
- dfn{Block} and
- command{tar} from which
- quotation
- The nomenclature of tape drives comes from IBM, where I believe
- they were invented for the IBM 650 or so. On IBM mainframes, what
- is recorded on tape are tape blocks. The logical organization of
- data is into records. There are various ways of putting records into
- blocks, including code{V} (variable
- sized records), var{n}
- to a block), var{n} to a block),
- code{JCL}
- command{tar} was totally confused about this.
- When I wrote
- command{tar} writes data records, which are grouped into blocks).
- It appears that the bogus terminology made it into
- ,{c}ois has migrated that terminology back
- into the source code too.
- dfn{physical block} means the basic transfer chunk from or
- to a device, after which reading or writing may stop without anything
- being lost. In this manual, the term
- emph{assuming} that each disk block is 512
- bytes in length. It is true that some disk devices have different
- physical blocks, but
- command{tar} block is always
- 512 bytes in length, and command{tar} block.
- The term
- GNUTAR{}.
- The term
- dfn{record} usually refers to a tape physical block,
- command{tar} archive is kept on magnetic tape.
- It is true that archives may be put on disk or used with pipes,
- but nevertheless,
- dfn{record} at a time, whatever the medium in use. One record is made
- up of an integral number of blocks, and this operation of putting many
- disk blocks into a single tape block is called
- dfn{blocking}. The term
- dfn{unit record} describes a small set
- of characters which are transmitted whole to or by the application,
- and often refers to a line of text. Those two last terms are unrelated
- to what we call a GNUTAR{}.
- When writing to tapes,
- dfn{records}. To change the default blocking
- factor, use the
- var{512-size} blocks. (Each
- xref{Standard}.) Each file written to the archive uses
- at least one full record. As a result, using a larger record size
- can result in more wasted space for small files. On the other hand, a
- larger record size can often be read and written much more efficiently.
- Further complicating the problem is that some tape drives ignore the
- blocking entirely. For these, a larger record size can still improve
- performance (because the software layers above the tape drive still
- honor the blocking), but not as dramatically as on tape drives that
- honor blocking.
- When reading an archive,
- command{tar} will
- print a message about a non-standard blocking factor, and then operate
- normally. On some tape devices, however,
- value{op-blocking-factor}) larger than the
- actual blocking factor, and then use the
- value{op-blocking-factor} and don't use the
- command{tar} will not
- attempt to figure out the recording size itself.) On some devices,
- you must always specify the record size exactly with
- command{tar} cannot
- figure it out. In any case, use
- command{tar} is reading the archive
- correctly.
- command{tar} records are all the same size;
- at the end of the file there's a block containing all zeros, which
- is how you tell that the remainder of the last record(s) are garbage.
- In a standard
- value{op-blocking-factor} option does is sets the blocking factor,
- changing the record size while leaving the block size at 512 bytes.
- 20 was fine for ancient 800 or 1600 bpi reel-to-reel tape drives;
- most tape drives these days prefer much bigger records in order to
- stream and not waste tape. When writing tapes for myself, some tend
- to use a factor of the order of 2048, say, giving a record size of
- around one megabyte.
- If you use a blocking factor larger than 20, older
- GNUTAR{}, however,
- will support arbitrarily large record sizes, limited only by the
- amount of virtual memory or the physical characteristics of the tape
- device.
- end menu
- subsection Format Variations
- cindex Format Options
- cindex Options, format specifying
- command{tar} uses
- default parameters. You cannot modify a compressed archive.
- If you create an archive with the
- value{pxref-blocking-factor}), you must specify that
- blocking-factor when operating on the archive.
- node Blocking Factor
- cindex Blocking Factor
- cindex Number of blocks per record
- cindex Bytes per record
- UNREVISED
- The data in an archive is grouped into blocks, which are 512 bytes.
- Blocks are read and written in whole number multiples called
- dfn{blocking factor}.
- The
- samp{tar --list
- --file=
- command{tar} fills out the archive to the end of the record.
- In general, the ideal record size depends on the size of the
- inter-record gaps on the tape you are using, and the average size of the
- files you are archiving.
- FIXME{Need example of using a cartridge with blocking factor=126 or more.}
- Archives with blocking factors larger than 20 cannot be read
- by very old versions of
- command{tar} running on old machines with small address spaces.
- With
- smallexample
- Cannot write to /dev/dlt: Invalid argument
- noindent
- In such cases, it sometimes happen that the
- GNUTAR{}
- requires an explicit specification for the block size,
- which it cannot guess. This yields some people to consider
- cite{the bundle w{
- value{op-list} without specifying a blocking factor---
- value{op-read-full-records} option while
- specifying a blocking factor larger then the blocking factor of the archive
- (ie.
- xref{list}, for more information on the
- xref{Reading}, for a more detailed explanation of that option.
- option
- var{number}
- var{number}
- Specifies the blocking factor of an archive. Can be used with any
- operation, but is usually not necessary with
- end table
- Device blocking
- option
- var{blocks}
- var{blocks}
- Set record size to var{blocks} * 512} bytes.
- This option is used to specify a
- command{tar}, will do reads and writes
- of the archive in records of var{block}*512} bytes. This is true
- even when the archive is compressed. Some devices requires that all
- write operations be a multiple of a certain size, and so,
- command{tar} is compiled, and is
- typically 20. Blocking factors larger than 20 cannot be read by very
- old versions of command{tar}
- running on old machines with small address spaces.
- With a magnetic tape, larger records give faster throughput and fit
- more data on a tape (because there are fewer inter-record gaps).
- If the archive is in a disk file or a pipe, you may want to specify
- a smaller blocking factor, since a large one will result in a large
- number of null bytes at the end of the archive.
- When writing cartridge or other streaming tapes, a much larger
- blocking factor (say 126 or more) will greatly increase performance.
- However, you must specify the same blocking factor when reading or
- updating the archive.
- Apparently, Exabyte drives have a physical block size of 8K bytes.
- If we choose our blocksize as a multiple of 8k bytes, then the problem
- seems to disappear. Id est, we are using block size of 112 right
- now, and we haven't had the problem since we switched
- GNUTAR{} the blocking factor is limited only
- by the maximum record size of the device containing the archive, or by
- the amount of available virtual memory.
- However, deblocking or reblocking is virtually avoided in a special
- case which often occurs in practice, but which requires all the
- following conditions to be simultaneously true:
- bullet
- item
- the archive is not handled through standard input or output, nor
- redirected nor piped,
- item
- command{tar}
- invocation.
- itemize
- item
- samp{
- item
- samp{compress -d} silently adds garbage after
- the result of decompression, which tar ignores because it already
- recognized its end-of-file indicator. So this bug may be safely
- ignored.
- samp{gzip -d -q} will be silent about the trailing zeros indeed,
- but will still return an exit status of 2 which tar reports in turn.
- command{tar} offers users against
- other possible problems at decompression time. If
- emph{and} also avoiding setting the
- exit status in this innocuous case, that would solve this situation.
- command{tar} should become more solid at not stopping to read a pipe at
- the first null block encountered. This inelegantly breaks the pipe.
- end itemize
- itemx --ignore-zeros
- Ignore blocks of zeros in archive (means EOF).
- The command{tar} to ignore blocks
- of zeros in the archive. Normally a block of zeros indicates the
- end of the archive, but when reading a damaged archive, or one which
- was created by concatenating several archives together, this option
- allows
- command{tar} write garbage after
- the zeroed blocks.
- Note that this option causes
- item -B
- value{op-read-full-records} is used,
- command{tar} will keep reading until it has obtained a full
- record.
- This option is turned on by default when
- command{tar}
- requested. If this option was not used,
- end table
- Tape blocking
- cindex blocking factor
- dfn{tape gap} is a small landing area on the tape
- with no information on it, used for decelerating the tape to a
- full stop, and for later regaining the reading or writing speed.
- When the tape driver starts reading a record, the record has to
- be read whole without stopping, as a tape gap is needed to stop the
- tape motion without loosing information.
- cindex DAT blocking
- Using higher blocking (putting more disk blocks per tape block) will use
- the tape more efficiently as there will be less tape gaps. But reading
- such tapes may be more difficult for the system, as more memory will be
- required to receive at once the whole record. Further, if there is a
- reading error on a huge record, this is less likely that the system will
- succeed in recovering the information. So, blocking should not be too
- low, nor it should be too high.
- w{
- option{--number-blocks} instead of
- option{--block} will then expand to
- node Many
- FIXME{Appropriate options should be moved here from elsewhere.}
- r{device}
- Most tape devices have two entries in the
- file{/dev/tape}, which often
- points to the only or usual tape device of a given system. There might
- be a corresponding file{/dev/ntape}. The simpler
- name is the
- samp{nr} in it is the
- command{tar}
- opens the archive file before using it and closes it afterwards, this
- means that a simple:
- kbd{tar cf /dev/tape
- end smallexample
- var{directory} contents to it, thus erasing prior tape contents and
- making it so that any subsequent write operation will destroy what has
- just been saved.
- command{tar} archive on a given tape, you
- will need to avoid using the rewinding version of the tape device. You
- will also have to pay special attention to tape positioning. Errors in
- positioning may overwrite the valuable data already on your tape. Many
- people, burnt by past experiences, will only use rewinding devices and
- limit themselves to one file per tape, precisely to avoid the risk of
- such errors. Be fully aware that writing at the wrong position on a
- tape loses all information past this point and most probably until the
- end of the tape, and this destroyed information
- var{directory-1} as a first archive at the beginning of a
- tape, and leave that tape ready for a second archive, you should use:
- kbd{mt -f /dev/nrtape rewind}
- $ var{directory-1}}
- cindex tape marks
- command{tar} by first writing two tape marks after your archive, and by
- backspacing over one of these. So, if you remove the tape at that time
- from the tape drive, it is properly terminated. But if you write
- another file at the current position, the second tape mark will be
- erased by the new information, leaving only one tape mark between files.
- So, you may now save
- smallexample
- $ var{directory-2}}
- noindent
- and so on for all the archives you want to put on the same tape.
- Another usual case is that you do not write all the archives the same
- day, and you need to remove and store the tape between two archive
- sessions. In general, you must remember how many files are already
- saved on your tape. Suppose your tape already has 16 files on it, and
- that you are ready to write the 17th. You have to take care of skipping
- the first 16 tape marks before saving
- smallexample
- $
- kbd{mt -f /dev/nrtape fsf 16}
- $ var{directory-17}}
- xref{Blocking}.
- command{mt} Utility
- node Tape Positioning
- UNREVISED
- Just as archives can store more than one file from the file system,
- tapes can store more than one archive file. To keep track of where
- archive files (or any other type of file stored on tape) begin and
- end, tape archive devices write magnetic
- smallexample
- rrrr*rrrrrr*rrrrr*rr*rrrrr**-------------------------
- dfn{tape
- head}---a physical part of the device which can only access one
- point on the tape at a time. When you use
- code{restore}
- script will find the archive automatically. xref{mt}, for
- an explanation of the tape moving utility.
- If you want to add new archive file entries to a tape, you should
- advance the tape to the end of the existing file entries, backspace
- over the last tape mark, and write the new archive file. If you were
- to add two archives to the example above, the tape might look like the
- following:
- end smallexample
- subsection The
- UNREVISED
- value{xref-blocking-factor}.
- You can use the
- FIXME{Why isn't there an "advance 'til you find two tape marks
- together"?}
- The syntax of the
- smallexample
- var{tapename}] var{number}]}
- var{tapename} is the name of the tape device,
- var{operation} is one of the following:
- table
- item eof
- var{number} tape marks at the current position on the tape.
- var{number} files.
- var{number} files.
- var{number}).
- itemx rewoff1
- Rewinds the tape and takes the tape device off-line. (Ignores
- item status
- Prints status information about the tape unit.
- FIXME{Is there a better way to frob the spacing on the list?}
- If you don't specify a command{mt} uses the environment
- variable env{TAPE} is not set,
- file{/dev/rmt12}.
- node Using Multiple Tapes
- UNREVISED
- Often you might want to write a large archive, one larger than will fit
- on the actual tape you are using. In such a case, you can run multiple
- value{op-exclude} or dumping entire file systems.
- Therefore,
- value{op-multi-volume} on the command line, and then
- command{tar} was archiving when it ran out of tape will usually
- be split between the two archives; in this case you need to extract from
- the first archive, using
- command{tar} can restore both halves of the
- file.)
- GNUTAR{} at both ends to process them properly.
- When prompting for a new tape,
- table
- item ?
- Request
- item q
- Request
- item n
- command{tar} to write the next volume on the file
- item !
- Request
- option{--restrict} command line option to
- item y
- Request
- end table
- (You should only type
- command{tar} will write over the volume it just finished.)
- cindex Info script
- command{tar} the
- var{script-name} is expected
- to be a program (or shell script) to be run instead of the normal
- prompting procedure. It is executed without any command line
- arguments. Additional data is passed to it via the following
- environment variables:
- env
- item TAR_VERSION
- vrindex TAR_ARCHIVE, info script environment variable
- command{tar} is processing.
- item TAR_VOLUME
- Ordinal number of the volume
- vrindex TAR_SUBCOMMAND, info script environment variable
- command{tar} is executed.
- vrindex TAR_FORMAT, info script environment variable
- xref{Formats}, for a complete
- list of archive format names.
- command{tar} to use new archive name,
- by writing in to file descriptor 3 (see below for an
- example).
- If the info script fails,
- command{tar} uses to detect end of tape is not perfect, and
- fails on some operating systems or on some devices. You can use the
- command{tar} can't detect the end of the
- tape itself. This option selects
- var{size} argument should then be the usable size of the tape.
- But for many devices, and floppy disks in particular, this option is
- never required for real, as far as we know.
- cindex volno file
- command{tar} in its tape-change prompt
- can be changed; if you give the
- var{file-of-number} should be an unexisting file to be created, or else,
- a file already containing a decimal number. That number will be used
- as the volume number of the first volume written. When
- value{ref-label}, it
- command{tar} to cycle through a series of files or tape
- drives, there are three approaches to choose from. First of all, you
- can give value{op-file} options. In this case
- the specified files will be used, in sequence, as the successive
- volumes of the archive. Only when the first one in the sequence needs
- to be used again will
- samp{n} response to the
- tape-change prompt, and, finally, you can use an info script, that
- writes new archive name to file descriptor. The following example
- illustrates this approach:
- group
- #! /bin/sh
- echo Preparing volume $TAR_VOLUME of $TAR_ARCHIVE.
- name=`expr $TAR_ARCHIVE : '\(.*\)-.*'`
- case $TAR_SUBCOMMAND in
- -c) ;;
- -d|-x|-t) test -r $}-$TAR_VOLUME || exit 1
- ;;
- *) exit 1
- esac
- echo $}-$TAR_VOLUME >&3
- end smallexample
- Each volume of a multi-volume archive is an independent
- value{op-multi-volume}. However, if one
- file in the archive is split across volumes, the only way to extract
- it successfully is with a multi-volume extract command
- option{-xM}) starting on or before the volume where
- the file begins.
- For example, let's presume someone has two tape drives on a system
- named file{/dev/tape1}. For having
- smallexample
- $ var{files}}
- $ var{files}}
- menu
- * Multi-Volume Archives:: Archives Longer than One Tape or Disk
- * Tape Files:: Tape Files
- * Tarcat:: Concatenate Volumes into a Single Archive
- node Multi-Volume Archives
- cindex Multi-volume archives
- value{op-multi-volume} option in conjunction with
- the pxref{create}). A
- value{op-multi-volume} option is specified), but is
- stored on more than one tape or disk.
- When you specify command{tar} does not report an
- error when it comes to the end of an archive volume (when reading), or
- the end of the media (when writing). Instead, it prompts you to load
- a new storage volume. If the archive is on a magnetic tape, you
- should change tapes when you see the prompt; if the archive is on a
- floppy disk, you should change disks; etc.
- You can read each individual volume of a multi-volume archive as if it
- were an archive by itself. For example, to list the contents of one
- volume, use value{op-multi-volume} specified.
- To extract an archive member from one volume (assuming it is described
- that volume), use
- value{op-multi-volume}.
- If an archive member is split across volumes (ie. its entry begins on
- one volume of the media and ends on another), you need to specify
- samp{tar --extract --multi-volume}---
- xref{extracting archives}, for more
- information about extracting archives.
- pxref{info-script}) is like
- command{tar} does not prompt you
- directly to change media volumes when a volume is full---instead,
- var{script-name}. For
- example, this option can be used to eject cassettes, or to broadcast
- messages such as
- var{script-name} is done,
- value{op-label}
- (command{tar} will not
- automatically label volumes which are added later. To label subsequent
- volumes, specify
- value{op-append}, value{op-concatenate} operation.
- FIXME{example}
- table
- item --multi-volume
- value{op-create}. To perform any other operation on a multi-volume
- archive, specify
- item --info-script=
- itemx -F
- value{op-create}.
- end table
- Beware that there is
- command{tar} archive, to span volume boundaries. If you have a
- multi-volume created by some vendor's
- GNUTAR{}.
- The converse is also true: you may not expect
- multi-volume archives created by
- command{tar}. Since there is little
- chance that, in mixed system configurations, some vendor's
- GNUTAR{} will work on most of
- them, your best bet is to install
- node Tape Files
- UNREVISED
- To give the archive a name which will be recorded in it, use the
- var{volume-label} as the name of the archive to the front of the archive
- which will be displayed when the archive is listed with
- value{op-multi-volume}
- samp{Volume var{nnn} is
- the number of the volume of the archive. (If you use the
- value{xref-label}.
- When
- command{tar}. To do this, use the
- command{mt} command and on the organization
- of tapes into a sequence of tape files, see
- smallexample
- var{some-prefix} `date +
- end smallexample
- or such, for pushing a common date in all volumes or an archive set.
- subsection Concatenate Volumes into a Single Archive
- GNUTAR{} multi-volume
- archive to a single
- GNUTAR{} is shipped with the shell
- script
- smallexample
- end smallexample
- The script implements a simple heuristics to determine the format of
- the first volume file and to decide how to process the rest of the
- files. However, it makes no attempt to verify whether the files are
- given in order or even if they are valid
- command{dd} and does not filter its standard error, so you
- will usually see lots of spurious messages.
- node label
- cindex Labeling an archive
- UNREVISED
- option{--label} option introduced
- option{-V} option introduced
- To avoid problems caused by misplaced paper labels on the archive
- media, you can include a
- value{op-label} option in conjunction with the
- table
- item --label=
- itemx -V
- dfn{archive-label} at the beginning of the archive when
- the archive is being created, when used in conjunction with the
- end table
- If you create an archive using both
- value{op-multi-volume}, each volume of the archive will have an
- archive label of the form var{archive-label} Volume
- var{n} is 1 for the first volume, 2 for the next, and so on.
- cindex Volume label, listing
- option{--list} along with
- the file contents. If verbose display is requested, it will also be
- explicitely marked as in the example below:
- group
- $
- end group
- cindex
- anchor{--test-label option}
- However,
- option{--test-label} option. This option reads only the
- first block of an archive, so it can be used with slow storage
- devices. For example:
- group
- $
- end group
- option{--test-label} is used with a single command line
- argument,
- smallexample
- kbd{tar --test-label --file=iamanarchive 'iamalable'}
- kbd{tar --test-label --file=iamanarchive 'iamalable' alabel}
- end group
- option{--create}, along
- with using command{tar} will first check if
- the archive label matches the one specified and will refuse to proceed
- if it does not. Use this as a safety precaution to avoid accidentally
- overwriting existing archives. For example, if you wish to add files
- to samp{My volume},
- you will get:
- group
- $
- end group
- noindent
- in case its label does not match. This will work even if
- command{tar} will refuse to list or extract the
- archive if its label doesn't match the
- var{archive-label} argument is interpreted
- as a globbing-style pattern which must match the actual magnetic
- volume label.
- footnote{Previous versions of
- command{tar}.}. If the switch
- var{archive-label} by
- samp{ Volume [1-9]*}} if the initial match fails, before giving
- up. Since the volume numbering is automatically added in labels at
- creation time, it sounded logical to equally help the user taking care
- of it when the archive is being read.
- The option{--volume}, but is not available
- under that name anymore.
- You can also use
- smallexample
- kbd{tar cfMV /dev/tape "Daily backup for `date +%Y-%m-%d`"}
- $
- end group
- GNUTAR{} initially attempted to write it,
- often soon after the operator launches
- node verify
- cindex Verifying a write operation
- table
- item -W
- end table
- This option causes
- command{tar} can compare an archive to the
- file system as the archive is being written, to verify a write
- operation, or can compare a previously written archive, to insure that
- it is up to date.
- To check for discrepancies in an archive immediately after it is
- written, use the
- value{op-create} operation. When this option is
- specified,
- value{op-compare} option, instead of using the more automatic
- value{xref-compare}.
- Note that these two options have a slightly different intent. The
- value{op-verify} option is
- really for checking if the physical contents agree and if the recording
- media itself is of dependable quality. So, for the
- command{tar} tries to defeat all in-memory cache pertaining to
- the archive, while it lets the speed optimization undisturbed for the
- value{op-compare} for
- media verification, you may have to defeat the in-memory cache yourself,
- maybe by opening and reclosing the door latch of your recording unit,
- forcing some doubt in your operating system about the fact this is really
- the same volume as the one just written or read.
- The
- value{op-verify} option will not work in conjunction with the
- value{op-append},
- value{op-delete} operations.
- command{tar} normally strips leading
- pxref{absolute}), a command like
- file{/}, as
- file{etc/motd}) when verifying the archive.
- section Write Protection
- Almost all tapes and diskettes, and in a few rare cases, even disks can
- be
- node Free Software Needs Free Documentation
- include freemanuals.texi
- appendix Genfile
- node Snapshot Files
- include snapshot.texi
- appendix Copying This Manual
- end menu
- node Index
- printindex cp
- contents
- c Local variables:
- c End:
|