SHIFT

--- Sjoerd Hooft's InFormation Technology ---

User Tools

Site Tools


Sidebar

Recently Changed Pages:

View All Pages


View All Tags


LinkedIn




WIKI Disclaimer: As with most other things on the Internet, the content on this wiki is not supported. It was contributed by me and is published “as is”. It has worked for me, and might work for you.
Also note that any view or statement expressed anywhere on this site are strictly mine and not the opinions or views of my employer.


Pages with comments

View All Comments

pfilebackup

Script: Bash: PFILE Backup

You need a pfile when restoring the Oracle RMAN Backup.

#!/bin/bash
# set -x
 
### Script Variables
WHATAMI=`basename $0`
BASEDIR=`dirname $0`
 
### Oracle Variables
export ORACLE_SID=<oraclesid>
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=/opt/oracle/product/10.2
 
 
### Offsitecopy Variables
. "$BASEDIR/mail.txt"
. "$BASEDIR/offsitecopy.func2"
BACKUPDIR=/var/backup/oracle/pfile
HOSTNAME=`hostname`
HOSTNAME_SHORT=`hostname -s`
LOGFILE="$BACKUPDIR/log.txt"
TOUSER="repluser"
TOHOST="syncserver.company.local"
TODIR="/srv/syncdata/Oracle/${HOSTNAME_SHORT}_${ORACLE_SID}/pfile"
BACKUPFILE="$BACKUPDIR/${HOSTNAME_SHORT}_${ORACLE_SID}-pfile_`date +%Y%m%d%H%M`.pfile"
DOCOPY="1"
 
mailFunction() {
   if [ "$1" == "SUCCESS" ]; then
      cat $LOGFILE | mail -s "Check PFILE Backup, not copied and not checked!" $MAILTOFAIL
   fi
}
 
copyFunction() {
   if [ "$DOCOPY" == "1" ]; then
      offsitecopy "${BACKUPFILE}" "$TOUSER" "$TOHOST" "$TODIR" "$LOGFILE" "$WHATAMI" "$HOSTNAME" "$MAILTOSUCCESS" "$MAILTOFAIL"
   else
      echo
      echo "Copy to offsite location is not enabled."
      echo "Modify the script under Offsitecopy Variables to enable offsitecopy"
      echo
      mailFunction SUCCESS
   fi
}
 
# NOTE: Output of command is always succesful because of the echo!!! Always check $LOGFILE
createPfile() {
   echo "Starting pfile backup..." > $LOGFILE
   echo "create pfile='$BACKUPFILE' from spfile;" | $ORACLE_HOME/bin/sqlplus -S "/ as sysdba" >> $LOGFILE
   echo "Pfile backup done." >> $LOGFILE
}
 
createPfile
copyFunction
 
echo
echo "INFO - PFILE backup finished"
echo

As you can see, there is an external reference to offsitecopy and mail.txt. Both are described in Script: Bash: Offsitecopy.

Another Check

You can cat the created pfile, so you can view the oracle settings.

More Resources

For more info on pfile, please see this article.

You could leave a comment if you were logged in.
pfilebackup.txt · Last modified: 2021/09/24 00:25 (external edit)