« May 15, 2007 | Main | June 11, 2007 »

May 18, 2007 Archives

May 18, 2007

Rman Backup scripts

Backup a complete database:

(If the target database is in archive mode, this can be done while the database is open)





RMAN>


run {                                      

# backup complete database to disk            

allocate channel c1 type disk;                

backup full                                   

tag full_db                                   

format '/usr1/ora817/test/rman/db_d.dmp'

(database);                                   

release channel c1;                           

}                                             



You can create a script and use it multiple times, so each time you
don't need to type the above script. Just make sure to drop the old
backup files.



RMAN>

create script full_db_backup {            

allocate channel c1 type disk;            

backup full database                      

format '/usr1/ora817/test/rman/db_%d.dmp';

release channel c1;                       

}                                         



This is how you run the script:



RMAN>

run { execute script full_backup ;}    





Archive logs too can be backed up along with the database in one script:



RMAN>

create script full_db_arc_backup {            

allocate channel c1 type disk;                                            

backup full database                                                      

format '/usr1/ora817/test/rman/db_%d.dmp';                                

release channel c1;                                                      

allocate channel c2 type disk format '/usr1/ora817/test/rman/arc_%d.dmp';

backup (archivelog all delete input);                                     

release channel c2;                                                       

}                                                                         



- '%d' puts database name in the backup file name.

- 'all delete input' in above script deletes all the archive logs once the backup is   

   complete, thus frees up the space.



RMAN>

run { execute script full_db_arc_backup ;}    


Recovery Scenarios Part -1

I am covering some of the basic recovery recovery scenarios via RMAN in below , this will be a 2 part series  :

Part 1:Database open, datafile deleted
Recovery Scenarios:

Note: If the database is opened with resetlogs, it is necessary to register the new incarnation of the database in the Recovery Catalog with the RESET DATABASE command.

(A) Database open, datafile deleted:

(a) Datafile recovery:

Find the datafile # and tablespace name by querying v$datafile table.

RMAN>
run {
allocate channel dev1 type disk;
sql "alter tablespace users offline immediate";
restore datafile 4;
recover datafile 4;
sql "alter tablespace users online";
release channel dev1;
}

 (b) Tablespace recovery:

RMAN>
run {
allocate channel dev1 type disk;
sql "alter tablespace users offline immediate";
restore tablespace users;
recover tablespace users;
sql "alter tablespace users online";
release channel dev1;
}
(c) SYSTEM Tablespace recovery:

Note: If it is the system tablespace datafiles to be restored, the database must be closed. It is not possible to offline the system tablespace.
SVRMGRL> shutdown immediate;
SVRMGRL> STARTUP MOUNT;

RMAN>
run {
allocate channel c1 type disk;
restore tablespace SYSTEM;
recover database;
sql "alter database open resetlogs";
release channel c1;
}
RMAN> Reset database;
(This command NOT allowed if you are NOT using Recovery Catalog)

Will post some more .............stay tunned ........

About May 2007

This page contains all entries posted to Pankaj Chandiramani's Blog in May 2007. They are listed from oldest to newest.

May 15, 2007 is the previous archive.

June 11, 2007 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle