Calling RMAN script with DBMS_JOB

Hi,
Maybe someone can help me out. I'm perfecting my skills on 9i in the backup area before I have a need to use them and am taking notes.
What I want to do is to store the backup script in the recovery catalog (which I already did under the name BACKUP) and call that script on a daily basis using DBMS_JOBS.
Here is my script:
RMAN>CREATE SCRIPT 'BACKUP'
{ALLOCATE CHANNEL C1 TYPE DISK;
BACKUP INCREMENTAL LEVEL 0 DATABASE
FILESPERSET 4;
BACKUP ARCHIVELOG ALL;
DELETE ARCHIVELOG UNTILTIME 'SYSDATE-7';}
This script compiled and is stored in rman. I ran it and it worked. I also autoconfigured the parameters to backup the controlfile automatically when the backup or copy is done.
Now my next goal is to get this script to run automatically everyday using DBMS_JOBS and this is where it is not working.
I used the DBMS_JOB.SUBMIT parameters to store the job in this feature but first the procedure 'RUNBACKUP' must compile successfully.
DBMS_JOB.SUBMIT(:1,'RUNBACKUP', SYSDATE,'SYSDATE+1');
This RUNBACKUP is a procedure that has to be called by the DBMS_JOBS PACKAGE. But the procedure is where Im having problems trying to write.
I am assuming that rman is not connected to the target database here. So this is what I think it should look like:
CREATE OR REPLACE PROCEDURE RUNBACKUP
BEGIN
RMAN; --the first thing that           
has to be called is rman executable.
CONNECT TARGET AL/AL@BBROWN
--now we have to connect the target db to rman.
CONNECT CATALOG RMAN/RMAN@RCAT;
-- connecting to the recovery catalog.
RUN {EXECUTE SCRIPT 'BACKUP';} --execute the stored backup script
END;
Also, at the end of this procedure I would like to exit rman as the final command.
Any ideas on this would be appreciated and thanks for your help in advance.
Al

You need to create a shell script to execute rman and add that script to cron, something like this:
#!/bin/ksh
# Script name: whole_db_backup.ksh
export PATH=/oracle/app/9i/bin:$PATH
export ORACLE_HOME=/oracle/app/9i
export ORACLE_SID=MDR
rman <<EOF
connect target /
connect catalog rmancat/PASS@RMANCAT
run {execute script whole_db_backup;}
exit
EOF

