Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get a savepnpc pre command to finish

Status
Not open for further replies.

benitos

Technical User
Aug 9, 2001
19
US
Hello,
I am running pre and post command using savepnpc (Legato Networker). We are shutting down Oracle databases, the problem is that the pre command sometimes takes longer than the actual backup. The post command runs (startup databases)while the pre is still not finished stoping databases.
How can I get networker save to wait untill the pre command is done? Or tell the save to wait 1 hour or so? Any recommendations would be appreciated.

Benito
 
The best to do this is not using savepnpc but the old fashion method for backup scripts. You will find at least one example in the NW admin Guide.
 
Exactly what does your savepnpc script look like? Perhaps the precommand does not get correct exit signals from the command specified. Try entering the command into a separate script, and call this script at the precmd line. In this new script, you have much more flexibility in controlling the end of whatever you want to do, and giving savepnpc correct exit signals.

Cheers!
Maverick
 
My savepnpc file (e.g. <groupname>.res) looks like this:
Code:
#modified 19-Sep-03 - Use script to detect DB down instead of long sleep 600
type: savepnpc;
#precmd: "/usr/bin/ksh /usr/local/bin/legato_pre_backup.ksh", "/usr/bin/sleep 600";
precmd: "/usr/bin/ksh /usr/local/bin/legato_pre_backup.ksh", "/usr/local/bin/legato_dbstatus.pl";
pstcmd: "/usr/bin/ksh /usr/local/bin/legato_post_backup.ksh", "/usr/bin/sleep 1";
timeout: "07:00:00";

Thus, I have two scripts that must complete before the backup can begin - the DB shutdown script and a separate script that actually looks at the Oracle system processes.

The 'pre_backup.ksh' is a shell script to shutdown the DB.

I wrote the 'legato_dbstatus.pl' Perl script to detect if the DB (Oracle on a Solaris box) is really down or not... you would have to 'tune' the script for what your DB processes look like (or write your own shell script) - this was for Oracle on a particular system:
Code:
#!/usr/bin/perl
#
# legato_dbstatus.pl
#
# Created:  18-Sep-03
# Author:   Me
# Purpose:  Make sure all Oracle processes have died before proceeding
#           with Legato backup processing.
#
#           Written in Perl 'cause I am too lazy to figure
#           it out as a shell program.
#   
#           **** IMPORTANT NOTE ****
#           This program is likely unique to the host that it is running
#           on - see the lines below the 'find candidate processes'
#           comment - we must tailor the program for the Oracle processes
#           found on this server.
#
# MODIFICATION HISTORY
#
# 09-Oct-03 00:12 - Change 'sleep 15' to 'sleep 60' at end (just trying to find
#                           if there is a problem... don't think so, but try it anyway)
# 08-Nov-04 15:32 - Modify to timeout after 15 minutes of waiting
# 06-Dec-04 22:53 - Fix output message

$now = `date`;
chomp($now);
print "Starting /usr/local/bin/legato_dbstatus.pl at $now - check/wait for DB to be stopped.\n";

$cnt = 1;

while($cnt) {   #lather, rinse, repeat until processes are gone
    @temp = `ps -ef | grep oracle`;   #grab all Oracle processes
    $cnt = 0;
    foreach (@temp) {
        chomp();
        #find candidate processes using regex
        # matches "ora_<any 4 alpha or numerics>_<valid suffix acc, shr or ddl>1"
        $cnt++ if (/ora_[A-z0-9]{4}_(acc|shr|ddl)1/);  #count dem boogers
    }
#    print "Count $cnt\n";
    sleep 30;

    $loopcnt++;         #how many times have we slept?
    last if ($loopcnt > 30);    #exit out if longer than 15 minutes
}

sleep 60;
$now = `date`;
chomp($now);

if ($loopcnt > 30) {     #DB did not shutdown within 15 minutes
    $msg = "\nDB still running(?) after 15 minutes of waiting... proceeding with backup.";
} else {                #DB shutdown was normal
    $msg = "\nDB DB appears to be down... proceeding with backup.";
}

print "Exiting /usr/local/bin/legato_dbstatus.pl at $now - $msg\n";

exit (0);
 
I forgot to include: This method is better than simply using a long 'sleep' command combined with a DB shutdown script as it will detect when there are no longer any running DB processes and exit.

There is also a provision in the DB checking script to timeout after a period (in my case, 15 minutes) so that if for some reason the DB did not shut down it will still go ahead with the backup but issue a warning message. Without this logic I sometimes found groups still running the next morning if the DB shutdown didn't work right.
 
Thanks everyone.
We are yet to implement Rman with Networker so this will be helpful till then.
So basically do the pre shutdown, wait a specified time period for the db to shutdown completly, backup runs, then startup.
Am I understanding this correctly?

Thanks again.

Benito
 
So basically do the pre shutdown, wait a specified time period for the db to shutdown completly, backup runs, then startup.
Am I understanding this correctly?
Yes, but your "wait" (i.e. 'sleep' statement on the precmd: line) needs to be as long as the the DB could possibly take to shutdown - or, as I have done, craft a script to detect when the DB is actually down, which I found to be better than simply waiting a fixed period of time.

Once all of the precmd: tasks are completed then the backup can start.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top