You are on page 1of 12

Backup

1) General Backup and Recovery questions


Why and when should I backup my database?
Backup and recovery is one of the most important aspects of a DBAs job. f you lose your company!s data" you could very #ell lose your job. $ard#are and soft#are can al#ays be replaced" but your data may be irreplaceable% &ormally one #ould schedule a hierarchy of daily" #eekly and monthly backups" ho#ever consult #ith your users before decidin' on a backup schedule. Backup frequency normally depends on the follo#in' factors(

Rate of data chan'e) transaction rate Database availability) *an you shutdo#n for cold backups+ *riticality of the data) ,alue of the data to the company Read-only tablespace needs backin' up just once ri'ht after you make it read-only f you are runnin' in archivelo' mode you can backup parts of a database over an e.tended cycle of days f archive lo''in' is enabled one needs to backup archived lo' files timeously to prevent database free/es 0tc.

*arefully plan backup retention periods. 0nsure enou'h backup media 1tapes) are available and that old backups are e.pired in-time to make media available for ne# backups. 2ff-site vaultin' is also hi'hly recommended. 3requently test your ability to recover and document all possible scenarios. Remember" it!s the little thin's that #ill 'et you. 4ost failed recoveries are a result of or'ani/ational errors and miscommunication.

What strategies are available for backing-up an Oracle database?


5he follo#in' methods are valid for backin'-up an 2racle database(

Export Import - 0.ports are 6lo'ical6 database backups in that they e.tract lo'ical definitions and data from the database to a file. 7ee the mport) 0.port 3A8 for more details. !old or Off-line Backups - shut the database do#n and backup up A99 data" lo'" and control files.

"ot or On-line Backups - f the database is available and in AR*$ ,092G mode" set the tablespaces into backup mode and backup their files. Also remember to backup the control files and archived redo lo' files. #$%& Backups - #hile the database is off-line or on-line" use the 6rman6 utility to backup the database. Brtools Backups - Backup can be taken offline and online usin' 7A: Brtools

t is advisable to use more than one of these methods to backup your database. 3or e.ample" if you choose to do on-line database backups" also cover yourself by doin' database e.ports. Also test A99 backup and recovery scenarios carefully. t is better to be safe than sorry. Re'ardless of your strate'y" also remember to backup all required soft#are libraries" parameter files" pass#ord files" etc. f your database is in AR*$ ,092G mode" you also need to backup archived lo' files.

What is the difference between online and offline backups?


A hot 1or on-line) backup is a backup performed #hile the database is open and available for use 1read and #rite activity). 0.cept for 2racle e.ports" one can only do on-line backups #hen the database is AR*$ ,092G mode. A cold 1or off-line) backup is a backup performed #hile the database is off-line and unavailable to its users. *old backups can be taken re'ardless if the database is in AR*$ ,092G or &2AR*$ ,092G mode. t is easier to restore from off-line backups as no recovery 1from archived lo's) #ould be required to make the database consistent. &evertheless" on-line backups are less disruptive and doesn!t require database do#ntime. :oint-in-time recovery 1re'ardless if you do on-line or off-line backups) is only available #hen the database is in AR*$ ,092G mode.

What is the difference between restoring and recovering?


Restorin' involves copyin' backup files from secondary stora'e 1backup media) to disk. 5his can be done to replace dama'ed files or to copy)move a database to a ne# location. Recovery is the process of applyin' redo lo's to the database to roll it for#ard. 2ne can rollfor#ard until a specific point-in-time 1before the disaster occurred)" or roll-for#ard until the last transaction recorded in the lo' files.
SQL> connect SYS as SYSDBA SQL> RECOVER DATABASE UNTIL TIME '2009-0 0!"#!"00"00' USIN$ BAC%U& CONTROL'ILE( RMAN> )*n + set *nt,- t,.e to/0ate1'02-A3)-2009 00"00"00'4 'DD-MON-YYYY 5522"MI"SS'6( )esto)e 0ata7ase( )eco8e) 0ata7ase( 9

