?
Solved

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

Posted on 2014-10-15
7
Medium Priority
?
516 Views
Last Modified: 2014-10-19
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
0
Comment
Question by:ram gutha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40383195
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.
0
 
LVL 23

Accepted Solution

by:
David earned 1500 total points
ID: 40383450
UNIX/Linux shells, when run from cron, or manually, typically use a simply redirect to generate a log, for example:

$ORA_SCRIPTS/somerestore.sh > $ORA_LOGS/somerestore_sometimestamp.log 2>&1

Now, using the built-in job scheduler instead of an O'/S scheduler may be worth your consideration, -- but the syntax above should provide your log file.
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40383488
>> 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.
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 35

Expert Comment

by:johnsone
ID: 40384040
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.
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 40384066
>>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...)

;)
0
 
LVL 35

Expert Comment

by:johnsone
ID: 40384086
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.
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
Via a live example, show how to take different types of Oracle backups using RMAN.
Suggested Courses
Course of the Month12 days, 17 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question