Posted in RMAN

RMAN additional Logging for Partial or complete restore

Its always tough to get the backups restored from TAPE to DISK  ,incase of any restore or recovery ( specifically when backups are done as Backupset Backup).

General process would be to ask Netbackup( in my case)  admin to restore backups as on <DATE> from Tape to disk and build an auxiliary instance from backup restored. And its DBA who need to ask Netbackup (in my case )  admin to restore required files.

So , in order to ease such job, oracle has provided a functionality  i.e

RESTORE <DATABASE/TABLESPACE> PREVIEW;

I have added this additional info into my backup script , so that I will be having all the required backup piece ,controlfile and archive log info , incase of any restore or recover.

Below is additional shell script I have added to existing backup script to make life easier.

 

NOTE: Since my environment is Multi-tenant , I would get requirement to restore certain schema ( a single or set of tablespaces) . So I have written script to fetch backup info for each tablespace.

tbs=$(sqlplus -s / as sysdba <<DOIT
set heading off
set feedback off
set lines 10000
set pagesize 10000
select tablespace_name from dba_tablespaces;
DOIT
exit)

for i in $tbs ; do echo “restore controlfile preview;restore tablespace ‘$i’ preview;”| NLS_DATE_FORMAT=’yyyymmddhh24miss’ rman target /| awk -v tbs=$i ‘
/Finished restore at /{timestamp=$4}
/Recovery must be done beyond SCN /{if ($7>scn) scn=$7 }
/^ *(Piece )Name: / { sub(/^ *(Piece )Name: /,””); files[$0]=1 }
END{ for (i in files) print i > “files-“timestamp”-SCN-“scn”-“tbs”.txt” } ‘ ;
done

startscn=`echo “restore controlfile preview;”| NLS_DATE_FORMAT=’yyyymmddhh24miss’ rman target /| awk ‘
/Recovery must be done beyond SCN /{if ($7>scn) scn=$7 }
END {print scn}’;`

echo “restore archivelog from scn “$startscn” preview;” | NLS_DATE_FORMAT=’yyyymmddhh24miss’ rman target /| awk -v scn=$startscn ‘
/Finished restore at /{timestamp=$4}
/Name:/{sub(/Name:/,””);gsub(/^[ \t]+|[ \t]+$/, “”); files[$0]=1}
END {for(i in files) print i > “Archivefiles-“timestamp”-SCN-“scn”.txt” }’ ;
exit
#End of the script

 

 

hope it helps…..

 

 

Advertisements