Data guard quick catch up by RMAN incremental from SCN – script and trick

This example demonstrate how to use script automatic generate RMAN incremental backup script to sync databases. Besides it, there is a trick that address the issue it doesn’t work in sometimes.

Reference: "RMAN incremental backups can be used to synchronize a physical standby database with the primary database. Using the RMAN BACKUP INCREMENTAL FROM SCN
command, you can create a backup on the primary database that starts at
the standby database’s current SCN, which can then be used to roll the
standby database forward in time. " — Oracle manual

Script: quickCatch.sh

# make myself happy
table=’v$datafile_header’

ssh $STANDBY_DB_SERVER <<_EOF >$0.spool
export ORACLE_SID=$SID
sqlplus -S "/as sysdba" <<_PP

col checkpoint_change for 999999999999999
alter database recover managed standby database cancel;
set heading off feedback off linesize 200
select ‘checkpoint_change:’||min(checkpoint_change#) checkpoint_change from $table;
exit;
_PP
exit
_EOF

seq=`tail -1 $0.spool|awk -F’:’ ‘{if($2!="")print $2}’`

echo "backup from sequence $seq"

cat <<_EOF >$0.rman
run
{
allocate channel t1 type disk;
backup as compressed backupset incremental from scn $seq
database format=’/p01/backup/rman/quickCatchup_%U’;
backup current controlfile for standby
format=’/p01/backup/rman/quickCatchup_ctl’;
}
exit;
_EOF

echo "please run RMAN backup with cmdfile $0.rman"

exit 0

Trick: The SCN is the key, however, SQL statement in Oracle document is not always right. The select current_scn from v$database doesn’t work always, please see more details from Oracle metalink.

Advertisements

About Pang

Oracle DBA working in database, fusion middleware and identity management and cloud.
This entry was posted in Oracle database. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s