You are on page 1of 16

1|P a g e

ORACLE 9i RMAN (10g)


(rev0.1) August, 2007 by Ergem PEKER
(rev1.1) December, 2008 by Ergem PEKER
10g enhancements and some more functionalities.

Version: Oracle Database 10.2.0.1 on Windows2003 Server
Oracle Database 9.2.0.4 on IBM pSeries AIX5L Server


Connecting to rman:

Host #> r man
Rman> connect t ar get /
Rman> connect t ar get dbuser as sysdba/ passwd@TNS
Rman> connect cat al og r man/ pass@TNS
Rman> connect auxi l i ar y dbuser / dbpass@TNS

### interactive mode
Host #> r man t ar get / cat al og r man/ pass@TNS
Host #> r man t ar get / nocat al og

### batch mode
Host #> r man t ar get / cat al og r man/ r man@d cmdf i l e <cmd_f i l e_name> l og
<l og_f i l e_name>

Host #> r man t ar get / @ dai l y. r cv

Rman> r epor t schema

### creating rman catalog
1- Connect t o r man cat al og dat abase wi t h sysdba pr i vi l eges
2- Cr eat e cat al og user wi t h unl i mi t ed quot a and gr ant
r ecover y_cat al og_owner , connect , r esour ce
3- St ar t r man wi t h r ecover y cat al og opt i ons
4- r un cr eat e cat al og command i n r man
5- r egi st er t he t ar get dat abase wi t h r egi st er dat abase command

### creating pipe interface
Host #> r man pi pe r mpi pe t ar get sys/ <passwor d>@TNS_ALI AS
ORA$RMAN_RMPI PE_I N ( r man i nput pi pe)
ORA$RMAN_RMPI PE_OUT ( r man out put pi pe)

SQLPLUS> DBMS_PI PE. PACK
SQLPLUS> DBMS_PI PE. SEND_MESSAGE

SQLPLUS> DBMS_PI PE. RECEI VE_MESSAGE
SQLPLUS> DBMS_PI PE. UNPACK

2|P a g e


Channels:

- - %U = %u_%p_%c
- %c: copy number of t he backup f i l e
- %t : backup set t i mest amp
- %n: dat abase name
- %d: dat abase name
- %p: backup pi ece number


Rman>
conf i gur e devi ce t ype di sk| sbt par al l el i sm3; ### max 255
conf i gur e def aul t devi ce t ype t o di sk;

conf i gur e devi ce t ype di sk cl ear ;
conf i gur e def aul t devi ce t ype cl ear ;

conf i gur e channel devi ce t ype di sk Rat e 5M;
Readr at e 5M;
For mat = / di sk2/ backup/ %U ;
Maxopenf i l es=10;
Maxpi ecesi ze=2G;

### setting disk IO rates
conf i gur e channel 1 devi ce t ype di sk r at e 5M;
conf i gur e channel 2 devi ce t ype di sk r at e 1M;

### rac option for backing up
conf i gur e channel 1 devi ce t ype di sk connect = sys/ passwor d@node1 ;
conf i gur e channel 2 devi ce t ype di sk connect = sys/ passwor d@node2 ;

### clearing channel settings
conf i gur e channel devi ce t ype di sk cl ear ;
conf i gur e channel 1 devi ce t ype di sk cl ear ;

### backing up to different disk media
conf i gur e channel 1 devi ce t ype di sk f or mat / di sk1/ %U ;
conf i gur e channel 2 devi ce t ype di sk f or mat / di sk2/ %U ;

Show al l ;
Show devi ce t ype;
Show def aul t devi ce t ype;
Show channel ;

### command blocks
Rman>
Run
{
Al l ocat e channel c1 devi ce t ype di sk;
Backup dat af i l e 3, 4, 5;
}

3|P a g e


Backup:

### backup database
Rman>
Backup dat abase i ncl ude cur r ent cont r ol f i l e;
Backup dat abase pl us ar chi vel og [ del et e al l [ i nput ] ] ;
Backup [ devi ce t ype di sk| sbt ] dat abase;
Backup dat abase t ag= <t ag_name> ;
Backup not backed up si nce t i me sysdat e- 3 dat abase pl us ar chi vel og;

Backup f or mat pat h/ %U dat abase f i l eper set 3;
Backup f ul l dat abase [ ski p of f l i ne| r eadonl y| i naccessi bl e] ;

### incremental and differential backups
Backup i ncr ement al l evel 0 dat abase;
Backup i ncr ement al l evel 1 dat abase;
Backup i ncr ement al l evel 1 di f f er ent i al dat abase;
Backup i ncr ement al l evel 1 cumul at i ve dat abase;

### overriding backup retentions
Backup dat abase keep unt i l t i me t o_dat e( 03. 08. 2007 , DD. MM. YYYY ) ;
Backup dat abase keep f or ever nol ogs;

### validation of backups
Backup val i dat e dat abase ar chi vel og al l ;

### backup parameters
Backup t abl espace dat a_t s f i l esper set =10 maxset si ze=20G;
Backup t abl espace <t s_name>;

### backup backupsets and imagecopies
Backup backupset 12;
Backup backupset compl et ed bef or e sysdat e- 7 del et e i nput ;
Backup backupset al l [ del et e i nput ] ;
Backup copy of dat abase del et e i nput ;

### configure backup copies
Conf i gur e dat af i l e backup copi es f or devi ce t ype di sk t o 3;
Conf i gur e ar chi vel og backup copi es f or devi ce t ype di sk t o 3;
Conf i gur e dat af i l e backup copi es f or devi ce t ype di sk cl ear ;

Backup devi ce t ype di sk copi es 3 dat af i l e 7 f or mat =
/ t emp/ %U, / dat a2/ backup/ %U, ?/ dbs/ %U;

### backup tablespace
Backup t abl espace user s f or mat =user s_%u%p%c;

Conf i gur e excl ude f or t abl espace <t s_name>;
Backup dat abase; ### wi l l excl ude t he t abl espaces
Backup dat abase noexcl ude; ### i f you dont want t o excl ude t he t s
Conf i gur e excl ude f or t abl espace <t s_name> cl ear ;

### backup database archivelog
Backup ar chi vel og al l [ del et e [ al l ] i nput ] ;
Backup ar chi vel og f r omsequence 121 unt i l sequence 125;
Backup ar chi vel og f r omt i me sysdat e- 30 unt i l t i me sysdat e- 7 ;

### backing up controlfile and spfile
Backup ( spf i l e) ( cur r ent cont r ol f i l e) ;
4|P a g e

Backup cur r ent cont r ol f i l e t ag= <t ag_name> ;


Backup cur r ent cont r ol f i l e f or mat ?/ or adat a/ %F. ct l ;

Backup cont r ol f i l ecopy ' / t mp/ cont r ol 01. ct l ' ;

### automatically backup controlfile
Conf i gur e cont r ol f i l e aut obackup on | of f ;

Backup cur r ent cont r ol f i l e t ag= cont r ol f i l e_27072007 ;
Conf i gur e cont r ol f i l e aut obackup f or mat [ f or devi ce t ype di sk] t o
' ?/ or adat a/ %F. ct l ' ;

### backup datafile
Backup dat af i l e syst em. dbf ;
Backup dat af i l e 48;
Backup devi ce t ype di sk dat af i l ecopy / dat a2/ backup/ onl i ne/ syst em_02. dbf ;
Backup dat af i l ecopy / t mp/ dat a01. dbf ;

### copying database files
Copy [ cur r ent ] cont r ol f i l e t o / t mp/ cont r ol 01. ct l ;
Copy dat af i l e 1 t o / t mp/ 1. dbf ;

Copy dat af i l e 1 t o / t mp/ 1. dbf ,
2 t o / t mp/ 2. dbf ,
3 t o / t mp/ 3. dbf ;

