1753792 Members
7308 Online
108799 Solutions
New Discussion юеВ

RMAN script through cron

 
SOLVED
Go to solution
Yvonne Butler
Regular Advisor

RMAN script through cron

I've having problems trying to get RMAN commands to run from a script. Ideally I want to run this script using cron. The script will attach to RMAN and give me an RMAN> prompt but the commands I've listed appear to get ignored.
Any ideas?
9 REPLIES 9
Massimo Bianchi
Honored Contributor

Re: RMAN script through cron

Hi,
how do you schedule it ?


Can you prompt the line ?

I used RMAN from cron and it worked for me.

POut your command in a text file, called some.sql

and run

rman ....... @some.sql


HTH,
Massimo

Steven E. Protter
Exalted Contributor

Re: RMAN script through cron

In the cron entry you need.

su - c oracle "script command"

along with the normal shell redirection you use in cron.

This assumes your oracle db owner is oracle. Change that to fit your circumstances.

In the command section include the full path name of the script to execute.

To diagnose problems with the actual script, I would need to see a copy. You should be able to attach it.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Darren Prior
Honored Contributor

Re: RMAN script through cron

Just to add to SEP's info:

If you're using su - oracle then you need to ensure that there is nothing in oracle's .profile that will need a response or tty. It would probably be safer to use su oracle; then source a file containing the necessary environmental setup. Otherwise you risk running into the "not a typewriter" type messages.

regards,

Darren.
Calm down. It's only ones and zeros...
Yvonne Butler
Regular Advisor

Re: RMAN script through cron

I probably haven't explained myself very well. Running the script through cron isn't a problem, the problem comes when executing the script. The script will run but sit at an RMAN> prompt at line 8>, it won't run any of the RMAN commands I've put in the script (which I've copied below).

1> #!/bin/sh
2> export ORACLE_SID=TMSPROD
3> export ORACLE_HOME=/oracle1/oracle/product/920
4> export RMAN=$ORACLE_HOME/bin/rman
5> cd /backup/TMSPROD/RMAN
6> cp tmsprod* /backup/TMSPROD/RMAN/old
7> rm tmsprod*
8> rman target / rcvcat rman/rman@tmsprod
9> run {
10> allocate channel c1 type disk
11> format '/backup/TMSPROD/RMAN/tmsprod_%U.dmp';
12> backup (database include current controlfile);
13> release channel c1;
14> allocate channel c1 type disk
15> format '/backup/TMSPROD/RMAN/tmsprod_al_%U.dmp;
16> sql "alter system archive log current";
17> backup (archivelog all delete input);
18> release channel c1;
19> }
Massimo Bianchi
Honored Contributor
Solution

Re: RMAN script through cron

Hi,
you are doing a wrong re-direction on input (read: no redirection).

Script should be

1> #!/bin/sh
2> export ORACLE_SID=TMSPROD
3> export ORACLE_HOME=/oracle1/oracle/product/920
4> export RMAN=$ORACLE_HOME/bin/rman
5> cd /backup/TMSPROD/RMAN
6> cp tmsprod* /backup/TMSPROD/RMAN/old
7> rm tmsprod*
8> rman target / rcvcat rman/rman@tmsprod << EOF
9> run {
10> allocate channel c1 type disk
11> format '/backup/TMSPROD/RMAN/tmsprod_%U.dmp';
12> backup (database include current controlfile);
13> release channel c1;
14> allocate channel c1 type disk
15> format '/backup/TMSPROD/RMAN/tmsprod_al_%U.dmp;
16> sql "alter system archive log current";
17> backup (archivelog all delete input);
18> release channel c1;
19> }
20> EOF


or better:

put the

run (..)
in a sql called backup.sql

and start your script calling it


rman target / rcvcat .... @backup.sql



HTH,
Massimo



Darren Prior
Honored Contributor

Re: RMAN script through cron

Hi,

I know very little about RMAN, but I can see that you are trying to run internal RMAN commands through the posix shell... You will need to put the RMAN commands into a file and get RMAN to execute them, or perhaps use a here document .

To ease testing you could run the script manually from the command line rather than via cron as this is not a cron issue.

regards,

Darren.
Calm down. It's only ones and zeros...
Yvonne Butler
Regular Advisor

Re: RMAN script through cron

Thanks Massimo I think I'm getting closer now. I just need to get my RMAN commands just right and I'm there. Thanks everyone, you've all been a big help!
Yvonne Butler
Regular Advisor

Re: RMAN script through cron

I'm not quite there it would seem. I've tested all the RMAN commands manually but get the following output when executing the script. Any ideas where I've gone wrong?

[logtms01]/backup/scripts=$ ./tmsprod.sh
cp: cannot access tmsprod*: No such file or directory
rm: tmsprod* non-existent

Recovery Manager: Release 9.2.0.3.0 - 64bit Production

Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.

connected to target database (not started)
connected to recovery catalog database

RMAN> run {
2> resync catalog;
3> change archivelog all crosscheck;
4> backup format '/backup/tmsprod/tmsprod_%U.dmp'
5> (database
6> include current controlfile);
7> backup format '/backup/tmsprod/tmsprod_%U.arc'
8> (archivelog all delete input);
9> }
10>
11>
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of resync command at 06/12/2003 12:11:33
RMAN-06403: could not obtain a fully authorized session
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
HP-UX Error: 2: No such file or directory

Recovery Manager complete.
Yvonne Butler
Regular Advisor

Re: RMAN script through cron

Can the previous message I've got it now. I'd put the database SID in uppercase when it should have been lowercase. All working now. Thanks again everyone...