Similar Messages

  • How to call a script with procedure parameter

    I have a script my_script.sql in sqlplus and that script calls a procedure with one in parameter my_procedure (my_parameter IN VARCHAR2).
    I need to pass the parameter in the script call.
    sqlplus>@my_script my_parameter
    How can I do that?

    SQL> set serveroutput on
    SQL> create or replace procedure testpass (par1 in varchar2)
      2  is
      3  begin
      4     dbms_output.put_line(par1);
      5* end;
    SQL> get my_script
      1* exec testpass ('&1');
    SQL> @my_script 'This is the parameter'
    This is the parameter
    PL/SQL procedure successfully completed.
    SQL>                                                                                        

  • Share you RMAN script with me

    Hi
    I newly hired to vacation as DBA. Could you experts share your RMAN backup script with me please? Which backup script do you us?
    Thanks in advance

    run {
    allocate channel ch1 device type disk;
    backup incremental level 0 format '/u04/rman_backup/RMAN_DBF_TSTDB<%s:%t:%p>.bkp' database;
    sql 'alter system archive log current';
    backup format '/u04/rman_backup/RMAN_ARCH_TSTDB<%s:%t:%p>.bkp' archivelog all;
    backup format '/u04/rman_backup/RMAN_CTL_TSTDB<%s:%t:%p>.bkp' current controlfile;
    You can use this script in crontab to take the database backup daily. But you should clear your concept about RMAN backup to troubleshoot any kind of error.
    Regards
    Asif Kabir

  • Rman Script with ORacle10g in RHEL5

    Dear Friends ,
    I have to install ORacle10g in RHEL5 . Now I need to take rman backup
    and for this reason I make the following script :
    ============================
    rman target / << !
    run
    allocate channel t1 type disk;
    backup format 'df_%t_%s_%p'
    (database);}
    ==============================
    It works fine and does not prompt for any user name and password . But Now
    I want a situation where this script wants username and password prompt
    when it goes to run , i.e., I need username and password prompt during
    running this script ?
    Can anybdy plz help me ..

    On Linux box i tried following and it's working:
    Recovery Manager: Release 10.2.0.1.0 - Production on Sat Mar 1 03:00:46 2008
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    RMAN> connect target sys
    target database Password:
    connected to target database: CCSDB (DBID=1595737743)
    RMAN>

  • How to store the value into variable and access it in RMAN script

    I want to create a variable and dynamically assign a numeric value to it (may get the value may be from SQL )and access the value in RMAN script.
    Thanks...Raj

    Raj,
    We have been getting this type of request and it is not possible via RMAN to do that.
    BUT--You could write a sql/plus script to query your variable and produce the RMAN script with the new value.
    Just a suggestion.
    Tammy

  • Using SYSDATE in RMAN script

    Hi
    Each night I move an RMAN backup from a PROD server to a test server.
    Then using RMAN script with NOCATALOG, I restore/recover the database on the test server as show below:
    RUN{
    ALLOCATE CHANNEL dev1 DEVICE TYPE DISK;
    STARTUP NOMOUNT;
    RESTORE CONTROLFILE from AUTOBACKUP;
    SHUTDOWN;
    STARTUP FORCE MOUNT;
    RESTORE DATABASE;
    RECOVER DATABASE;
    ALTER DATABASE OPEN RESETLOGS;
    Of course the script fails at the "RECOVER DATABASE" command because it runs out of ARCH logs to apply at some point and therefore never gets to the final command of DATABASE OPEN. I would like to change that line to something like:
    RECOVER DATABASE UNTIL TIME 'SYSDATE:02:45:00';
    The above fails with an RMAN error of "expected number".
    Of course I could use SET UNTIL TIME "to_date('SYSDATE 02:45:00','DD-MON-YYYY HH24:MI:SS')"; although I have the same problem, i.e., getting RMAN to accept SYSDATE as the date portion of the point in time recovery.
    Oddly, from an RMAN prompt and within brackets, I can issue the following command successfully:
    RMAN {
    set until time "to_date('SYSDATE 02:45:00','DD-MON-YYYY HH24:MI:SS')";
    command completed successfully
    So my question is, how can I use SYSDATE in an RMAN point in time recovery and have sysdate represent the current date, either in the RECOVER DATABASE line or the SET UNTIL TIME line?
    Thanks.

    user522620 wrote:
    Hi
    Each night I move an RMAN backup from a PROD server to a test server.
    Then using RMAN script with NOCATALOG, I restore/recover the database on the test server as show below:
    RUN{
    ALLOCATE CHANNEL dev1 DEVICE TYPE DISK;
    STARTUP NOMOUNT;
    RESTORE CONTROLFILE from AUTOBACKUP;
    SHUTDOWN;
    STARTUP FORCE MOUNT;
    RESTORE DATABASE;
    RECOVER DATABASE;
    ALTER DATABASE OPEN RESETLOGS;
    So my question is, how can I use SYSDATE in an RMAN point in time recovery and have sysdate represent the current date, either in the RECOVER DATABASE line or the SET UNTIL TIME line?
    Thanks.
    Given:
    SQL> alter session set NLS_DATE_FORMAT='DD-MON-YYYY HH24:MI:SS';
    SQL> select to_char(trunc(sysdate)+(2/24)+(45/1440),'dd-mon-yyyy hh24:mi') from
    dual;
    TO_CHAR(TRUNC(SYS
    25-JUN-2012 02:45:00
    Use this (uses to_date)
    RUN{
    set until time "to_date(trunc(sysdate)+(2/24)+(45/1440),'DD-MON-YYYY HH24:MI:SS')";
    ALLOCATE CHANNEL dev1 DEVICE TYPE DISK;
    STARTUP NOMOUNT;
    RESTORE CONTROLFILE from AUTOBACKUP;
    SHUTDOWN;
    STARTUP FORCE MOUNT;
    RESTORE DATABASE;
    RECOVER DATABASE;
    ALTER DATABASE OPEN RESETLOGS;
    ## if that command fails, it will fall to the next command as the run blocks are autonomous.
    RUN{
    ALTER DATABASE OPEN RESETLOGS;
    }

  • Calling a script from rman

    Hi Experts,
    Is it possible to call a script from rman.
    database 9i
    Recovery catalog 10g.
    Ex :
    connect target test/test@TEST;
    connect catalog rman/rman@RMAN
    @backup (where backup is a datafile backup script on unix)
    I dont know if there is any other way of calling a script within an rman script.
    Any ideas....
    Thanks in Advance
    MB

    OK,
    I understood. The file .SQL is for SQL statements only, not for RMAN commands.
    You can create a shell script on Unix named your_backup.sh on /home/oracle directory,
    for example.
    This shell script file (bellow) is with your rman code, like this:
    #!/bin/sh
    # Name: A name for the shell script
    # Author: You
    # Description: Executes backup for Sunday using the RMAN
    # Updates:
    export ORACLE_HOME=$1
    export ORACLE_SID=$2
    export LOG_DIR=$3
    # Variables:
    SCRIPT="your_backup"
    data_log=`date '+%y-%m-%d_%H:%M:%S'`
    logfile=${LOG_DIR}/${SCRIPT}-${data_log}.log
    # Execution of script backup of rman:
    $ORACLE_HOME/bin/rman <<EOF > $logfile
    connect target rman/rman
    connect catalog rman/rman
    run{
    set controlfile autobackup format for device type disk to '%F';
    allocate channel d1 type disk format '/tmp/SID/df_s%s_p%p_t%t';
    restore controlfile to '/PATH/ctl/cntrlTEMP.dbf' from autobackup;
    replicate controlfile from '/PATH/ctl/cntrlTEMP.dbf';
    sql "alter database mount";
    release channel d1;
    EOF
    exitto you execute this script, you can do this on the unix:
    [oracle@server oracle]$ /home/oracle/your_backup.sh /u01/app/oracle/product/9.2.0.1.0 devdb /home/oracleThis script is going to generate log file to you analyze.
    []´s

  • RMAN errors sent to shell script calling RMAN sequence?

    Hello,
    I have a Korn shell script run on Solaris as the root user that launches RMAN sequences similar to this one:
    #!/bin/ksh
    su - oracle -c "export ORACLE_SID=ORCL; rman target / << !
    <rman sequence>
    I am wondering if there is a way to catch the RMAN errors in the shell script?
    If I call SQLplus instead of RMAN, I can use "whenever sqlerror exit sql.sqlcode" and I will retrieve the error code in the shell script from $? - can I do such a thing with RMAN?
    Thank you,
    Adrian

    You could capture the return code *$?* from your RMAN script and if it returns anything other than 0, then you could grep the RMAN log for errors and/or query
    V$RMAN_OUTPUT after the RMAN script executes.

  • Can I call an external program from my rman script

    Hi
    Is it possible to do an external call to a bat-file in a rman script?
    My script looks like this (it's pretty much generated from EM):
    $rman_script="backup device type disk tag '%TAG' database;
    sql 'alter system archive log current';
    backup device type disk tag '%TAG' archivelog all not backed up delete all input;
    allocate channel for maintenance type disk;
    delete noprompt obsolete device type disk;
    release channel;
    Can i somehow make an external call before at the end?
    Regards
    Klaus Mogensen

    You can use the HOST command.

  • Calling an rss script with rs.exe fails to result in a report pdf from VB6 w/ ShellEx.

    Sql 2008 R2
    Calling an rss script with rs.exe fails to result in a report pdf from VB6 w/ ShellEx. 
    If I call rs.exe with the various parameters from the command prompt I  have success(other than rs.exe using the temp folder, which is a different issue).  But when I try to execute the same process from a Visual Basic 6.0 application utilizing
    the ShellEx api call, the report creation and output to PDF format do not occur.   There is no error raised.
    Yes, I wish I could use a newer dev tool but that isn't an option right now. I think this should work.  Can ya'll tell me what I'm doing wrong?
    sArgs = "-i " & Chr(34) & "'C:\Program Files\Dura Supreme\OrderEntry\RunOrdReports.rss'" & Chr(34) & _
    " -s 'http://walnut/reportserver' -v 'DuraOrderNum=" & _
    Chr(34) & sOrdDuraID & Chr(34) & "' -e Exec2005 -t"
    ShellEx Chr(34) & "C:\Program Files\Dura Supreme\OrderEntry\rs.exe" & Chr(34), EShellShowConstants.essSW_SHOWNORMAL, sArgs
    TIA,
    Jim M.

    ShellEx Chr(34) & "C:\Program Files\Dura Supreme\OrderEntry\rs.exe" & ....
    Hello Jim,
    The path for rs.exe includes spaces, you should set it in hyphen, as you already did for file "RunOrdReports.rss" in variable "sArgs2
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • What's wrong with this RMAN script?

    Hi,
    I have a rman script to back up the 8i database like the following:
    #!/bin/ksh
    if [ $# != 1 ]; then
    echo "Usage: $0 ORACLE_SID"
    exit
    fi
    ORACLE_SID=$1; export ORACLE_SID
    RMAN_LOC=/u1/rman_backup
    export ORACLE_HOME=/u2/oracle/8.1.7
    export PATH=$ORACLE_HOME/bin:$PATH
    echo "connect target /" > rman_backup.rcv
    echo "" >> rman_backup.rcv
    echo "configure controlfile autobackup on;" >> rman_backup.rcv
    echo "" >> rman_backup.rcv
    echo "configure controlfile autobackup format for device type disk to '${RMAN_LOC}/%F';" >
    rman_backup.rcvecho "" >> rman_backup.rcv
    echo "run {" >> rman_backup.rcv
    echo "allocate channel t1 type disk;" >> rman_backup.rcv
    echo "backup database format '${RMAN_LOC}/db_${ORACLE_SID}_%u';" >> rman_backup.rcv
    echo "}" >> rman_backup.rcv
    rman cmdfile rman_backup.rcv
    When I run it, I got the following error:
    RMAN> connect target /
    2>
    3> configure controlfile
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-00558: error encountered while parsing input commands
    RMAN-01005: syntax error: found "controlfile": expecting one of: "compatible"
    RMAN-01007: at line 3 column 11 file: rman_backup.rcv
    BTW, the same script is working fine with 9i db.
    Could someone help me?
    Thanks in advance,
    Helen

    Hello,
    there is no controlfile autobackup in 8i RMAN. You must copy controlfile on your own, e.g. SQL 'ALTER DATABASE BACKUP CONTROLFILE TO file_name' or use eqiv. rman command - please check documentation.
    Kind Regards, Piotr
    DBA OCP.

  • Please help to call oracle procedure with out paramter from shell script

    Hi
    I want to call a process with out parameter from shell script. I am calling process in shell script in below way
    function Process_loads {
    ( echo 'set serveroutput on size 1000000 arraysize 1'
    echo "set pagesize 0 term on verify off feedback off echo off"
    echo "BEGIN"
    echo " dbms_output.put_line('Before Calling The package'); "
    echo " x ( '$1', '$2', '$2', '$4', '$5', '$error_code'); "
    echo " dbms_output.put_line('After Calling The package'); "
    echo "EXCEPTION "
    echo " WHEN OTHERS THEN "
    echo " dbms_output.put_line('BIN_LOAD_ERROR' || SQLERRM); "
    echo " ROLLBACK;"
    echo "END;"
    echo "/" ) | sqlplus -s $USER/$PASSWORD@$SID
    Here $error_code is out paramter. All varaibles passed in process are declared with export command.
    When executing .sh it gives below error
    "sh ERROR at line 3: ORA-06550: line 3, column 99: PLS-00363: expression '' cannot be used as an assignment target ORA-06550: line 3, column 3: PL/SQL: Statement ignored".
    Please help to get rid from this error or please suggest how to call a oracle procedure with out paramter from unix shell script.
    Thanks in advance

    You can try this:
    From sql*plus
    SQL> ed
      1  create or replace procedure my_proc(p_id in int, p_result out int)
      2  as
      3  begin
      4  select 10 * p_id
      5  into p_result
      6  from dual;
      7* end my_proc;
    SQL> /
    Procedure created.
    SQL> set serveroutput on
    SQL> declare
      2  v_r int;
      3  begin
      4  my_proc(10,v_r);
      5  dbms_output.put_line(v_r);
      6  end;
      7  /
    100
    PL/SQL procedure successfully completed.
    from bash:
    testproc.sh:
    #!/bin/bash
    (echo 'set serveroutput on';
    echo 'declare';
    echo 'v_r int;';
    echo 'begin';
    echo 'my_proc(10,v_r);';
    echo 'dbms_output.put_line(v_r);'
    echo 'end;';
    echo '/';) | sqlplus -s u1/u1
    Console:
    oracle@mob-ubuntu:~$ chmod u+x testproc.sh
    oracle@mob-ubuntu:~$ ./testproc.sh
    100
    PL/SQL procedure successfully completed.With kind regards
    Krystian Zieja

  • Error with SMLets in an Orchestrator called PowerShell Scripts

    Hi!
    This is likely so simple I am overlooking the problem but...
    I have a "Run .Net Script" activity in an Orchestrator 2012 SP1 Runbook.  It calls SMLets.  The issue is it runs in the PowerShell ISE on the Runbook server without issue.  It runs in the Runbook Tester just fine.  But if I
    call the runbook with the PowerShell script, it errors out on the first call the a SMLets provide cmdlet.
    A Few Detail:
    We loaded the latest SMLets from CodePlex.  We can use the cmdlets in both the 32-bit and 64-bit environments.
    The very first line of the PowerShell script is: Import-Module SMLets
    The first SM cmdlet is: $class = Get-SCSMClass System.WorkItem.Activity.ReviewActivity$
    The Runbook Containing the PowerShell Script:
    And lastly, the Event of the error thrown:
    In trying to make this work we have tried to run the script remotely on the SCSM server (New-PSSession and Invoke-Command).  Failures due to rights on the SCSM server. 
    My opinion is the issue is a rights issue but we cannot find the difference between any of the accounts testing/debugging and the Orchestrator Runbook Service account.  I can run the PowerShell and the Runbook Tester when logged on as the
    Orchestrator Runbook Service account.  It works until I have to call the runbook with the PowerShell Activity.  It just like my Account.  We've even set the account on the security tab of the Invoke Runbook Activity.
    Is there something I've overlooked?  Something in the install of the SMLets, maybe? A clue?  Help?
    If nothing else, thank you for letting me voice my issue onto the 'Net.  Maybe someone else has been down this road and can tell me where the off-ramp is.  ;-)
    Ray Watters,
    Chicago, IL

    Hi,
    also make sure that your PS scriptruns with Windows PowerShell (x86) (32bit)
    http://www.sc-orchestrator.eu/index.php/scoblog/64-using-64bit-powershell-cmdlets-in-the-run-net-script-activity-from-orchestrator
    or with PowerShell V2
    http://www.sc-orchestrator.eu/index.php/scoblog/102-running-powershell-30-with-the-run-net-script-activity
    Regards,
    Stefan
    www.sc-orchestrator.eu ,
    Blog sc-orchestrator.eu

  • Scheduler with RMAN script

    hi,
    i have the following RMAN script:
    /*daily.sh*/
    run {
    allocate channel ch1 device type disk format '/rman/%d_%T_%p_%U' maxpiecesize 1G;
    backup
    incremental level 1 cumulative
    database
    plus archivelog delete input;
    backup current controlfile;
    backup spfile;
    release channel ch1;
    and also have the following scheduler script:
    BEGIN
    DBMS_SCHEDULER.CREATE_JOB(
    job_name=>'BDOFFICE.INC_BACKUP',
    job_type => 'EXECUTABLE',
    job_action =>'/office/u01/daily.sh',
    start_date=>'28-NOV-06 02.18.00 PM',
    repeat_interval=>'TRUNC(SYSDATE+1)+14/24',
    /* after 1 days at 1:00 PM */
    comments => 'daily backup');
    END;
    how can i integrate these so that scheduler run the script automatically.
    plz give me the steps with example.
    thanks
    Message was edited by:
    bijitesh

    You can use the dbconsole to schedule your backup script. It is quite easy and you can have it show you the sql used to create the job.

  • Place Call and continue with remaining script steps - is it possible?

    We recently picked up IPCelerate which has the ability to send a Text display or Text-to-Speech message to a group of phones simply by dialing a configured directory number.  We would like to text our call center agents with this application when a caller has been waiting for X number of loops.
    Attempting to use 'Place Call' to initiate this text page works, however, the script terminates immediately after the call is placed and we would like to continue on with the remainder of our script.  In this case, on Success go back to the top of the loop.   
    I have also tried to use Call Subflow instead, thinking an executed sub-routine placing the call would return to the original script and continue on, but it didn't.  In both cases, the system comes back and states " I'm sorry, we're currently experiencing system problems and are unable to process your call.  Please try again later."
    If there's a way to get this to work via Place Call or another process to accomplish the same result, that would be fantastic.  I appreciate any feedback.
    We're using UCCx Express 5.0 (2.064) with premium type licensing.

    Hello,
    I did get to an answer similar to what r.stockton did to solve the issue, but I left Exception (ContactInactiveException) Goto in ours to isolate exceptions because we have multiple contacts within our script.  Turns out that this particular exception was thrown by the PlaceCall step ending abruptly by our paging system answering and hanging up the call quickly.  MIVR logs showed that it didn't bomb as immediately as when the debugs showed it crashing - it actually went into a loop over and over with the Trigger contact before failing.
    We had some help from TAC on this, but below is what we did to keep some error checking and notification we use available to us.  We are running a check to make sure the Call Trigger (original call) is still active.
    placecallContact = Place Call (to Number)
    on Exception (ContactInactiveException) Goto
    label:
    CallActive = Get Contact Info (--Trigering Contact--, Active)
    If (CallActive) Then
    - True branch continues with script
    - False Branch terminates call
    If this takes the false branch, it means the trigger contact is not active, and has abandoned the call or been transferred elsewhere.  Placed an End step here to prevent any loops.
    If this takes the true branch, it means the triggering contact is actually still active. In our scenario, CallActive (boolean variable) is verified true and continues with the script without going into the loop of death.
    I hope this helps!

Maybe you are looking for

  • TDM for Logic Pro on a Mac Pro

    I have a Mac Pro running OSX 10.4.8 and I am wondering if anyone knows when Apple is going to release an update for TDM to will work with Logic. For some reason i cant record with Core Audio either. Can someone explain.

  • When i enter date range n vkorg iam getting all sales orginzation

    HI All, I have enter which you have given for me but its not working eg.. it isfunction module import parameters all are options p_stdate=01.04.2005 p_endate=30.04.2005 p_kunnr= i will not enter any thing p_vkorg= m600 so i have entered only date ran

  • Delete last month payroll result

    Hi All, How to delete only last month payroll result, when I am trying to delete with PU01, its deleting all the payroll results I nee dto delete only last month Thanks SD

  • Xml is not generating the selected column

    Hi experts, I have selected the 3 column in my slect statement with 3 bind variable . But when I save my datamodel and generate the xml , My xml is not showing the selected three column...please find the blow query. Select BAL_ATT.TRANSACTIONAL_AMOUN

  • EDitorKit development -- XMLEditorKit

    Does anyone know if future versions of Java will include a XMLEditorKit, or is something like this available elsewhere? I am attempting to build a simple text editor capable of highlighting XML tags, elements, attributes, etc. with different colors t