DBAsupport.com Forums - Powered by vBulletin
Results 1 to 6 of 6

Thread: Backup failing through cron, most urgent please.

  1. #1
    Join Date
    Apr 2002
    Posts
    291
    Hi gurus,
    I'm facing a very strange problem. I want to run this following script for cold backups. I got another script whcih automatically shuts down the DB by name dbshut1.sh, and after backup to tape succefully, then startup the DB. But the ownership for these two files are under oracle user. But this cron has to be executed by root. By any ways, this cron is not calling my inner scripts DBSHUT1.SH and DBSTART1.sh. Couldn't understand. I tried to run this by putting root under DBA group, and by giving 777 permissions on these two files to root etc.. But not working. DB is not comming down. Here i'm pasting my script. Please look into this and help me . This is really crucial for me.

    ORA_DUMP.scr
    ----------------
    #! /bin/bash

    # Purpose:
    # Script to backup up each oracle file system to tape.

    # keep track of the time it takes to run
    time {

    # use the "date" command to make log file unique
    mnth=`date +%b%d`
    time=`date +%T`
    year=`date +%Y`
    logdate=${mnth}_${time}_${year}

    # create a log file and put everything there
    logfile=/var/adm/backups/ora_backup.${logdate}.log

    exec > $logfile 2>&1
    echo "Starting script ora_dump.scr..."
    echo `date`
    echo ""
    echo "Backing up directories on `hostname`..."
    echo ""

    # Ensure that the DB has been properly shut down
    echo "Running /usr/local/bin/dbshut1.sh to ensure that the DB is shut down prop
    erly..."
    /usr/local/bin/dbshut1.sh
    retcode=`echo $?`
    echo $retcode
    if [ $retcode = 0 ]; then
    date
    echo "Database is shut down properly, proceeding..."
    echo ""
    else
    date
    echo "Database did not shut down properly, aborting...."
    # send mail out
    exit 1
    fi

    # Do the backup here.
    for dir in /u00 /u01 /u02; do
    echo "/sbin/dump -a -0u -f /dev/nst0 $dir"
    /sbin/dump -a -0 -f /dev/nst0 $dir
    echo "Backup of $dir is complete..."
    echo ""
    done

    # eject tape when complete
    #mt -f /dev/st0 rewoffl

    # start the Oracle database back up...
    echo "Starting oracle database back up..."
    /usr/local/bin/dbstart1.sh

    # Send mail with logfile
    mail rudawson@dc.com < $logfile

    echo "Script ora_dump.scr is finished."
    echo `date`
    }

    exit 0

    ----------DBSHUT1.SH

    # /bin/bash

    # This is to shut down the Oracle DB and make sure that it is shut down properly

    # log the activity

    # use the "date" command to make log file unique
    mnth=`date +%b%d`
    time=`date +%T`
    year=`date +%Y`
    logdate=${mnth}_${time}_${year}
    logfile=/opt/oracle/admin/cms/logs/ora_shutdown.$logdate

    exec > $logfile 2>&1

    sqlplus /nolog < connect / as sysdba
    shutdown immediate
    exit
    ps -ef | grep ora_pmon_test > /dev/null
    dbstat=$?
    while [ $dbstat = "0" ]; do
    echo "DATABASE CMS is still up"
    echo "Sleeping for five minutes..."
    sleep 3
    ps -ef | grep ora_pmon_test > /dev/null
    dbstat=$?
    done
    echo "DATABASE CMS is down"
    echo "Script exitting..."

    exit 0

    ------- DBSTART1.SH

    sqlplus /nolog < connect / as sysdba
    startup pfile=$ORACLE_HOME/dbs/initcms.ora
    exit
    echo "DATABASE \"${ORACLE_SID}\" IS UP AND RUNNING "


    ---------------------------------------------------------------------

    These are the scripts. Please correct me. The mandatory one is i've to run the backup script as root only.

    Thanks in advance
    PNRDBA

  2. #2
    Join Date
    Apr 2001
    Posts
    108

    Cron jobs as root

    You need to perform an su within the script to change to the oracle userid when you run the scripts to shutdown or startup the database. Modify lines as follows:

    /usr/local/bin/dbshut1.sh

    changes to

    su - oracle -c /usr/local/bin/dbshut1.sh

    Make the same modification to the dbstart script as well. Hope this helps you out.

    Eric Hanson

    There are 10 types of people in the world:

    Those who understand binary and those who don't!

  3. #3
    Join Date
    Apr 2002
    Posts
    291
    I tried this. but su - oracle is not working in this script. Its just hanging there. The script itself is not working with this command.


    Can any one help me???
    PNRDBA

  4. #4
    Join Date
    Jun 2000
    Location
    Madrid, Spain
    Posts
    7,447
    does it work if you run it manually :?

  5. #5
    Join Date
    Apr 2002
    Posts
    291
    Nope
    PNRDBA

  6. #6
    Join Date
    Jun 2000
    Location
    Madrid, Spain
    Posts
    7,447
    add at the beggining in /usr/local/bin/dbstart1.sh

    echo "HIHIHIH I AM YOUR MAMMA"

    and see if that appears in your prompt, if not then something is wrong with your call routing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width