##############################################################################
#
# airollfwd.sh
#
# This
shell rolls forward the after-image files that are located in the
# LOCALAPPLYDIR directory
and then moves them to the STOREDIR directory
#
# Parameters:
#
# $1 Warm spare database
directory - REQUIRED
# $2 Warm spare database
name - REQUIRED? SHOULD
NOT INCLUDE THE .db EXTENSION
#
###############################################################################
DBDIR=$1
DBNAME=$2
LOCALAPPLYDIR=/usr/dbx/ai_apply
STOREDIR=/usr/dbx/ai_store
chk_order()
{
for TMPFILE in `ls *$DBNAME.* 2>/dev/null`
do
? AIFILE_N=`echo $AIFILE | cut -f2 -d.`
? TMPFILE_N=`echo $TMPFILE | cut -f2 -d.`
? if [ $TMPFILE_N -lt $AIFILE_N ]
? then
??? echo $TMPFILE
should apply before $AIFILE
??? exit 4
? fi
done
}
# 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 warmspare database directory does not exist.? Aborting roll
forward."
??? return -1
fi
if [ ! -f $DBDIR/${DBNAME}.db ]
then
??? echo "Could
not find the warmspare database " $DBNAME "
in " $DBDIR ".? Aborting roll forward."
??? return -1
fi
if [ ! -d $LOCALAPPLYDIR
]
then
??? echo "The
warm spare hold directory does not exist.?
Aborting roll forward."
??? return -1
fi
#############################
#
#############################
AIAPPLIED=0
RUNDATE=`/usr/bin/date "+%m/%d/%y %H:%M:%S"`
cd $LOCALAPPLYDIR
# Step 1. Check that previous roll
forward process finished.
if [ -f PROC_${DBNAME}* ]
then
? exit 1
fi
# Step 2. Unzip files.
for AIFILE in `ls $DBNAME.*gz 2>/dev/null`
do
??? cp $AIFILE
$STOREDIR
??? if [ $? != 0 ]
??? then
?????? echo $RUNDATE
$PPID $AIFILE "ERROR. Could not copy $AIFILE to $STOREDIR."
?????? exit 2
??? fi
??? gzip
-d $AIFILE
??? if [ $? != 0 ]
??? then
?????? echo $RUNDATE
$PPID $DBDIR $DBNAME $AIFILE "ERROR. Could not unzip $AIFILE."
?????? exit 2
??? fi
done
# Step 3. Check that previous roll
forward process finished again.
if [ -f PROC_${DBNAME}* ]
then
? exit 1
fi
# Step 4. Apply AI.
for AIFILE in `ls $DBNAME.* 2>/dev/null`
do
??? echo $AIFILE | grep '\.gz' >/dev/null
??? if [ $? = 0 ]
??? then
????? exit
??? fi
??? if [ -f
PROC_${DBNAME}_backup ]
??? then
????? echo $RUNDATE
$PPID Now we need to do a backup of $DBNAME
????? exit
??? fi
??? # Check that files are not out of order
??? chk_order
??? RUNDATE=`/usr/bin/date
"+%m/%d/%y %H:%M:%S"`
??? echo $RUNDATE
$PPID Processing $AIFILE
??? ls
-l $DBNAME.*
??? mv
$AIFILE PROC_$AIFILE
??? if [ $? != 0 ]
??? then
?????? echo $RUNDATE
$PPID "Could not move " $AIFILE
?????? ls
-l $DBNAME.*
?????? exit
??? fi
??? $DLC/bin/rfutil
$DBDIR/$DBNAME -C roll forward -a PROC_$AIFILE >/dev/null
??? if [ $? != 0 ]
??? then
??????? echo $RUNDATE
$PPID $DBDIR $DBNAME $AIFILE "ERROR.?
Could not roll forward this extent"
??????? exit 3
??? fi
??? rm
PROC_$AIFILE
??? AIAPPLIED=`expr
$AIAPPLIED + 1`
??? RUNDATE=`/usr/bin/date
"+%m/%d/%y %H:%M:%S"`
??? echo $RUNDATE
$PPID $AIFILE Processed
??? if [ -f
${DBNAME}.* ]
??? then
????? ls
-l $DBNAME.*
??? fi
done
if [ ! $AIAPPLIED = 0 ]
then
??? RUNDATE=`/usr/bin/date
"+%m/%d/%y %H:%M:%S"`
??? echo $RUNDATE
$PPID $AIAPPLIED $DBNAME "extents applied to" $DBDIR/$DBNAME
fi
# Step 5. Remove old ai files from STOREDIR
if [ -d ${STOREDIR} ]
then
? find
${STOREDIR}/${DBNAME}* -type f -mtime +2 -exec \rm {} \; 2>/dev/null
fi