SHIFT

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

User Tools

Site Tools


Sidebar

Sponsor:

Would you like to sponsor this site?
Or buy me a beer?:


Recently Changed Pages:

View All Pages
View All Q Pages


View All Tags


Sign up for Q to post comments.





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.


Terms And Conditions for Q users


Pages with comments

PageDateDiscussionTags
2019/06/22 10:36 1 Comment
2019/03/15 16:02 1 Comment
2019/03/15 16:02 1 Comment
2019/03/15 16:02 3 Comments
2017/04/20 15:28 1 Comment
2017/04/20 15:23 1 Comment
2017/04/19 14:44 1 Comment
2017/04/17 20:10 1 Comment
2017/04/17 20:07 1 Comment
2017/04/17 19:58 1 Comment
2017/04/17 19:52 1 Comment

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: 2013/05/04 13:20 by sjoerd