STEPS FOR RESTORING AND RECOVERING DATAFILES FROM THE RMAN TAPE BACKUP TO THE NEW FILESYSTEM.
Scenario:
There was a file system problem in DBSERVER01 and the datafiles in data/data01 got corrupted.
Solution:
1. Connect to RMAN catalog database
rman catalog rmanuser/pwd@rmancatdb.com target sys/pwd@proddb
2. Following are the datafiles that were corrupt
FILE# FILE NAME
1 /data/data01/oradata/proddb/system01.dbf
4 /data/data01/oradata/proddb/co140_idx_01.dbf
6 /data/data01/oradata/proddb/snaplogs01.dbf
16 /data/data01/oradata/proddb/CO140_6.dbf
HINT : Use the from tag option to get datafile from any other day other than latest
run{
allocate channel ‘ch1’ type ‘sbt_tape’;
set newname for datafile 1 to ‘/data11/proddb/system01.dbf’;
restore datafile 1 from tag TAG20060730T100105; — remove tag to restore latest backup
};
run{
allocate channel ‘ch1’ type ‘sbt_tape’;
set newname for datafile 4 to ‘/data11/proddb/co140_idx_01.dbf’;
restore datafile 4 from tag TAG20060730T100105;
};
run{
allocate channel ‘ch1’ type ‘sbt_tape’;
set newname for datafile 6 to ‘/data11/proddb/snaplogs01.dbf’;
restore datafile 6 from tag TAG20060730T100105;
};
run{
allocate channel ‘ch1’ type ‘sbt_tape’;
set newname for datafile 16 to ‘/data11/proddb/CO140_6.dbf’;
restore datafile 16 from tag TAG20060730T100105;
};
3. Database (where the datafiles are corrupted) will be in mount mode.
4. Rename the datafiles to point to the new filesystem where the files are restored.
alter database rename file ‘/data/data01/oradata/proddb/system01.dbf’ TO ‘/data11/proddb/system01.dbf’;
alter database rename file ‘/data/data01/oradata/proddb/co140_idx_01.dbf’ TO ‘/data11/proddb/co140_idx_01.dbf’;
alter database rename file ‘/data/data01/oradata/proddb/snaplogs01.dbf’ TO ‘/data11/proddb/snaplogs01.dbf’;
alter database rename file ‘/data/data01/oradata/proddb/CO140_6.dbf’ to ‘/data11/proddb/CO140_6.dbf’;
5. After above steps for restoring the database use the below command to apply archive logs
—to apply archive log files and recover the database
run{
allocate channel ‘ch1’ type ‘sbt_tape’;
allocate channel ‘ch2’ type ‘sbt_tape’;
recover datafile 1,4,6,16;
};
RMAN will check whether the archivelogs are present in disk first before looking for tape. If present on disk it will start applying it from there itself.
=======================================================================
STEPS FOR RESTORING AND RECOVERING THE DATAFILES FROM THE RMAN TAPE BACKUP TO THE SAME FILESYSTEM.
These are the rman scripts to restore and recover the database.
=================== proddb ==============================
Connect to the RMAN catalog
rman catalog rmanuser/pwd@rmancatdb.com target sys/pwd@proddb
Following are the datafiles that were corrupt
FILE# FILE NAME
1 /data/data01/oradata/proddb/system01.dbf
4 /data/data01/oradata/proddb/co140_idx_01.dbf
6 /data/data01/oradata/proddb/snaplogs01.dbf
16 /data/data01/oradata/proddb/CO140_6.dbf
Run the following command
run{
allocate channel ‘ch1’ type ‘sbt_tape’;
restore datafile 1 from tag TAG20060730T100105; — remove tag to restore latest backup
};
run{
allocate channel ‘ch1’ type ‘sbt_tape’;
restore datafile 4 from tag TAG20060730T100105;
};
run{
allocate channel ‘ch1’ type ‘sbt_tape’;
restore datafile 6 from tag TAG20060730T100105;
};
run{
allocate channel ‘ch1’ type ‘sbt_tape’;
restore datafile 16 from tag TAG20060730T100105;
};
After that restoration of the database use the below command to apply archive logs
—to apply archive log files and recover the database
run{
allocate channel ‘ch1’ type ‘sbt_tape’;
allocate channel ‘ch2’ type ‘sbt_tape’;
recover datafile 1,4,6,16;
};