Sunday, September 29, 2013

Rman Backup Shell script

Links to this post
This is backup script to schedule in crontab.
Create three rman command file first.
These Rman commandfile will be called by Below shell script to Kick of which Type of Backup you want.

1) Full backup
2) Inremental Backup
3) Archivelog Backup

To run below backup script provide argument as

./script_name FULL|INCR|ARCH
Backup script

#!/bin/ksh
###########################################################
#######CHECK ARGUMENTS
#
if [ $# -lt 2 ] ;
then
echo "Usage :script_name ORACLE_SID FULL|INCR|ARCH POLICY"
exit
else
echo "Enough Argument Passed"
fi
###########################################################
export ALTER SESSION NLS_DATE_FORMAT='DD-MON-YYYY HH24:MI'

export ORACLE_SID=$1
echo $ORACLE_SID
if [[ $( grep -iwc "$ORACLE_SID" /etc/oratab ) -eq 1 ]]
then
echo "ORACLE SID Found"
echo "$ORACLE_SID is instance"
ORACLE_HOME=`grep -iw $ORACLE_SID /etc/oratab | cut -d ":" -f2`
TNS_ADMIN=$ORACLE_HOME/network/admin
PATH=$ORACLE_HOME/bin:$PATH
RMAN=$ORACLE_HOME/bin/rman
echo "Current Oracle Instance :-------------: $ORACLE_SID"
echo "Current Oracle Home :-----------------: $ORACLE_HOME"
echo "Current TNS admin :-------------------: $TNS_ADMIN"
echo "Current RMAN :------------------------: $RMAN"
else
echo "$ORACLE_SID" not found in Oratab file.
exit
fi
###########################################################
export BKTYPE=$2
echo $BKTYPE
case $BKTYPE in
FULL) print "\n You selected FULL DB BACKUP"
export CMD=/u01/test_disk_bkp.rcv
echo $CMD
;;
INCR) print "\n You selected Incremental Backup"
export CMD=/u01/test_disk_incr_bkp.rcv
echo $CMD
;;
ARCH) print "\n You selected Achivelog backup"
export CMD=/u01/test_disk_arch.rcv
echo $CMD
;;
*) print "\n Invalid Argument"
print " choose FULL or INCR or ARCH"
sleep 0
exit
;;
esac
###########################################################

rman  <connect target /
connect catalog rman/dummy@RMAN_CATALOG_STRING
@$CMD
exit
EOF
####################################################################################
RETURN_STATUS=$?
if [ $RETURN_STATUS = 0 ]; then
  echo "$ORACLE_SID Backup successful" | mail -s "$ORACLE_SID backup Completed"
   else
  echo "$ORACLE_SID Backup not successful" | mail -s "$ORACLE_SID backup failed"  
fi
####################################################################################

Tuesday, September 24, 2013

OGG-01028 Formatting error

Links to this post
Extract can be abend if Parameters are not Set correctly.
Extract was abend due to below Error , after searching on Metalink I found that it is considered as DB bug which fixed in 11.2.0.4.
But there is workaround.

Error
2013-09-24 04:08:30  ERROR   OGG-01028  Formatting error on: table name DUMMY.DUMMY_INQ, rowid AADYhHAHVAAJLIcAAA, XID 8.26.543865, 
position (Seqno 7314, RBA 212298768). Error converting timestamp with timezone from Oracle to ASCII format for column DUMMY_UPDATE.

Metalink Suggestion
GoldenGate extract abends: OGG-01028 Formatting error on: table name xxxx.xxxx rowid , XID nnnn.nn.nnnn, position (Seqno n, RBA n). (Doc ID 1558791.1)

Oracle GoldenGate - Version 11.2.1.0.1 and later
Information in this document applies to any platform.

This is related to database bug 15947884 (base bug 14053498).

In House WorkAround
--Add SETENV parameter before userid 
SETENV (NLS_LANG="AMERICAN_AMERICA.US7ASCII")
--Add SETENV in Extract
TRANLOGOPTIONS INCLUDEREGIONID