sh Standard platform
Best practice
&'(
)'* +,,-
Best practice
Document history
+'(
)'* +,,-
Best practice
Table of content
&. Backup with rman.sh............................................................................................................. > +. Restore ................................................................................................................................. 4
)'(
)'* +,,-
Best practice
*'(
)'* +,,-
Best practice
1.
The script rman.sh is used to 5ackup #racle data5ases in UNIX en3ironments. The script uses #racle?s Reco3er@ $ana0er 6rman8 and creates d@namic commands when to 5e used 5@ rman.
1.1.
rman.sh options
"ull 5ackup Archi3elo0 5ackup Backup to disk or TS$ usin0 TD #= an A I til TS$ Use of se3eral channels to TD # Use rman catalo0 or control file Specification of lo0 file location Specification of da@s to sa3e the 5ackup
1.2.
The location of the rman file structure is normall@ 'oracle'rman 6D$8 or 'opt'oracle'rman 6$D8= 5ut other locations can 5e used at some s@stems. The rman file structure stores script files= tdpo option files= lo0 files and trace files in the followin0 structure rman'5in BB...'lo0 .BB..'lo0'rman.trace .BB..'tdpo location of scripts. location of 5ackup lo0s= for eCample rmanT<STDB.lo0 location of trace files. location of tdpo confi0uration files.
1.3.
rman.sh parameters
Dhere to put disk 5ackups 2ow man@ da@s to sa3e the 5ackup !ocation of lo0 file 6default when usin0 the Er parameter8 !ocation of rman setup?s FrootG catalo0 /ompression of 5ackup %c 6/leanupperiod8 2ow lon0 to sa3e the control file= initora= sa3ed when 5ackin0 up to disk.
Dhen usin0 rman.sh se3eral parameters should 5e specified= these areA %d 6Dirmask8 %s 6Sa3eda@s8 %l 6!o0dir8 %r 6Rmandir8 %H 6compreI8
Rman catalo0 6for eCample. rman'rmanJR$AN8 online'offline'archi3elo0s disk's5tKtape'ti3oli Num5er of channels to allocate !e3el of 6differential8 incremental 5ackup !e3el of cumulati3e incremental 5ackup Dhich data5ase to 5ackup.
>'(
)'* +,,-
Best practice
1.4.
Using rman.sh
#ften= rman.pl is started from another script= eCample of this follows. #nline full 5ackup of the data5ase T<STB to TS$ with one channel and clean%up of 5ackups older than *>da@sA
tdpo_online.sh /oracle/rman/bin/rman.sh -p 1 -r /opt/oracle/rman -t online -v tivoli -s 45 TESTDB > /tmp/tdpo_online.err 2> 1
#nline incremental , 5ackup of T<STDB to TS$ with one channel and clean%up of 5ackups older than *>da@sA
tdpo_incremental_!.sh /oracle/rman/bin/rman.sh -p 1 -r /opt/oracle/rman -i ! -t online -v tivoli -s 45 TESTDB > /tmp/tdpo_incremental_!.err 2> 1
#nline incremental & 5ackup of T<STDB to TS$ with one channel and clean%up of 5ackups older than *>da@sA
Archi3elo0 5ackup of T<STDB to TS$ with one channel and clean%up of 5ackups older than *>da@sA
tdpo_archivelo"s.sh /oracle/rman/bin/rman.sh -p 1 -r /opt/oracle/rman -t archivelo"s -v tivoli -s 45 TESTDB > /tmp/tdpo_archivelo"s.err 2> 1
-'(
)'* +,,-
Best practice
2.
2.1.
Restore
!erall reflections
Restore of #racle data5ases is not a tri3ial task and there can 5e se3eral scenarios= for instanceA !oss of ser3er or data5ase !oss of ta5lespace !oss of one or se3eral data files /orrupt data files <tc.
Dependin0 on which scenario that ha3e occurred= the tasks to perform and how to perform them 3aries. 2owe3er= the t@pical scenario is a complete restore either a full restore or to a oint In Time= .I.T. A description for these + scenarios follows. "or other scenarios= refer to #racle Documentation.
2.2.
Before startin0 the restore= there are some pre%conditions that ha3e to 5e met. Amon0 others the followin0A Is #RA/!<K2#$< in place or is an #S restore needed7 Is rman catalo0 or control file used for re0istration of 5ackup histor@7 o G/onnect strin0G to the rman catalo0 can 5e found in the s@stem documentation. o Dhen usin0 rman.pl 5ackup of control file is 0uaranteed as a minimum the num5er of da@s specified 5@ the init parameter GcontrolKfileKrecordKkeepKtimeG. The last Gcop@G of the control file for a 0i3en data5ase can 5e found in #RA/!<K2#$<'d5s with the file name SIDM.cntrlK5ck.d5 or LSIDM.cntrlK5ck.arch.
!ocation of TD # option files7 These are placed at the default location for rman in the folder tdpo= see the s@stem documentation. /onsider restore scenario= .I.T. or full7 If @ou ha3e time= do a cold 5ackup. Are init files= GinitLSIDM.oraG= GifileG or GspfileG= in place7 The usa0e of them is descri5ed in the s@stem documentation.
2.3.
Dependin0 on setup= the 5ackup histor@ information shall 5e 0athered from an rman catalo0 or from a control file. If an rman catalo0 is used= the Gconnect strin0G can 5e found in the s@stem documentation.
4'(
)'* +,,-
Best practice
In case control file is to 5e used= the latest 5ackup has 5een restored to N#RA/!<K2#$<'d5s 5@ TS$. "rom now on the control file is distri5uted to locations 0i3en in init parameters. Dependant on time for restore= LSIDM.cntrlK5ck.d5 or LSIDM.cntrlK5ck.arch should 5e restored. T@picall@= it is the latter since arhci3elo0 5ackup are more freOuentl@ run. "or instanceA dsmc r N#RA/!<K2#$<'d5s'T<STDB.cntrlK5ck.arch Before restore of the control file= it should 5e checked whether the eCistin0 control file 5ackup in P#RA/!<K2#$<P'd5s is new enou0h= since there is a risk that pre3ious #S 5ackup has could ha3e failed. Restore the data5ase Below follows a 0eneric method for restore of #racle data5ases that were 5acked up usin0 rman.pl. "or other scenarios= see the #racle documentation. &. If the data5ase is open= shut it down. +. <sta5lish 5ackup histor@= see a5o3e. ). Start the restore. As the oracle user= set the en3ironment to the data5ase that should 5e restored= also set N!SKDAT<K"#R$ATQ?RRRR%$$%DD 22+*A$IASS? Dith an editor create a script to 5e used for a full restore= for instance named restore.rman= with the followin0 contentA
r#n $ start#p mo#nt% allocate channel t1 t&pe 'sbt_tape' parms 'E()*+TD,-_-,T./0E*/opt/oracle/rman/tdpo/tdpo.db.opt1'% restore database% recover database% alter database open% release channel t1% 2
The location of the tdpo.d5.opt is dependent to the actual s@stem confi0uration and can 5e found in the s@stem documentation "or a .I.T. restore the scripts content should 5eA
r#n $ start#p mo#nt% set #ntil time * 32!!4-!5-24 125!!5!!3% allocate channel t1 t&pe 'sbt_tape' parms 'E()*+TD,-_-,T./0E*/opt/oracle/rman/tdpo/tdpo.db.opt1'% restore database% recover database% alter database open resetlo"s% release channel t1% 2
where F@@@@%mm%dd hhAmmAssG is replaced with the oint In Time @ou wish to restore to. Start the restore 5@ callin0 rman= for instance with an rman catalo0A
rman tar"et / catalo" rman/orarman6rman cmd7ile*restore.rman ms"lo"*restore.lo"
1'(
)'* +,,-
Best practice
2.4.
Temporary tablespace
If the data5ase uses temporar@ ta5lespace of the t@pe GtempfilesG= this ta5le space will not 5e restored. Instead it must 5e re%esta5lished after the restore. A method for this isA &. !o0in into the data5ase +. Do a 5ackup of the control file til traceA
alter database bac8#p control7ile to trace%
). In the udump trace destination= @ou can find a trace file with statements for addition of temporar@ ta5lespace similar to Falter tablespace temp add temp7ile 99: *. <Cecute these statements.
2.%.
Dhen .I.T. restore is performed with an rman catalo0 and the data5ase has 5een opened with reset lo0s in sOlplus= @ou should make sure that the there is a new incarnation in the rman catalo0. Rou do this 5@ startin0 rman with Gcatalo0G and then eCecute Greset data5aseG= for instanceA
rman tar"et / catalo" rman/orarman6rman reset database%
('(
)'* +,,-