Database Refresh using RMAN

Database Refresh using RMAN


Duplicate command based on SCN
find the SCN from PRD database
 
#!/usr/bin/ksh
export ORAENV_ASK='NO'
export ORACLE_SID=PRD
/usr/local/bin/oraenv

export NLS_LANG=American_america.us7ascii;
export NLS_DATE_FORMAT="Mon DD YYYY HH24:MI:SS";

$ORACLE_HOME/bin/rman target / nocatalog log=/tmp/duplicate_tape_TEST.log <<EOF
connect auxiliary
sys/PASSWORD@TEST;
run
{
allocate auxiliary channel aux1 device type disk;
set until SCN 42612597059;
duplicate target database to "TEST" pfile='/u01/app/xxxx/product/10.2.0/db_1/dbs/initTEST.ora' NOFILENAMECHECK;
}
EOF
mailx -s "PRD_Tape to TEST duplication result" "
hello@gmail.com.au" < /tmp/duplicate_tape_TEST.log

Duplicate command based on data and time

#!/usr/bin/ksh
export ORAENV_ASK='NO'
export ORACLE_SID=PRD
. oraenv

export NLS_LANG=American_america.us7ascii;
export NLS_DATE_FORMAT="Mon DD YYYY HH24:MI:SS";

$ORACLE_HOME/bin/rman target / nocatalog log=/tmp/duplicate_TEST.log <<EOF
connect auxiliary
sys/PASSWORD@TEST;
run
{
allocate auxiliary channel aux1 device type disk;
set until time 'Jan 14 2011 01:00:00';
duplicate target database to "ASIAMI" pfile='/u01/app/xxx/product/10.2.0/db_1/dbs/initTEST.ora' NOFILENAMECHECK;
}
EOF
mailx -s "PRD to TEST duplication result" "
HELLO@gmail.com" < /tmp/duplicate_TEST.log

Restore command until time

#!/usr/bin/ksh
. ~/.profile
export ORAENV_ASK='NO'
export ORACLE_SID=TEST
. oraenv
cd u02/test/scripts
export NOW=`date +"%Y%m%d%H%M"`


export NLS_LANG=American_america.us7ascii;
export NLS_DATE_FORMAT="Mon DD YYYY HH24:MI:SS";

#restore TEST to 'Aug 23 2010 07:00:00'
db_restore() {
$ORACLE_HOME/bin/rman target / nocatalog log =/u01/app/XXX/admin/TEST/logs/TESTrestore.$NOW.log <<EOF
run
{
allocate channel c1 device type disk;
SET UNTIL TIME 'Aug 23 2010 07:00:00';
RESTORE DATABASE;
RECOVER DATABASE;
}
EOF
}

#Send email after restore is done
email_result(){
mailx -s "TEST restore result" "
hello@gmail.com.au" < /u01/app/xxx/admin/TEST/logs/TESTrestore.$NOW.log
}

#execute function
db_restore
email_result

 

Comments

Popular posts from this blog

QUERY DATAGUARD AND STANDBY STATUS

Blocking session on RAC database

Finding object size in Oracle database