$y database is down and I cannot restore' What now?


5his is probably not the appropriate time to be sarcastic" but" recovery #ithout backups are not supported. ;ou kno# that you should have tested your recovery strate'y" and that you should al#ays backup a corrupted database before attemptin' to restore)recover it. &evertheless" 2racle *onsultin' can sometimes e.tract data from an offline database usin' a utility called D<9 1Disk <n9oad - 9ife is D<9 #ithout it%). 5his utility reads data in the data files and unloads it into 789=9oader or e.port dump files. $opefully you!ll then be able to load the data into a #orkin' database. &ote that D<9 does not care about rollback se'ments" corrupted blocks" etc" and can thus not 'uarantee that the data is not lo'ically corrupt. t is intended as an absolute last resort and #ill most likely cost your company a lot of money% D<D0 1Database <nloadin' by Data 0.traction) is another non-2racle utility that can be used to e.tract data from a dead database. 4ore info about D<D0 is available at http())###.ora>??.nl).

"ow does one backup a database using the export utility?


2racle e.ports are 6lo'ical6 database backups 1not physical) as they e.tract data and lo'ical definitions from the database into a file. 2ther backup strate'ies normally back-up the physical data files. 2ne of the advanta'es of e.ports is that one can selectively re-import tables" ho#ever one cannot roll-forward from an restored export. 5o completely restore a database from an e.port file one practically needs to recreate the entire database. Al#ays do full system level e.ports 13<99@;07). 3ull e.ports include more information about the database in the e.port file than user level e.ports. 3or more information about the 2racle e.port and import utilities.

"ow does one put a database into %#!"I(E)O* mode?


5he main reason for runnin' in archivelo' mode is that one can provide AB-hour availability and 'uarantee complete data recoverability. t is also necessary to enable AR*$ ,092G mode before one can start to use on-line database backups. ssue the follo#in' commands to put a database into AR*$,092G mode(
SQL> CONNECT s:s AS SYSDBA SQL> STARTU& MOUNT E;CLUSIVE( SQL> ALTER DATABASE ARC5IVELO$( SQL> ARC5IVE LO$ START( SQL> ALTER DATABASE O&EN(

Alternatively" add the above commands into your database!s startup command script" and bounce the database.

5he follo#in' parameters needs to be set for databases in AR*$ ,092G mode(
-o</a)c=,8e/sta)t > TRUE -o</a)c=,8e/0est/# > 'LOCATION>?a)c=/0,)/na.e' -o</a)c=,8e/0est/state/# > ENABLE -o</a)c=,8e/@o).at > A0/At/AsBa)c

&O+E ,- Remember to take a baseline database backup ri'ht after enablin' archivelo' mode. Cithout it one #ould not be able to recover. Also" implement an archivelo' backup to prevent the archive lo' directory from fillin'-up. NOTE 2:' AR*$ ,092G mode #as introduced #ith 2racle >" and is essential for database point-in-time recovery. Archivin' can be used in combination #ith on-line and off-line database backups. &O+E .- ;ou may #ant to set the follo#in' & 5.2RA parameters #hen enablin' AR*$ ,092G mode( log_archive_start=TRUE" log_archive_dest=..." and log_archive_format=... &O+E /- ;ou can chan'e the archive lo' destination of a database on-line #ith the ARCH !E "O# $TART TO 'director%'& statement. 5his statement is often used to s#itch archivin' bet#een a set of directories. &O+E 0- Chen runnin' 2racle Real Application *lusters 1RA*)" you need to shut do#n all nodes before chan'in' the database to AR*$ ,092G mode. 7ee the RA* 3A8 for more details.

I1ve lost an archived online #E2O )O* file3 can I get my 2B back?
5he follo#in' & 5.2RA)7:3 90 parameter can be used if your current redolo's are corrupted or blo#n a#ay. t may also be handy if you do database recovery and one of the archived lo' files are missin' and cannot be restored. &250( !aution is advised #hen enablin' this parameter as you mi'ht end-up losing your entire database. :lease contact 2racle 7upport before usin' it.
/a--oC/)eset-o<s/co))*3t,on > t)*e

5his should allo# you to open the database. $o#ever" after usin' this parameter your database #ill be inconsistent 1some committed transactions may be lost or partially applied). 4teps

Do a 67$<5D2C& &2R4A96 of the database 7et the above parameter Do a 675AR5<: 42<&56 and 6A950R DA5ABA70 2:0& R070592G7D6

f the database asks for recovery" use an <&5 9 *A&*09 type recovery and apply all available archive and on-line redo lo's" then issue *A&*09 and reissue the 6A950R DA5ABA70 2:0& R070592G7D6 command. Cait a couple of minutes for 2racle to sort itself out Do a 67$<5D2C& &2R4A96 Remove the above parameter% Do a database 675AR5<:6 and check your A90R5.92G file for errors. 0.tract the data and rebuild the entire database

56 7ser managed backup and recovery


5his section deals #ith user mana'ed" or non-R4A& backups.

"ow does one do off-line database backups?


7hut do#n the database from sqlplus or server mana'er. Backup all files to secondary stora'e 1e'. tapes). 0nsure that you backup all data files" all control files and all lo' files. Chen completed" restart your database. Do the follo#in' queries to 'et a list of all files that needs to be backed up(
se-ect na.e @)o. s:sB8/D0ata@,-e( se-ect .e.7e) @)o. s:sB8/D-o<@,-e( se-ect na.e @)o. s:sB8/Dcont)o-@,-e(

7ometimes 2racle takes forever to shutdo#n #ith the 6immediate6 option. As #orkaround to this problem" shutdo#n usin' these commands(
a-te) s:ste. c=ecE3o,nt( s=*t0oCn a7o)t sta)t*3 )est),ct s=*t0oCn ,..e0,ate

&ote that if your database is in AR*$ ,092G mode" one can still use archived lo' files to roll for#ard from an off-line backup. f you cannot take your database do#n for a cold 1off-line) backup at a convenient time" s#itch your database into AR*$ ,092G mode and perform hot 1on-line) backups.

"ow does one do on-line database backups?


0ach tablespace that needs to be backed-up must be s#itched into backup mode before copyin' the files out to secondary stora'e 1tapes). 9ook at this simple e.ample.
ALTER TABLES&ACE F:G BE$IN BAC%U&( H c3 F:@',-e# ?7acE*3D,)? ALTER TABLES&ACE F:G END BAC%U&(

t is better to backup tablespace for tablespace than to put all tablespaces in backup mode. Backin' them up separately incurs less overhead. Chen done" remember to backup your control files. 9ook at this e.ample(
ALTER SYSTEM SIITC5 LO$'ILE( -- 'o)ce -o< sC,tc= to *30ate cont)o- @,-e =ea0e)s ALTER DATABASE BAC%U& CONTROL'ILE TO '?7acE*3D,)?cont)o-B07@'(

