Saturday, July 31, 2010

RMAN Backup and Recovery

RMAN Backup:
Listener shld be start
#xhost +
#mkdir /u01/prd
#mkdir /u01/rmanprd
#su – oracle
$export ORACLE_SID=prd
$sqlplus / as sysdba
sys@prd>startup
sys@prd>create tablespace rman_ts datafile ‘/u01/prd/rmants1.dbf’ size 300m;
sys@prd>create user rman identified by abc default tablespace rman_ts;
sys@prd>grant connect,resource,recovery_catalog_owner to rman;
sys@prd>host
$rman target system/manager rcvcat rman/abc@prdservice
Rman>create catalog;
Rman>register database;

Full Database Backup Script
Run {
Allocate channel c1 type disk;
Backup full database filesperset 1 format ‘/u01/rmanprd/rman%s.%p’;
Release channel c1;
}

Recovery Loss of User Data file Script
Run {
Allocate channel c1 type disk;
Sql ‘alter database datafile 4 offline’;
Restore datafile 4;
Recover datafile 4;
Sql ‘alter database datafile 4 online’;
Release channel c1;
}

Recovery Loss of Control File Script
Run {
Allocate channel c1 type disk;
Restore controlfile;
Restore database;
Sql ‘alter database mount’;
Recover database;
Sql ‘alter database open resetlogs’;
Release channel c1;
}

Recovery Loss of Redo Log File Script
Run {
Allocate channel c1 type disk;
Restore database;
Recover database;
Sql ‘alter database open resetlogs’;
Release channel c1;
}