Link to home
Start Free TrialLog in
Avatar of ram gutha
ram gutha

asked on

i would like to write a shell script to automate the restore of a database

i want to restore an oracle database every day. I so i want to automate the procedure through a shell script and run the shell script to automate it. I also want to generate a log while executing this procedure. I got a restore procedure script in a location. Can somebody help me with developing the shell script for this so i can run the restore script and develop a log file while it is being executed? actually I am new to this
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

From your previous question on this, you are doing everything with RMAN.

As long as you have the RMAN command file working, the shell script is as simple as setting up the Oracle environment variables (ORACLE_HOME/PATH/etc...) and one line running the RMAN command.

RMAN will create the log file of what it does.
ASKER CERTIFIED SOLUTION
Avatar of David VanZandt
David VanZandt
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>> but the syntax above should provide your log file.

That assumes the script echos output to stdout.  RMAN and a command file has it's own built in logfile and doesn't normally echo to stdout so that syntax likely won't capture anything,

>>Now, using the built-in job scheduler instead of an O'/S scheduler may be worth your consideration,

I assume you are talking about DBMS_SCHEDULER or DBMS_JOB.  I've read where RMAN has PL/SQL API's that should work but I've never used them so I'm not sure what logging aspects they may have.
The way that I always create scripts like this is to do it manually and write down every single step.  Once you have all the steps down, it is pretty easy to put it all into a script.

One thing to be aware of that I didn't see mentioned yet.  If you run your script through cron, there is no environment set up.  cron does not run any of the login scripts.  If your script works fine interactively, but is failing through cron, missing environment variables is almost always the issue.
>>One thing to be aware of that I didn't see mentioned yet.

re: http:#a40383195
, the shell script is as simple as setting up the Oracle environment variables (ORACLE_HOME/PATH/etc...)

;)
I saw that, but you didn't mention that cron doesn't set the environment.  I was just trying to be clear that it needed to be set in the script if run through cron.  Some people see them set in their environment and don't realize that cron doesn't get those.

Also, the Oracle environment variables may not be the only ones required.  Every shop is different and they may rely on some standard variables that are set at login and don't realize that cron won't see those.  In a lot of places that I have worked, there were environment variables set for log locations and some file locations and if your script is going to rely on those, you need to set them yourself.