PDF00075_Great Tips on Table Recovery with RMAN Backup
PDF00075_Great Tips on Table Recovery with RMAN Backup
M ost database administrators face the scenario when they have to recover some specific table
that dropped/truncated during a RMAN backup. Most of the times the goal is to recover a single
table and not all objects in the tablespace.
Suppose our target database is on host A and we want to restore the database on host B. Both
of them have different directory structures. The table to be recovered is named MYTABLE and is
located on MYTABLESPACE tablespace. Also we do not want ORACLE_SID to be changed for
restored database. The steps required to recover the MYTABLE table are discussed as follows.
First of all we need to backup the controlfile and move all archived logs to host B. The archive
logs will be from the time you performed the backup.
Datafile Locations:
The file number and location of datafile will be changed on host B. Therefore you need to keep
track of the file numbers and names on host A. You can retrieve this information by running
below command.
file# name
—– ————————————————
1 /oracle/orcl/oradata/system01.dbf
2 /oracle/ orcl/oradata/users.dbf
3 /oracle/orcl/oradata/undo01.dbf
4 /oracle/orcl/oradata/tools01.dbf
5 /oracle/orcl/oradata/mytable01.dbf
6 /oracle/orcl/oradata/mytable02.dbf
7 /oracle/orcl/oradata/undo02.dbf
8 /oracle/orcl/oradata/rcvcat.dbf
Locating backups:
The backup sets must be located in the same directory where it was written during backup. For
disk backups you either set up an NFS directory mounted on both host A and B or you can use
symbolic links on host B.
Make sure that init.ora is available on host B including any location specific parameters such as
ifile, log_archive_dest*, *_dump_dest or control file backup taken on Host A.
http://www.articles.freemegazone.com/table-recovery-rman-backup.php
You must set up a password file for duplicated database in order to allow RMAN remote
connections.
Database Recovery:
Now you need to perform below steps on Host B in order to recover the database.
You can use RMAN for changing datafiles location from the location on host A to host B. However
it is necessary to restore both undo tablespaces if you keep switching between two undo
tablespaces in your database.
RMAN> run {
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
set newname for datafile 1 to ‘/oracle/datafiles/system01.dbf';
set newname for datafile 3 to ‘/oracle/datafiles/undo01.dbf';
set newname for datafile 5 to ‘/oracle/datafiles/mytable01.dbf';
set newname for datafile 6 to ‘/oracle/datafiles/mytable02.dbf';
set newname for datafile 7 to ‘/oracle/datafiles/undo02.dbf';
restore tablespace SYSTEM;
restore tablespace UNDOTBS1;
restore tablespace MYTABLESPACE;
switch datafile all;
}
Now you will perform incomplete recovery. Instead of restoring whole database backup you can
save space and time by making offline tablespaces datafiles that need not to be restored such as
datafiles other than SYSTEM, UNDOTBS1 and MYTABLESPACE.
Apply the archived redo log files to the point just before the table was dropped. Once you have
required archived redo log files in the log_archive_dest directory then you can stop the recovery
process by typing cancel at the prompt.
Before opening the database you must rename the logfiles by issuing below command.
http://www.articles.freemegazone.com/table-recovery-rman-backup.php
Finally you can query the table MYTABLE to find out the data. If your required table is recovered
then you can export the table and import it to your target database.
http://www.articles.freemegazone.com/table-recovery-rman-backup.php