&250( Do not run on-line backups durin' peak processin' periods. 2racle #ill #rite complete database blocks instead of the normal deltas to redo lo' files #hile in backup mode. 5his #ill lead to e.cessive database archivin' and even database free/es.

$y database was terminated while in B%!879 $O2E3 do I need to recover?


f a database #as terminated #hile one of its tablespaces #as in BA*E<: 42D0 1A950R 5AB907:A*0 .y/ B0G & BA*E<:D)" it #ill tell you that media recovery is required #hen you try to restart the database. 5he DBA is then required to recover the database and apply all archived lo's to the database. $o#ever" from 2racle F.A" one can simply take the individual datafiles out of backup mode and restart the database.
ALTER DATABASE DATA'ILE '?3at=?@,-ena.e' END BAC%U&(

2ne can select from ,GBA*E<: to see #hich datafiles are in backup mode. 5his normally saves a si'nificant amount of database do#n time. 7ee script endHbackupA.sql in the 7cripts section of this site. 3rom 2racleIi on#ards" the follo#in' command can be used to take all of the datafiles out of hotbackup mode(
ALTER DATABASE END BAC%U&(

5his command must be issued #hen the database is mounted" but not yet opened.

2oes Oracle write to data files in begin hot backup mode?


Chen a tablespace is in backup mode" 2racle #ill stop updatin' its file headers" but #ill continue to #rite to the data files. Chen in backup mode" 2racle #ill #rite complete chan'ed blocks to the redo lo' files. &ormally only deltas 1chan'e vectors) are lo''ed to the redo lo's. 5his is done to enable reconstruction of a block if only half of it #as backed up 1split blocks). Because of this" one should notice increased lo' activity and archivin' durin' on-line backups. 5o solve this problem" simply s#itch to R4A& backups.

J) R4A& backup and recovery


5his section deals #ith R4A& backups(

What is #$%& and how does one use it?


Recovery 4ana'er 1or R4A&) is an 2racle provided utility for backin'-up" restorin' and recoverin' 2racle Databases. R4A& ships #ith the database server and doesn!t require a separate installation. 5he R4A& e.ecutable is located in your 2RA*90H$240)bin directory. n fact R4A&" is just a :ro=* application that translates commands to a :9)789 interface. 5he :9)789 calls are stallically linked into the 2racle kernel" and does not require the database to be opened 1mapped from the +)rdbms)admin)recover.bsq file). R4A& can do off-line and on-line database backups. t cannot" ho#ever" #rite directly to tape" but various Jrd-party tools 1like ,eritas" 2miback" etc) can inte'rate #ith R4A& to handle tape library mana'ement. R4A& can be operated from 2racle 0nterprise 4ana'er" or from command line. $ere are the command line ar'uments(
A)<*.ent Va-*e Desc),3t,on ----------------------------------------------------------------------------ta)<et J*ote0-st),n< connect-st),n< @o) ta)<et 0ata7ase cata-o< J*ote0-st),n< connect-st),n< @o) )eco8e): cata-o< nocata-o< none ,@ s3ec,@,e04 t=en no )eco8e): cata-o< c.0@,-e J*ote0-st),n< na.e o@ ,n3*t co..an0 @,-e -o< J*ote0-st),n< na.e o@ o*t3*t .essa<e -o< @,-e t)ace J*ote0-st),n< na.e o@ o*t3*t 0e7*<<,n< .essa<e -o< @,-e a33en0 none ,@ s3ec,@,e04 -o< ,s o3ene0 ,n a33en0 .o0e 0e7*< o3t,ona--a)<s act,8ate 0e7*<<,n< .s<no none s=oC RMAN-nnnn 3)e@,F @o) a-- .essa<es sen0 J*ote0-st),n< sen0 a co..an0 to t=e .e0,a .ana<e) 3,3e st),n< 7*,-0,n< 7-ocE @o) 3,3e na.es t,.eo*t ,nte<e) n*.7e) o@ secon0s to Ca,t @o) 3,3e ,n3*t -----------------------------------------------------------------------------

$ere is an e.ample(
Ko)ac-eL-oca-=ost o)ac-eMD ).an Reco8e): Mana<e)" Re-ease #0B#B0B2B0 &)o0*ct,on Co3:),<=t 1c6 #99N4 20024 O)ac-eB A-- ),<=ts )ese)8e0B RMAN> connect ta)<et( connecte0 to ta)<et 0ata7ase" ORCL 1DBID>#0NO9NP0206 RMAN> 7acE*3 0ata7ase( BBB

"ow does one backup and restore a database using #$%&?


5he bi''est advanta'e of R4A& is that it only backup used space in the database. R4A& doesn!t put tablespaces in backup mode" savin' on redo 'eneration overhead. R4A& #ill re-read database blocks until it 'ets a consistent ima'e of it. 9ook at this simple backup e.ample.

).an ta)<et s:s?QQQ nocata-o< )*n + a--ocate c=anne- t# t:3e 0,sE( 7acE*3 @o).at '?a33?o)ac-e?7acE*3?A0/tAt/sAs/3A3' 10ata7ase6( )e-ease c=anne- t#( 9

