Solved

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

Posted on 2014-10-15
7
463 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
  • 3
  • 2
7 Comments
 
LVL 76

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 500 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 76

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 34

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 76

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 34

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

911 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now