Solved

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

Posted on 2014-10-15
7
460 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
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 explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

747 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

11 Experts available now in Live!

Get 1:1 Help Now