0.ample R4A& restore(


).an ta)<et s:s?QQQ nocata-o< )*n + a--ocate c=anne- t# t:3e 0,sE( *nt,- t,.e 'A*< 0P 2000 "N#'( )esto)e ta7-es3ace *se)s( )eco8e) ta7-es3ace *se)s( )e-ease c=anne- t#( 9 R set

5he e.amples above are e.tremely simplistic and only useful for illustratin' basic concepts. By default 2racle uses the database controlfiles to store information about backups. &ormally one #ould rather setup a R4A& catalo' database to store R4A& metadata in. Read the 2racle Backup and Recovery Guide before implementin' any R4A& backups. &ote( R4A& cannot #rite ima'e copies directly to tape. 2ne needs to use a third-party media mana'er that inte'rates #ith R4A& to backup directly to tape. Alternatively one can backup to disk and then manually copy the backups to tape.

"ow does one backup and restore archived log files?


2ne can backup archived lo' files usin' R4A& or any operatin' system backup utility. Remember to delete files after backin' them up to prevent the archive lo' directory from fillin' up. f the archive lo' directory becomes full" your database #ill han'% 9ook at this simple R4A& backup scripts(
RMAN> )*n + 2> a--ocate c=anne- 0e8# t:3e 0,sE( > 7acE*3 2> @o).at '?a33?o)ac-e?a)c=7acE?-o</At/As3A3' N> 1a)c=,8e-o< a-- 0e-ete ,n3*t6( !> )e-ease c=anne- 0e8#( P> 9

5he 6delete input6 clause #ill delete the archived lo's as they as backed-up. 9ist all archivelo' backups for the past AB hours(
RMAN> LIST BAC%U& O' ARC5IVELO$ 'ROM TIME 's:s0ate-#'(

$ere is a restore e.ample(


RMAN> )*n + 2> a--ocate c=anne- 0e8# t:3e 0,sE( > )esto)e 1a)c=,8e-o< -oC -o<seJ PO ## =,<= -o<seJ PO 20 t=)ea0 # a--6( 2> )e-ease c=anne- 0e8#( N> 9

"ow does one create a #$%& recovery catalog?


7tart by creatin' a database schema 1usually called rman). Assi'n an appropriate tablespace to it and 'rant it the recover%_catalog_o'(er role. 9ook at this e.ample(
sJ-3-*s s:s SQL> c)eate *se) ).an ,0ent,@,e0 7: ).an( SQL> a-te) *se) ).an 0e@a*-t ta7-es3ace too-s te.3o)a): ta7-es3ace te.3( SQL> a-te) *se) ).an

J*ota *n-,.,te0 on too-s( SQL> <)ant connect4 )eso*)ce4 )eco8e):/cata-o</oCne) to ).an( SQL> eF,t(

&e.t" lo' in to rman and create the catalo' schema. :rior to 2racle Ki this #as done by runnin' the catrma(.s)l script.
).an cata-o< ).an?).an RMAN> c)eate cata-o< ta7-es3ace too-s( RMAN> eF,t(

;ou can no# continue by re'isterin' your databases in the catalo'. 9ook at this e.ample(
).an cata-o< ).an?).an ta)<et 7acE07a?7acE07a RMAN> )e<,ste) 0ata7ase(

2ne can also use the 6up'rade catalo'D6 command to up'rade to a ne# R4A& release" or the 6drop catalo'D6 command to remove an R4A& catalo'. 5hese commands need to be entered t#ice to confirm the operation.

"ow does one integrate #$%& with third-party $edia $anagers?


5he follo#in' 4edia 4ana'ement 7oft#are ,endors have inte'rated their media mana'ement soft#are #ith R4A& 12racle Recovery 4ana'er)(

,eritas &etBackup - http())###.veritas.com) 04* Data 4ana'er 10D4) - http())###.emc.com) $: 24& Back) Data:rotector - http())###.hp.com) B4!s 5ivoli 7tora'e 4ana'er 1formerly AD74) - http())###.tivoli.com)stora'e) 04* &et#orker - http())###.emc.com) Bri'ht7tor AR*serve Backup - http())###.ca.com)us)data-loss-prevention.asp. 7terlin' 7oft#are!s 7A47(Ale.andria 1formerly from 7pectralo'ic) http())###.sterlin'.com)sams) 7<&!s 7olstice Backup - http())###.sun.com)soft#are)#hitepapers)backup-n-stora'e) *omm,ault Gala.y - http())###.commvault.com) etc...

