##############################################################################

#

# aiswitch.sh

#

# This shell performs switches the after image file, copies it to the after

# image directory and to the warm spare hold directory.

#

# Parameters:

#

# $1 Database directory - REQUIRED

# $2 Database name - REQUIRED? SHOULD NOT INCLUDE THE .db EXTENSION

#

###############################################################################

 

DBDIR=$1

DBNAME=$2

AI_TO_DR=${EXECDIR}/ai_to_dr

AIBACKUP=${EXECDIR}/ai_backup?????????? # Backup directory to save after-images on primary server

??????????????????????????????????????? # You can replace "mv" command in aiftp.sh script to "rm" if

# you do not want to save ai on primary server.

 

REMOTE_DIR=/some_dir/ai_apply? ?????????? # Same as LOCALAPPLYDIR in airollfwd.sh

CHILDPROCESS=${EXECDIR}/aiswitch2.sh

FTPPROCESS=${EXECDIR}/aiftp.sh

export DBDIR DBNAME AI_TO_DR AIBACKUP REMOTE_DIR

 

 

# Let's check out all the parameters and make sure we've got valid information

 

if [ $# -lt 2 ]

then

??? echo "Insufficient number of parameters.? The syntax for this command is :"

??? echo "$0 <directory> <db name> "

??? return -1

fi

 

if [ ! -d $DBDIR ]

then

??? echo "The database directory does not exist.? Aborting AI Switch"

??? return -1

fi

cd $DBDIR

 

if [ ! -f ${DBNAME}.db ]

then

??? echo "Could not find the database " $DBNAME " in " $DBDIR ".? Aborting AI switch"

??? return -1

fi

 

if [ ! -d $AI_TO_DR ]

then

??? echo "The after image directory $AI_TO_DR does not exist. Aborting."

??? return -1

fi

 

if [ ! -d $AIBACKUP ]

then

??? echo "The after image backup directory $AIBACKUP does not exist. Aborting."

??? return -1

fi

 

export RUNDATE=`/usr/bin/date "+%m/%d/%y %H:%M:%S"`

 

# Check the database status.? If it's not 16 it means that it's not online.

# This is not an error condition, hence exit with a 0 code.

 

$DLC/bin/proutil $DBDIR/$DBNAME -C holder > /dev/null

if [ $? != 16 ]

then

??? echo $RUNDATE "Server is not running for" $DBDIR/$DBNAME

??? exit 0

fi

 

 

#############################

# Step One: Copy the full after-image file(s) to the database's after

#?????????? image file directory and mark them empty

#############################

$CHILDPROCESS $DBDIR $DBNAME $AI_TO_DR

RETCODE=$?

if [ $RETCODE != 0 ]

then

??? exit $RETCODE

fi

 

#############################

# Step Two: Switch current AI

#############################

$DLC/bin/rfutil $DBDIR/$DBNAME -C aimage new > /dev/null

if [ $? != 0 ]

then

??? echo $RUNDATE $DBDIR $DBNAME "AIERROR.? Could not switch to a new AI extent"

??? exit 1

fi

 

 

#############################

# Step Three: Copy newly created full after-image file to the database's after

#?????????? image file directory and mark it empty

#############################

$CHILDPROCESS $DBDIR $DBNAME $AI_TO_DR

RETCODE=$?

if [ $RETCODE != 0 ]

then

??? exit $RETCODE

fi

 

#############################

# Step Four: Copy files to DR box

#############################

$FTPPROCESS >/dev/null

RETCODE=$?

if [ $RETCODE != 0 ]

then

??? echo "FTP failure in $0"

??? exit $RETCODE

fi

 

#############################

# Step Five: Remove old ai files from AIBACKUP

#############################

find ${AIBACKUP}/${DBNAME}* -type f -mtime +2 -exec \rm {} \;