Copy dat af i l e 1 t o / dat a2/ backup/ dat af i l e. dbf ;

### reporting backups
Li st backup;
Li st backup of dat abase [ summar y] ;
Li st backup of dat af i l e 48, 49, 50;
Li st backup of dat af i l e <dat af i l e_f ul l _pat h/ name> ;
Li st backup of t abl espace user s;
Li st backup of cont r ol f i l e;
Li st backup of ar chi vel og al l ;
Li st backup of ar chi vel og [ summar y] ;
Li st backup of ar chi vel og f r omsequence 1000 unt i l sequence 1050;
Li st copy;
Li st copy of t abl espace <t s_name>;
Li st copy of ar chi vel og f r omt i me= sysdat e- 7 ;

### compressed backups
RMAN> Backup as compr essed backupset f or mat / or adat a/ backup/ %d_%u. dbf
dat abase;
RMAN> Sql al t er dat abase ar chi ve l og cur r ent ;
RMAN> Backup as compr essed backupset f or mat . . ar chi vel og al l del et e al l
i nput ;

### image copies and backupsets
RMAN> Backup as backupset f or mat . . / dat a_06. bus dat af i l e 6;
RMAN> Backup as backupset dat af i l e 6;
RMAN> Backup as copy dat abase;

### incremental restore to imagecopies
RMAN> backup as copy i ncr ement al l evel 0 dat abase t ag db_whol e_copy;
RMAN> backup i ncr ement al l evel 1 f or r ecover of copy wi t h t ag db_whol e_copy
dat abase t ag db_copy_upd;
RMAN> r ecover copy of dat abase wi t h t ag db_whol e_copy;
RMAN> del et e backupset t ag db_copy_upd;
5|P a g e


Restore & Recover:

### Preparing Recovery

SQL>
Select Status from v$instance;

SQL>
Select
file#,
status,
error,
recover,
tablespace_name,
name
from
v$datafile_header;
SQL>
Select
r.file# as df#,
d.name as df_name,
t.name as tbsp_name,
d.status,
r.error,
r.change#,
r.time
from
v$recover_file r,
v$datafile d,
v$tablespace t
where
t.ts# = d.ts# and
d.file# = r.file#;

### validating backed up database files
Rman>
Rest or e val i dat e;
Rest or e dat abase val i dat e;

### recovering full db
Rest or e dat abase;
Recover dat abase;

Recover dat abase
# opt i onal l y, del et e l ogs r est or ed f or r ecover y and l i mi t di sk space used
Del et e ar chi vel og maxsi ze 100M
# opt i onal l y, ski p t he r ecover y of some t abl espaces
Ski p t abl espace hi st or y;

Recover dat abase [ del et e ar chi vel og [ maxsi ze=1G] ] ;

### incomplete recovery
r un
{
set unt i l t i me ' Nov 15 2001 09: 00: 00' ;
# you can use unt i l cl ause wi t h r est or e or r ecover commands
# r est or e unt i l sysdat e- 7 ;
# r ecover unt i l sysdat e- 7 ;
# al t er nat i vel y, you can speci f y SCN
# set unt i l scn 1000;
# al t er nat i vel y, you can speci f y l og sequence number
# set unt i l sequence 9923;

6|P a g e

r est or e dat abase;


r ecover dat abase;
sql al t er dat abase open r eset l ogs ;
}

### recovering partial db
sql ' al t er t abl espace <t s_name> of f l i ne i mmedi at e' ;
r est or e t abl espace <t s_name>;
r ecover t abl espace <t s_name>;
sql ' al t er t abl espace <t s_name> onl i ne;

### recovering spfile
Rman>
St ar t up f or ce nomount ; # f or ce because spf i l e i s l ost
Rest or e spf i l e; # i f you ar e usi ng a cat al og
Rest or e spf i l e f r omaut obackup; # i f i n NOCATALOG mode
Rest or e spf i l e t o / t mp/ spf i l e<SI D>. or a [ f r omaut obackup] ;
Rest or e spf i l e t o pf i l e / t mp/ spf i l e<SI D>. or a [ f r omaut obackup] ;

### restoring controlfile from auto backup
Rman>
Rest or e cont r ol f i l e f r omaut o backup; - - can be r un i n nomount mode


### restoring controlfile and a database
Rman>
# open wi t h no cont r ol f i l e
St ar t up nomount ;
# i f you dont use r ecover y cat al og or you have mor e t han one dat abase wi t h
# t he same dbname
set dbi d <sel ect dbi d f r omv$dat abase>
# speci f y a nondef aul t aut obackup f or mat onl y i f r equi r ed
Set cont r ol f i l e aut obackup f or mat f or devi ce t ype di sk t o ?/ t mp/ %F. ct l ;
Rest or e cont r ol f i l e [ f r omaut obackup] [ maxdays 180] ;
# mount dat abase
Al t er dat abase mount ;
# r est or e dat abase
Rest or e dat abase;
Recover dat abase;
# open wi t hy r eset l ogs bease cont r ol f i l e i s f r ombackup
Al t er dat abase open r eset l ogs;
# dont f or get t o add t emp f i l es
SQL al t er t abl espace t emp add t empf i l e ?/ or adat a/ dbname/ t emp01. dbf
r euse ;

# backup t he dat abase
Shut down i mmedi at e;
St ar t up mount ;
Backup dat abase;
Al t er dat abase open;

### restoring to a new location
### restoring datafiles to a new location
r un
{
sql ' al t er t abl espace user s of f l i ne i mmedi at e' ;
sql ' al t er t abl espace t ool s of f l i ne i mmedi at e' ;
# r est or e t he dat af i l e t o a new l ocat i on
set newname f or dat af i l e ' ?/ t r gt / user s01. dbf ' t o ' / t mp/ user s01. dbf ' ;
set newname f or dat af i l e ' ?/ t r gt / t ool s01. dbf ' t o ' / t mp/ t ool s01. dbf ' ;
r est or e t abl espace user s, t ool s;
7|P a g e

# poi nt cont r ol f i l e t o new f i l enames


swi t ch dat af i l e al l ;
r ecover t abl espace user s, t ool s;
sql ' al t er t abl espace user s onl i ne;
sql ' al t er t abl espace t ool s onl i ne;
}

Rman>
Set newname f or dat af i l e ?/ or adat a/ dbn/ t ool s01. dbf t o / t mp/ t ool s01. dbf ;
Rest or e dat af i l e ?/ or adat a/ dbname/ t ool s01. dbf ;

Rman>
Swi t ch dat af i l e / t mp/ t ool s01. dbf t o dat af i l ecopy <new dbf name> ;

### restoring controlfile to a new location
r un
{
# t o r est or e a cont r ol f i l e cr eat ed bef or e a cer t ai n dat e, i ssue t he
# f ol l owi ng
# set command usi ng a val i d dat e f or ' date_string' . you can al so speci f y
# an scn or l og sequence number .
# set unt i l t i me = ' date_string' ;
r est or e cont r ol f i l e t o ' / t mp/ cont r ol 01. ct l ' ; # r est or e t o new l ocat i on
# r epl i cat e t he cont r ol f i l e manual l y t o cont r ol _f i l es l ocat i ons
r est or e cont r ol f i l e f r om' / t mp/ cont r ol 01. ct l ' ;
st ar t up mount ;
}

### restoring archivelogs to a new location
r un
{
set ar chi vel og dest i nat i on t o ' / or acl e/ t emp_r est or e' ;
r est or e ar chi vel og al l ;
# r est or e and r ecover dat af i l es as needed
}

