OraMatt: YABAOracle

Yet Another Blog About Oracle

Quick backups with ZFS Storage Appliance

I started messing around with ZFS storage with the Oracle ZFS Storage Simulator found here (http://www.oracle.com/technetwork/server-storage/sun-unified-storage/downloads/sun-simulator-1368816.html).

Pretty cool stuff!!!

——————————————————————————


#!/bin/sh
#################
#
# Author:
#      Matt D
#	
#
# Purpose:
#	Hot backup of Oracle Database with ZFS Snapshots
#
#
# References:
#  http://www.oracle.com/technetwork/articles/systems-hardware-architecture/backup-recovery-db7k-184420.pdf
#
#################
#


# Set up the environment
SCRIPT_HOME=`pwd`;export SCRIPT_HOME
ORACLE_HOME=$ORACLE_HOME;export ORACLE_HOME
TIMESTAMP=`date +%m_%d_%y_%H_%M`; export TIMESTAMP

# Need to get/set some Info
#echo "Please enter your Oracle SID> "
#read USID
#echo "Please enter the hostname or IP of your Sun ZFS Storage> "
#read OPENSTORE
#echo "Please enter the Sun ZFS Project> "
#read PROJECT
#echo "Please enter the Sun ZFS share to snapshot> "
#read SHARE
#echo "Please enter the mount point on the server> "
#read SVRMNT


USID=thor;export USID
OPENSTORE=sunstore;export OPENSTORE
PROJECT=ORACLE_DB;export PROJECT
SHARE=11g_data;export SHARE
SVRMNT=/oracle/data;export SVRMNT

# Set Oracle SID
ORACLE_SID=$USID;export ORACLE_SID


# Create the backup script

echo "script EOF" >$SCRIPT_HOME/orabk
echo "run('shares select $PROJECT'); ">>$SCRIPT_HOME/orabk
echo "run('select $SHARE'); " >>$SCRIPT_HOME/orabk
echo "run('snapshots snapshot hotbackup_$TIMESTAMP'); ">>$SCRIPT_HOME/orabk
echo "run('commit');" >>$SCRIPT_HOME/orabk

clear 
echo "#################"
echo "Snapshot Script"
echo "#################"

cat orabk
# sleep 15

echo ""
sqlplus "sys/oracle as sysdba" << EOF
create pfile from spfile;
alter system archive log current;
alter database backup controlfile to trace;
alter database begin backup;
EOF


echo "#################"
echo "Start of ZFS Backup"
echo "#################"


ssh $OPENSTORE -T <orabk


echo "#################"
echo "ZFS Backup Done"
echo "#################"

sqlplus "sys/oracle as sysdba" << EOF
alter database end backup;
alter system archive log current;
EOF


echo "#################"
echo "List the snapshots"
echo "#################"

ls -ltha $SVRMNT/.zfs/snapshot

Leave a comment

Navigation

About

I’m Matt and I do Oracle things.