5he above 4edia 4ana'ement ,endors #ill provide first line technical support 1and installation 'uides) for their respective products. A complete list of supported 4edia 4ana'ement ,endors can be found at( http())###.oracle.com)technolo'y)deploy)availability)htdocs)bsp.htm Chen allocatin' channels one can specify 4edia 4ana'ement spesific parameters. $ere are some e.amples(

&etbackup on 4olarisa--ocate c=anne- t# t:3e 'SBT/TA&E' &ARMS>'SBT/LIBRARY>?*s)?o3en8?net7acE*3?7,n?-,7o7EBsoB#'(

&etbackup on Windowsa--ocate c=anne- t# t:3e 'SBT/TA&E' sen0 SNB/ORA/CLIENT>c-,ent/.ac=,ne/na.eS(

Omniback 2ata9rotector on "9-7:a--ocate c=anne- t# t:3e 'SBT/TA&E' &ARMS>'SBT/LIBRARY> ?o3t?o.n,?-,7?-,7o72o)ac-eO/!27,tBs-'(

or(
a--ocate c=anne- '0e8/#' t:3e 's7t/ta3e' 3a).s 'ENV>OB2BARTY&E>O)ac-eO4OB2A&&NAME>o)c-4OB2BARLIST>.ac=,nena.e/o)c-/a)c=-o<s6 '(

"ow does one clone duplicate a database with #$%&?


5he first step to clone or duplicate a database #ith R4A& is to create a ne# & 5.2RA and pass#ord file 1use the orap#d utility) on the machine you need to clone the database to. Revie# all parameters and make the required chan'ed. 3or e.ample" set the DBH&A40 parameter to the ne# database!s name. 7econdly" you need to chan'e your environment variables" and do a 75AR5<: &242<&5 from sqlplus. 5his database is referred to as the A<L 9 AR; in the script belo#. 9astly" #rite a R4A& script like this to do the clonin'" and call it #ith 6rman cmdfile dupdb.rcv6(
connect ta)<et s:s?sec*)eLo),<07 connect cata-o< ).an?).anLcat07 connect a*F,-,a): ? )*n + set neCna.e @o) 0ata@,-e # to '?ORADATA?*0#?s:ste.0#B07@'( set neCna.e @o) 0ata@,-e 2 to '?ORADATA?*02?*n0ot7s0#B07@'( set neCna.e @o) 0ata@,-e to '?ORADATA?*0 ?*se)s0#B07@'( set neCna.e @o) 0ata@,-e 2 to '?ORADATA?*0 ?,n0F0#B07@'( set neCna.e @o) 0ata@,-e N to '?ORADATA?*02?eFa.3-e0#B07@'( a--ocate a*F,-,a): c=anne- 0*307# t:3e 0,sE( set *nt,- seJ*ence 2 t=)ea0 #( 0*3-,cate ta)<et 0ata7ase to 0*307 -o<@,-e $ROU& # 1'?ORADATA?*02?)e0o0#B-o<'6 SITE 200E REUSE4 $ROU& 2 1'?ORADATA?*0 ?)e0o02B-o<'6 SITE 200E REUSE( 9