r un
{
# set a new l ocat i on f or l ogs 1 t hr ough 10.
set ar chi vel og dest i nat i on t o ' / t mp' ;
r est or e ar chi vel og f r omsequence 1 unt i l sequence 10;
# set a new l ocat i on f or l ogs 11 t hr ough 20.
set ar chi vel og dest i nat i on t o ' ?/ or adat a' ;
r est or e ar chi vel og f r omsequence 11 unt i l sequence 20;
# set a new l ocat i on f or l ogs 21 t hr ough 30.
set ar chi vel og dest i nat i on t o ' ?/ dbs' ;
r est or e ar chi vel og f r omsequence 21 unt i l sequence 30;
r est or e ar chi vel og f r omt i me ' sysdat e- 20' unt i l t i me ' sysdat e- 19' ;
r est or e ar chi vel og f r omt i me t o_dat e( 20. 02. 2008 , DD. MM. YYYY HH24: MI : SS )
unt i l t i me t o_dat e( 22. 02. 2008 , DD. MM. YYYY HH24: MI : SS ) ;

# r est or e and r ecover dat af i l es as needed
}

### performing disaster recovery
### 1
# St ar t RMAN and connect t o t he t ar get dat abase
%r man TARGET SYS/ or acl e@t r gt

# set t he DBI D f or t he t ar get dat abase
set dbi d 676549873;
st ar t up f or ce nomount ; # r man st ar t s i nst ance wi t h dummy par amet er f i l e
8|P a g e

r un
{
al l ocat e channel t 1 devi ce t ype sbt ;
r est or e spf i l e f r omaut obackup;
}
st ar t up f or ce nomount ;

r un
{
# manual l y al l ocat e a channel t o t he medi a manager
al l ocat e channel t 1 devi ce t ype sbt ;
# r est or e an aut obackup of t he cont r ol f i l e. t hi s exampl e assumes t hat
you have
# accept ed t he def aul t f or mat f or t he aut obackup name.
r est or e cont r ol f i l e f r omaut obackup;
# t he set unt i l command i s used i n case t he dat abase
# st r uct ur e has changed i n t he most r ecent backups, and you wi sh t o
# r ecover t o t hat poi nt - i n- t i me. n t hi s way r man r est or es
# t he dat abase t o t he same st r uct ur e t hat t he dat abase had at t he
speci f i ed t i me.
set unt i l sequence 1124 t hr ead 1;
al t er dat abase mount ;
r est or e dat abase;
r ecover dat abase;
}
al t er dat abase open r eset l ogs; # r eset t he onl i ne l ogs af t er r ecover y
compl et es

### 2
r un
{
# i f you need t o r est or e t he f i l es t o new l ocat i ons, t el l r ecover y
# manager
# t o do t hi s usi ng set newname commands:
set newname f or dat af i l e 1 t o ' / dev/ vgd_1_0/ r l vt 5_500m_1' ;
set newname f or dat af i l e 2 t o ' / dev/ vgd_1_0/ r l vt 5_500m_2' ;
set newname f or dat af i l e 3 t o ' / dev/ vgd_1_0/ r l vt 5_500m_3' ;
al l ocat e channel t 1 devi ce t ype sbt ;
r est or e cont r ol f i l e f r omaut obackup;
set unt i l sequence 124 t hr ead 1;
al t er dat abase mount ;
r est or e dat abase;
# updat e t he cont r ol f i l e wi t h new l ocat i on of t he dat af i l es.
swi t ch dat af i l e al l ;
r ecover dat abase;
}
al t er dat abase open r eset l ogs;

### blockrecover command
bl ockr ecover dat af i l e 8 bl ock 13 dat af i l e 2 bl ock 19;
# r est or e f r ombackupset
bl ockr ecover dat af i l e 8 bl ock 13 dat af i l e 2 bl ock 19 f r ombackupset ;
# r est or e f r omdat af i l e i mage copy
bl ockr ecover dat af i l e 8 bl ock 13 dat af i l e 2 bl ock 19 f r omdat af i l ecopy;
# r est or e usi ng backups made bef or e one week ago
bl ockr ecover dat af l e 8 bl ock 13 dat af l e 2 bl ock 19 r est or e unt i l
' sysdat e- 7' ;
# r est or e usi ng backups made bef or e scn 100
bl ockr ecover dat af i l e 8 bl ock 13 dat af i l e 2 bl ock 19 r est or e unt i l scn 100;
# r est or e usi ng backups made bef or e l og sequence 7024
9|P a g e

