SUMMARY: NSR backup of AdvFs clones

From: Randy Rodgers <rrodgers_at_ci.ft-wayne.in.us>
Date: Wed, 21 Aug 1996 15:00:05 -0500

I got one response. I have not had a chance to test this out, but it looks like it should work. I decided to go ahead & post this summary because I know of at least one other person who is interested.

I got the following script from Ryan R. Ziegler <zieglerr_at_novachem.com>:

#!/bin/sh
# clone_backup
# Backup SAP database using AdvFS clone sets
#
# The general strategy
# 1) shutdown SAP to flush oracle buffers to the tablespace files
# 2) make clone sets, cloneset mount points, mount the clonesets
# 3) restart SAP
# 4) backup the clone sets
# 5) unmount clonesets, remove cloneset mount points, remove clonesets
#
# Note 1) clonesets are removed as soon as the dump of that cloneset has
# completed
# 2) The /clone directory must exist before running this thing.
# 3) A 'saveindex' is done each time we do a backup. This allows us
# to rebuild the index from the latest tape in the event of 'trouble'.
#
# Tunable parameters
# SID - SID of SAP database in *upper* case
# DIRS - list of directories to be backed up
# REMOTE_INSTS - application server instances running on remote hosts
# CLONE - directory of cloneset mount points - should not have general access
# TAPE - tape drive to do backups
# DUMP - dump command to do backups

# 'unset PRINTER' to eliminate the default printing of 'saveindex' logs.
unset PRINTER

SID=C14

#
# The list of directories to be backed up.
#
DIRS="/oracle/${SID}"
DIRS="$DIRS /oracle/${SID}/sapdata1"
DIRS="$DIRS /oracle/${SID}/sapdata2"
DIRS="$DIRS /oracle/${SID}/sapdata3"
DIRS="$DIRS /oracle/${SID}/sapdata4"
DIRS="$DIRS /oracle/${SID}/sapdata5"
DIRS="$DIRS /oracle/${SID}/saparch"
DIRS="$DIRS /oracle/${SID}/sapreorg"
DIRS="$DIRS /oracle/${SID}/saplog1"
DIRS="$DIRS /oracle/${SID}/saplog2"
DIRS="$DIRS /sapmnt/${SID}"
DIRS="$DIRS /usr/sap/${SID}"
DIRS="$DIRS /usr/sap/trans"
DIRS="$DIRS /usr/local/bin"
DIRS="$DIRS /bdc"
DIRS="$DIRS /bdc_${SID}"

REMOTE_INSTS=""

#
# The /clone directory MUST exist before running this script.
# The 'tape' must be the 'no-rewind' device.
#
CLONE=/clone
TAPE=/dev/nrmt1h
HOST=`hostname`

# DUMP="tar cvf ${TAPE}"
# DUMP="vdump -0 -DN -F 64 -f ${TAPE}"
DUMP="save -L -q -l full -s ${HOST}"

PATH=/sbin:/usr/sbin:/usr/bin

sid=`echo ${SID} | tr '[A-Z]' '[a-z]'`


######################################################################
# #
# Procedures #
# #
######################################################################

# get_file_set_mount_point procedure
# return a list of mountpoint#domain#fileset for each directory in ${DIRS}
# filesets will show up in the list only once
get_fileset_mount_points() {

        df ${DIRS} 2> /dev/null | grep '#' | awk '{print $6 "#" $1}' | \
            grep -v "^${CLONE}" | sort | uniq
}


# clone procedure
# clone a fileset, create a mount point in ${CLONE}, mount the clone set there
# Parameters:
# $1 - directory mount point of fileset
# $2 - domain fileset to be cloned is in
# $3 - fileset to be cloned

clone() {
        dir=$1
        domain=$2
        fileset=$3

        echo Cloning ${fileset} in domain ${domain} mounting on ${CLONE}${dir}
        clonefset ${domain} ${fileset} clone_${fileset}
        mkdir -p ${CLONE}${dir} 2> /dev/null
        mount -t advfs "${domain}#clone_${fileset}" ${CLONE}${dir}
}


# unclone procedure
# unmount cloneset, destroy mount point in ${CLONE}, remove cloneset
# Assumes current directory is ${CLONE}, so created mount point can be removed
# Parameters
# $1 - directory mount point of fileset
# $2 - domain cloned fileset is in
# $3 - original fileset name whose clone is to be destroyed
unclone() {
        dir=$1
        domain=$2
        fileset=$3

        umount ${CLONE}${dir}
        [ $? = 0 ] && {
                rmdir -p .${dir} 2> /dev/null
                rmfset ${domain} clone_${fileset}
                echo Unmounted ${CLONE}${dir} removed cloneset ${fileset}
from domain ${domain}
        }
}


# dodump procedure
# dump a directory to tape;
# Assumes currect directory is ${CLONE}, will dump the relative path
# Parameters:
# $1 - directory to dump
dodump() {
        dumpdir=$1

        echo Dumping clone of ${dumpdir} at `date`
        ${DUMP} .${dumpdir}
        [ $? != 0 ] && {
                echo "$0: Backup of ${dumpdir} failed!!"
        }
}

# stopdb procedure
# stop the running SAP database
stopdb() {
        echo Shutting down SAP instance ${SID} at `date`
#
# application shutdown stuff goes here.
#
        }
}

# startdb procedure
# start the SAP database running
start_sap() {

#
# stuff to start the database goes here.
#
        }
}

######################################################################
# #
# Begin work here #
# #
######################################################################


####################
# 0) check to see if we are super user
####################
cd /
[ `whoami` != "root" ] && {
        echo You must be user \"root\" to run $0
        exit 1
}

####################
# 1) Shutdown SAP
####################
stopdb



####################
# 2) create clone sets
####################
echo Creating clone sets at `date`
for fs in `get_fileset_mount_points`
do
        clone `echo $fs | sed "s/#/ /g"`
done


####################
# 3) restart SAP, resume brarchive
####################
start_sap &

####################
# 4) do the backup, print statistics, remove the clone
####################
cd ${CLONE}
for fs in `get_fileset_mount_points`
do
        dodump `echo $fs | sed "s/#.*$//"`
        du -ks ${CLONE}`echo $fs | sed "s/#.*$//"`
        unclone `echo $fs | sed "s/#/ /g"`
done

####################
# 5) remove remaining clones that may have been mount points
####################
for fs in `get_fileset_mount_points | sort -k br`
do
        unclone `echo $fs | sed "s/#/ /g"`
done

saveindex -l full -s ${HOST}


echo Cloneset backups complete at `date`

exit 0

[=================================
[ Randy Rodgers
[ rrodgers_at_ci.ft-wayne.in.us
[ System Administrator
[ Allen County/City of Fort Wayne
[ Information Systems
[ (219)449-7660
[=================================
Received on Thu Aug 22 1996 - 16:03:21 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:47 NZDT