5he above script #ill connect to the 6tar'et6 1database that #ill be cloned)" the recovery catalo' 1to 'et backup info)" and the au.iliary database 1ne# duplicate DB). :revious backups #ill be restored and the database recovered to the 6set until time6 specified in the script. &otes( the 6set ne#name6 commands are only required if your datafile names #ill different from the tar'et database.

5he ne#ly cloned DB #ill have its o#n unique DB D.

!an one restore #$%& backups without a !O&+#O);I)E and #E!O(E#< !%+%)O*?
Details of R4A& backups are stored in the database control files and optionally a Recovery *atalo'. f both these are 'one" R4A& cannot restore the database. n such a situation one must e.tract a control file 1or other files) from the backup pieces #ritten out #hen the last backup #as taken. 9et!s look at an e.ample( 9et!s take a backup 1partial in our case for ilustrative purposes)(
D ).an ta)<et ? nocata-o< Reco8e): Mana<e)" Re-ease #0B#B0B2B0 - !27,t &)o0*ct,on Co3:),<=t 1c6 #99N4 20024 O)ac-eB A-- ),<=ts )ese)8e0B connecte0 to ta)<et 0ata7ase" ORCL 1DBID>#02!!!2!296 *s,n< ta)<et 0ata7ase cont)o-@,-e ,nstea0 o@ )eco8e): cata-o< RMAN> 7acE*3 0ata@,-e #( Sta)t,n< 7acE*3 at 20AU$-02 a--ocate0 c=anne-" ORA/DIS%/# c=anne- ORA/DIS%/#" s,0>#2! 0e8t:3e>DIS% c=anne- ORA/DIS%/#" sta)t,n< @*-- 0ata@,-e 7acE*3set c=anne- ORA/DIS%/#" s3ec,@:,n< 0ata@,-e1s6 ,n 7acE*3set ,n3*t 0ata@,-e @no>0000# na.e>?o)a0ata?o)c-?s:ste.0#B07@ c=anne- ORA/DIS%/#" sta)t,n< 3,ece # at 20AU$-02 c=anne- ORA/DIS%/#" @,n,s=e0 3,ece # at 20-AU$-02 3,ece =an0-e> ?@-as=/)eco8e):/a)ea?ORCL?7acE*3set?2002/0O/20?o#/.@/nnn0@/TA$20020O20T#N 2N! /0-cG09t@/B7E3 co..ent>NONE c=anne- ORA/DIS%/#" 7acE*3 set co.3-ete4 e-a3se0 t,.e" 00"00"2N c=anne- ORA/DIS%/#" sta)t,n< @*-- 0ata@,-e 7acE*3set c=anneORA/DIS%/#" s3ec,@:,n< 0ata@,-e1s6 ,n 7acE*3set ,nc-*0,n< c*))ent cont)o-@,-e ,n 7acE*3set ,nc-*0,n< c*))ent S&'ILE ,n 7acE*3set c=anne- ORA/DIS%/#" sta)t,n< 3,ece # at 20-AU$-02 c=anne- ORA/DIS%/#" @,n,s=e0 3,ece # at 20-AU$02 3,ece =an0-e> ?@-as=/)eco8e):/a)ea?ORCL?7acE*3set?2002/0O/20?o#/.@/ncsn@/TA$20020O20T#N 2N! /0-cG@)FO/B7E3 co..ent>NONE c=anne- ORA/DIS%/#" 7acE*3 set co.3-ete4 e-a3se0 t,.e" 00"00"02 ',n,s=e0 7acE*3 at 20-AU$-02K?co0eM

&o#" let!s destroy one of the control files(


SQL> s=oC 3a)a.ete)s CONTROL/'ILES NAME TY&E VALUE ------------------------------------ ---------------------------------------- cont)o-/@,-es st),n< ?o)a0ata?o)c-?cont)o-0#Bct-4 ?o)a0ata?o)c-?cont)o-02Bct-4 ?o)a0ata?o)c-?cont)o-0 Bct- SQL> s=*t0oCn a7o)t( ORACLE ,nstance s=*t 0oCnB SQL> H .8 ?o)a0ata?o)c-?cont)o-0#Bct- ?t.3?cont)o-0#Bct-U?3)e>