bl ockr ecover dat af l e 8 bl ock 13 dat af l e 2 bl ock 19 r est or e unt i l sequence


7024;

# r ecover t he r ecor ds i n v$dat abase_bl ock_cor r upt i on
bl ockr ecover cor r upt i on l i st
f r ombackupset
r est or e unt i l t i me ' sysdat e- 10' ;

thev$dat abase_bl ock_cor r upt i onviewindicateswhichblocksinadatafileweremarked
corruptsincethemostrecentbackup,backup. . . val i dat e,orcopycommandwasrun.aftera
corruptblockisrepaired,therowidentifyingthisblockisdeletedfromtheview.

ahistoricalrecordofblockcorruptionsinrmanbackupsandcopiesiskeptin
v$backup_cor r upt i onandv$copy_cor r upt i on.


10|P a g e


Others:


SQL al t er t abl espace t ool s of f l i ne i mmedi at e ;
SQL al t er t abl espace t ool s onl i ne ;


I f usi ng Cat al og;

Cr eat e scr i pt <scr i pt _name>
{
Backup
I ncr ement al l evel 0
Tag backup_whol e_10
Fi l eper set 6
Dat abase pl us ar chi vel og;
#comment out
}

Backup as compr essed backupset t abl espace syst em, sysaux t ag=syst em_backup;
Del et e backupset t ag=syst em_backup;

Run
{
Execut e scr i pt <scr i pt _name>;
}

Sql pl us r man/ pass@cat ;
Sel ect * f r omr c_st or ed_scr i pt ;


Resync cat al og;
Al t er syst emset cont r ol f i l e_r ecor d_keep_t i me=7; #def aul t 7

Conf i gur e r et ent i on pol i cy t o r ecover y wi ndow of 7 days;


Conf i gur e r et ent i on pol i cy t o r edundancy 2;
Conf i gur e r et ent i on pol i cy t o none; ### no set t i ngs
Conf i gur e r et ent i on pol i cy cl ear ; ### t o def aul t set t i ngs

Show r et ent i on pol i cy;

Cr osscheck backup;
Cr osscheck backup of dat abase;
Cr osscheck copy [ of dat abase| t abl espace| dat af i l e] ;

Repor t obsol et e;
Repor t obsol et e r edundancy 2;
Del et e obsol et e;
Del et e expi r ed;
Del et e f or ce;

Del et e backupset 4;
Del et e ar chi vel og al l backed up 2 t i mes t o devi ce t ype di sk;
Del et e copy of dat af i l e 6 t ag f i l e6_ext r a;

Cat al og dat af i l ecopy <pat h_t o_t he copi ed_dat af i l e> ;

Change backupset 231 nokeep | keep;
11|P a g e

Change backupset 231 avai l abl e | unavai l abl e;


Change backupset 231 nol ogs;
Change backupset t ag <t ag_name> nokeep;
Change backupset 231 uncat al og | cat al og;

### system views
V$backup_f i l es;
V$backup_set ;
V$backup_spf i l e;
V$r man_conf i gur at i on;
V$backup_dat af i l e;
V$backup_cor r upt i on;
V$copy_cor r upt i on;
V$backup_devi ce;

V$dat abase_bl ock_cor r upt i on;
V$backupset ;
v$ar chi ved_l og
v$backup_r edol og
v$backup_pi ece

l ar ge pool
backup r est or e oper at i ons
I / O ser ver pr ocesses
Sessi on memor y f r o shar ed user s
Lar ge_pool _si ze ( appr oxi mat el y 2gb)

Rman
dbwr _i o_sl aves ( i nt eger )
backup_t ape_i o_sl aves ( t r ue| f al se)

### snapshot controlfile
Show snapshot cont r ol f i l e name;
Conf i gur e snapshot cont r ol f i l e name t o / t mp/ cont r ol f i l e_snapshot . ct l ;
Conf i gur e snapshot cont r ol f i l e name cl ear ;

### validating backups and backupsets
r est or e cont r ol f i l e val i dat e;
r est or e t abl espace syst emval i dat e;
r est or e ar chi vel og al l val i dat e;

l i st backupset ;
l i st copy;
l i st backup of cont r ol f i l e;
l i st backup of ar chi vel og
f r omt i me " t o_dat e( ' 16. 01. 2008' , ' DD. MM. YYYY' ) "
unt i l t i me " t o_dat e( ' 17. 01. 2008' , ' DD. MM. YYYY' ) " ;

val i dat e backupset 1121;

conf i gur e backup opt i mi zat i on on| of f ;
show backup opt i mi zat i on;
show dat af i l e backup copi es;

r epor t schema;
r epor t need backup; - - f i l es need backup
r epor t unr ecover abl e;
r epor t need backup i ncr ement al 3 [ dat abase] ;
12|P a g e

r epor t need backup days 3;


r epor t need backup days 3 [ t abl espace <t s_name> ] ;
r epor t need backup r edundancy 3;

change dat af i l ecopy . . . unavai l abl e;
change backup of cont r ol f i l e unavai l abl e | avai l abl e;
change copy of ar chi vel og sequence bet ween 230 and 240 unavai l abl e;

change . . . keep | nokeep;

change backupset 123 keep f or ever nol ogs;
change dat af i l e copy . . . keep unt i l sysdat e + 60 ;


### environment variables and instance parameters
#expor t nl s_dat e_f or mat =dd- mm- yy hh24: mi : ss
#expor t NLS_LANG=amer i can_amer i ca. we8i so8859p9
SQLPLUS> show par amet er cont r ol _f i l e_r ecor d_keep_t i me
SQLPLUS> show par amet er db_r ecover y_f i l e_dest
SQLPLUS> show par amet er db_r ecover y_f i l e_dest _si ze

### minimize load | time
RMAN> Backup as compr essed backupset f or mat / or adat a/ backup/ %d_%u. dbf
dur at i on 8: 00 mi ni mi ze [ t i me | l oad] f i l eper set 1 dat abase;

### enabling block change tracking
SQL> Al t er dat abase enabl e bl ock change t r acki ng usi ng f i l e
/ or adat a/ backup/ change_t r acki ng. dbf ;
SQL> sel ect * f r omv$bl ock_change_t r acki ng;


13|P a g e



Example Scripts:


Backup cont r ol f i l e

r un
{
Al l ocat e channel dev1 t ype di sk f or mat c: \ backup\ %u ;
backup cur r ent cont r ol f i l e;
}


r ecover usi ng backup cont r ol f i l e ( st ar t up mount )

r un
{
al l ocat e channel dev1 t ype di sk;
r est or e cont r ol f i l e;
al t er dat abase mount ;
r est or e dat abase;
r ecover dat abase;
sql al t er dat abase open r eset l ogs;
}

backup al l dat af i l es and cont r ol f i l e

r un
{
al l ocat e channel dev1 t ype di sk;
backup f ul l t ag = f ul l backup dat abase i ncl ude cur r ent cont r ol f i l e f or mat = c. . ;
r el ease chanel dev1;
}

r est or e because of mi ssi ng f i l e ( f i r st mount t he dat abase and r un r man)

r un
{
al l ocat e channel dev1 t ype di sk;
r est or e dat abase;
r ecover dat abase;
}

restore until time
- - set unt i l t i me must mat ch wi t h t he var i abl e NLS_DATE_FORMAT

r un
{
#sql al t er sessi on set nl s_dat e_f or mat = dd- mm- yyyy hh24: mi : ss ;
#set unt i l t i me 01- 05- 2008 08: 00: 00
set unt i l t i me May 1 2000 08: 00: 00 ;
al l ocat e channel dev1 t ype di sk;
shut down abor t ;
st ar t up mount ;
r est or e cont r ol f i l e;
al t er dat abase mount ;
r est or e dat abase;
r ecover dat abase;
sql al t er dat abase open r eset l ogs ;
}

pur ge obsol et e backups

r epor t obsol et e r edundancy 3 devi ce t ype di sk;
r epor t obsol et e or phan; / / use t hi s r epor t t o f i l l xxx bel ow

r un
{
al l ocat e channel f or mai nt enance t ype di sk;
al l ocat e channel f or del et e t ype di sk;
14|P a g e

change backuppi ece c: \ backup\ xxx del et e;


r el ease channel ;
}




backup al l ar chi ve l ogs

r un
{
al l ocat e channel dev1 t ype di sk f or mat c\ backup\ %u ;
backup ar chi vel og al l [ del et e i nput | ski p i naccessi bl e] ;
}

par al l el i zat i on

r un
{
al l ocat e channel c1 t ype sbt ;
al l ocat e channel c2 t ype sbt ;
al l ocat e channel c3 t ype sbt ;
backup
i ncr ement al l evel 0
f or mat . . .
( dat af i l e 1, 4, 5 channel c1 t ag=DF1)
( dat af i l e 2, 3, 9 channel c1 t ag=DF2)
( dat af i l e 6, 7, 8 channel c1 t ag=DF3) ;
al t er syst emar chi ve l og cur r ent ;
};


***

r un
{
al l ocat e channel c1 t ype di sk;
al l ocat e channel c2 t ype di sk;
set unt i l t i me = 2000- 12- 09: 11: 44: 00 ;
r est or e dat abase;
r ecover dat abase;
al t er dat abase open r eset l ogs;
}

r un
{
set unt i l sequence 120 t hr ead 1;
al t er dat abase mount ;
r est or e dat abase;
r ecover dat abase; / / r ecover s t hr ough l og 119
al t er dat abase open r eset l ogs;
}

Run
{
Al l ocat e channel t 1 t ype sbt _t ape;
Al l ocat e channel t 2 t ype sbt _t ape;
Backup copy of dat abase del et e i nput ;
Backup ar chi vel og al l del et e al l i nput ;
Rel ease channel t 1;
Rel ease channel t 2;
Al l ocat e channel d1 t ype di sk;
Al l ocat e channel d2 t ype di sk;
Backup as copy dat abase;
Rel ease channel d1;
Rel ease channel d2;
}


select * from v$backup_piece where trunc(start_time)=trunc(ysdate-1)

select
t1.file#, t2.name, t1.incremental_level, t1.datafile_blocks, t1.blocks, t1.block_size,
t1.completion_time
15|P a g e

from v$backup_datafile t1 LEFT JOIN v$datafile t2 ON (t1.file# = t2.file#) where


trunc(t1.completion_time)=trunc(sysdate-1)

select count(*) from v$datafile
16|P a g e



10g enhancement s

RUN {
# Set t he def aul t channel conf i gur at i on. Not e t he use of t he
# %U di r ect i ve t o i nsur e uni que f i l e names f or t he i mage copi es
ALLOCATE CHANNEL dbkp1 DEVI CE TYPE DI SK FORMAT ' c: \ or acl e\ r manbkup\ U%' ;

# Cr eat e an i mage copy of al l dat af i l es i n t he dat abase
BACKUP AS COPY DATABASE;
}



OracleError:ORA19590:conversationalreadyactive

Cause:Youtriedtobeginabackuporrestoreconversation,butanotherconversationisalreadyactiveinthissession.

Action:Eithercontinuethecurrentconversation,orcallbackupCancelorrestoreCanceltoendthecurrentconversationbeforestartinga
newone

You might also like