&o#" let!s see if #e can restore it. 3irst #e need to start the databaase in &242<&5 mode(
SQL> sta)t*3 NOMOUNT ORACLE ,nstance sta)te0B Tota- S:ste. $-o7a- A)ea 2O920!9P! 7:tes ',Fe0 S,Ge # 0#N ! 7:tes Va),a7-e S,Ge 2!2!PP2P2 7:tes Data7ase B*@@e)s 2N#!NO22 7:tes Re0o B*@@e)s 2!2#22 7:tesU?3)e>

&o#" from 789=:lus" run the follo#in' :9)789 block to restore the file(

DECLARE 8/0e8t:3e VARC5AR21#006( 8/0one BOOLEAN( 8/.aF&,eces NUMBER( TY&E t/3,eceNa.e IS TABLE O' 8a)c=a)212NN6 INDE; BY 7,na):/,nte<e)( 8/3,eceNa.e t/3,eceNa.e( BE$IN -- De@,ne t=e 7acE*3 3,ecesBBB 1na.es @)o. t=e RMAN Lo< @,-e6 8/3,eceNa.e1#6 "> '?@-as=/)eco8e):/a)ea?ORCL?7acE*3set?2002/0O/20?o#/.@/ncsn@/TA$20020O20T#N 2N !/0-cG@)FO/B7E3'( 8/3,eceNa.e126 "> '?@-as=/)eco8e):/a)ea?ORCL?7acE*3set?2002/0O/20?o#/.@/nnn0@/TA$20020O20T#N 2N !/0-cG09t@/B7E3'( 8/.aF&,eces "> 2( -- A--ocate a c=anne-BBB 1Use t:3e>>n*-- @o) DIS%4 t:3e>>'s7t/ta3e' @o) TA&E6 8/0e8t:3e "> DBMS/BAC%U&/RESTOREB0e8,ceA--ocate1t:3e>>NULL4 ,0ent>>'0#'6( -- Resto)e t=e @,)st Cont)o- ',-eBBB DBMS/BAC%U&/RESTOREB)esto)eSetData',-e( -C'NAME .,st 7e t=e eFact 3at= an0 @,-ena.e o@ a cont)o-@,-e ta=t Cas 7acEe0*3 DBMS/BAC%U&/RESTOREB)esto)eCont)o-',-eTo1c@na.e>>'?a33?o)ac-e?o)a0ata?o)c-?co nt)o-0#Bct-'6( 07.s/o*t3*tB3*t/-,ne1'Sta)t )esto),n< 'VV8/.aF&,ecesVV' 3,ecesB'6( 'OR , IN #BB8/.aF&,eces LOO& 07.s/o*t3*tB3*t/-,ne1'Resto),n< @)o. 3,ece 'VV8/3,eceNa.e1,66( DBMS/BAC%U&/RESTOREB)esto)eBacE*3&,ece1=an0-e>>8/3,eceNa.e1,64 0one>>8/0one4 3a)a.s>>n*--6( eF,t C=en 8/0one( END LOO&( -- Dea--ocate t=e c=anne-BBB DBMS/BAC%U&/RESTOREB0e8,ceDeA--ocate1'0#'6( E;CE&TION I5EN OT5ERS T5EN DBMS/BAC%U&/RESTOREB0e8,ceDeA--ocate( RAISE( END( ?

9et!s see if the controlfile #as restored(


SQL> H -s -- ?o)a0ata?o)c-?cont)o-0#Bct- -)C-)----# o)ac-e 09!NP! A*< 20 #!"2N ?o)a0ata?o)c-?cont)o-0#Bct-K?co0eM 07a

Ce should no# be able to 42<&5 the database and continue recovery...


SQL> H c3 ?o)a0ata?o)c-?cont)o-0#Bct- ?o)a0ata?o)c-?cont)o-02Bctc3 ?o)a0ata?o)c-?cont)o-0# SQL> H

You might also like