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;
}

Similar Messages

  • How to use parallelism in RMAN script having multiple lines

    Gurus,
    Need your advice on using parallelism in 'BACKUP AS COPY DATAFILE' script having multiple lines.
    I have a script like below:
    CONFIGURE DEVICE TYPE DISK PARALLELISM 10;
    backup as copy datafile '/data1/oradata/PROD/data01.dbf' format '+DATA';
    backup as copy datafile '/data2/oradata/PROD/data02.dbf' format '+DATA';
    backup as copy datafile '/data3/oradata/PROD/data03.dbf' format '+DATA';
    backup as copy datafile '/data4/oradata/PROD/data04.dbf' format '+DATA'; and so on ......
    If I run this script, it runs sequentially. How can I parallely copy the required data files ?
    I have to selectively copy few files in ASM.
    I want to use a single script.
    Please advise.
    Best regards,
    Santosh
    Edited by: 966454 on Oct 18, 2012 11:59 PM
    Edited by: 966454 on Oct 18, 2012 11:59 PM

    Unfortunately, this will not help my case. It may not always be '+DATA'
    I want to know if there is any way to parallelise the multiple statements.
    Script may have :
    CONFIGURE DEVICE TYPE DISK PARALLELISM 10;
    backup as copy datafile '/data1/oradata/PROD/data01.dbf' format '+DATA1';
    backup as copy datafile '/data2/oradata/PROD/data02.dbf' format '+DATA2';
    backup as copy datafile '/data3/oradata/PROD/data03.dbf' format '+DATA3';
    backup as copy datafile '/data4/oradata/PROD/data04.dbf' format '+DATA4'; ........
    or
    backup as copy datafile 1 as '/data1/oradata/PROD/data01.dbf' ;
    backup as copy datafile 2 as '/data2/oradata/PROD/data02.dbf' ;
    backup as copy datafile 3 as '/data3/oradata/PROD/data03.dbf' ; ........
    Regards,
    Santosh
    Edited by: 966454 on Oct 19, 2012 12:33 AM

  • How to pass a parameter into RMAN script

    Hello,
    I have the following rman script :
    run {
    CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
    CONFIGURE CONTROLFILE AUTOBACKUP OFF;
    CONFIGURE DEVICE TYPE DISK PARALLELISM 2;
    CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT 'c:\oracle\RmanORCL102\ora_df%t_s%s_s%p';
    This script called configure.rman is launch by a .bat script with the following command:
    rman target 'sys/sys12@ORCL102 as sysdba' @c:\oracle\RmanORCL102\configure.rman
    How can I pass a parameter into rman script, I want to pass an additional directory like this:
    rman target 'sys/sys12@ORCL102 as sysdba' @c:\oracle\RmanORCL102\configure.rman v_dir_name
    And use it in rman script:
    CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT 'c:\oracle\RmanORCL102\$v_dir_name\ora_df%t_s%s_s%p';
    Is it a way to do this?
    Regards,
    Elodie

    One option would be to create a file called backup.bat with the following:
    echo run {
    echo CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
    echo CONFIGURE CONTROLFILE AUTOBACKUP OFF;
    echo CONFIGURE DEVICE TYPE DISK PARALLELISM 2;
    echo CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT 'c:\oracle\RmanORCL102\%1\ora_df%t_s%s_s%p';
    echo } ) | rman target sys/sys12@orcl102and then call the script as:
    c:\> backup.bat backup_directory_name

  • Using scheduler to directly execute rman script stored in recovery catalog

    Hi everyone, I usually automate my rman backups using either cron or dbms_scheduler to call my rman scripts stored in a NIX sh file.  Everything works fine but does anyone know how/if it's possible to call an rman script stored in the recovery catalog. Lets say I create a script in the catalog:
    RMAN> create script showall
    comment 'just an example for demonstration'
    SHOW ALL;
    Can I use dbms_scheduler to call that script directly? If so how and if not then how can I schedule this or any catalog stored script stored in the rman catalog.  Searched all over the place but everything seems to point to having to leave Oracle to call either a .sh or .bat file.
    Regards,
    Dave

    Hi Greg, think you are definately on the right track mate.  Based on what you put I found this at:
    http://www.oracle-base.com/articles/12c/scheduler-enhancements-12cr1.php
    It has the entire rman script in the pl/sql block but going to see if I can modify what's on that page and use what you put so instead of executing the entire script it will run something like:
    BEGIN
    DBMS_SCHEDULER.CREATE_JOB(
    job_name => 'RMAN_SHOW_ALL',
    job_type => 'EXECUTABLE',
    job_action => 'RMAN TARGET / CATALOG rman/password@ your_cat run {execute script showall;}'
    END;
    Or something similar with times etc for execution if possible as the mechanics are the same. Believe though that using the job_action parameter will be the answer and allow me to automate my daily etc backups at night.
    Will let you know once it's done and mark as correct answer.
    Dave

  • RMAN backup of 8i target db using 9i rman scripts

    Hello,
    I have set up a server for Monitoring and Backup using OEM and RMAN, and I have installed Oracle 9.2.0.6 RMAN catalog, to store the backup scripts and the backup information
    I have registred and taken backup of Oracle 9i databases, and it works okay. Now I want to register Oracle 8.1.7.4 databases and take backup of 8i target databases using the scripts and configuration setting that I created for 9i databases
    Can I use the 9i scripts and "configure" command to backup 8i databases?
    I had checked the compatability matrix on metalink (docid: 73431.1) and it suggested using same version of rman executable (.. wrt target database). Is it so?
    I assumed that 9i RMAN is backward compatible and so this can be used to backup the 8i databases... sames commands and not just the 9i catalog. I get RMAN-6429 when I try to connect to 8i database from the backup server.
    Please let me know if I can use Oracle 9i RMAN command and features to backup Oracle 8.1.7.4 databases?
    Regards
    Sudhanshu

    Update on this thread (...the feedback I got from metalink)
    No, you cannot use the 9i rman executable and features to backup a 8.1.x Database. The rman executable must match the Target Database when Target is 8.1.x.
    New features in 9i are not backward compatible.
    Thanks

  • 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

  • RMAN scripts & variables/parameters

    Hi
    We are using RMAN with TSM. There are a number of 9i and 8i databases. I tried to set the environment up to with as few scripts as possible to cover the variety of databases. I provide various variables/parameters to handle the differences between the various databases.
    In the 9i environment I "CONFIGURE" as much as possible to avoid setting changes in the actual backup script. That gives me a fairly clean generic backup script which also avoids manual channel allocations ie :
    run
    backup incremental level=0
    not backed up since time='SYSDATE-(8/24)'
    check logical
    filesperset=4
    format='/LVL0_%d_%T_%U'
    (database include current controlfile)
    plus archivelog format '/ARC_%d_%T_%U' delete all input;
    However due to the lack of "CONFIGURE" in 8i I cannot configure automatic channels. Therefor my script has to change to :
    run
    allocate channel ch01 type 'sbt_tape' parms 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin/tdpo_${ORACLE_SID}.opt)';
    allocate channel ch02 type 'sbt_tape' parms 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin/tdpo_${ORACLE_SID}.opt)';
    allocate channel ch03 type 'sbt_tape' parms 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin/tdpo_${ORACLE_SID}.opt)';
    allocate channel ch04 type 'sbt_tape' parms 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin/tdpo_${ORACLE_SID}.opt)';
    backup incremental level=0
    check logical
    filesperset=4
    format='/LVL0_%d_%T_%U'
    (database include current controlfile)
    (archivelog all format '/ARC_%d_%T_%U' delete input);
    release channel ch01;
    release channel ch02;
    release channel ch03;
    release channel ch04;
    I have multiple database instances on the same server & would like to have a single generic script with a variable/parameter to change the "tdpo.opt" file for each instance. The alternate is to have a complete set of scripts for each DB instance with everything hard coded.
    The question is : Can I pass variables/parameters to a RMAN script? If yes, how do I go about it?
    Maybe there are other ideas out there to do this. The key to me in this whole execise is to reduce maintenance & increase flexibility.
    Your responses will be appreciated
    CM

    I was hoping to get away from building part of the backup script ie the channel allocation in the RMAN statement.Don't know how you expect to do this when it's required for 8i databases ?
    Well since you are looking to accommodate 8i & 9i database and you need to manually allocate channels for the 8i databases, then you could configure your script to include an IF..THEN block that will run one set of RUN commands if the database name that is passed in is in a certain list and run the other RUN block if it isn't. You could maintain two "here document" blocks, one for 8i and one for 9i. Therefore, all of the commands can reside in one generic script.
    For example, you could configure your single, generic script as:
    # add your logic checking here to see if a 9i database sid
    # was passed in as a parameter.  If so run the following code
    rman target / log=${sid}bkp_log append << !1
    run
    backup incremental level=0
    not backed up since time='SYSDATE-(8/24)'
    check logical
    filesperset=4
    format='/LVL0_%d_%T_%U'
    (database include current controlfile)
    plus archivelog format '/ARC_%d_%T_%U' delete all input;
    !1
    # if not run the following (ie. 8i databases)
    rman target / log=${sid}bkp_log append << !2
    run
    allocate channel ch01 type 'sbt_tape' parms 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin/tdpo_${ORACLE_SID}.opt)';
    allocate channel ch02 type 'sbt_tape' parms 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin/tdpo_${ORACLE_SID}.opt)';
    allocate channel ch03 type 'sbt_tape' parms 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin/tdpo_${ORACLE_SID}.opt)';
    allocate channel ch04 type 'sbt_tape' parms 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin/tdpo_${ORACLE_SID}.opt)';
    backup incremental level=0
    check logical
    filesperset=4
    format='/LVL0_%d_%T_%U'
    (database include current controlfile)
    (archivelog all format '/ARC_%d_%T_%U' delete input);
    release channel ch01;
    release channel ch02;
    release channel ch03;
    release channel ch04;
    !2then you could call this generic script with the appropriate command line parameters.
    Hope I'm following your explanation/requirement.

  • 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.

  • Understanding order of commands in RMAN script

    I just started working at a new job and the prior DBA had already left before I got there. I'm looking at his RMAN script to backup the 11gR2 single instance database and I can't understand what is the need for two "crosscheck backup" commands? Wouldn't it be prudent to also have a "crosscheck backup of archivelog all" command as well? Also, what is the point of having the "restore database preview" command in the daily backup script?
    run
    crosscheck backup;
    recover copy of database with tag 'ORA$OEM_LVL1_ILANDB_PRIM' until time 'SYSDATE-1';
    backup incremental level 1 for recover of copy with tag 'ORA$OEM_LVL1_ILANDB_PRIM' database plus archivelog delete all input;
    delete noprompt obsolete;
    restore database preview;
    crosscheck backup;
    }

    Here is how RMAN is currently configured. How do you suggest I clean this up?
    RMAN> show all;
    using target database control file instead of recovery catalog
    RMAN configuration parameters for database with db_unique_name ORCL are:
    CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
    CONFIGURE BACKUP OPTIMIZATION ON;
    CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
    CONFIGURE CONTROLFILE AUTOBACKUP ON;
    CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u02/app/oracle/fast_recovery_area/ORCL/fullbackup/full_bkp_${DD}/%F';
    CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET PARALLELISM 4;
    CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
    CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
    CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/u02/app/oracle/fast_recovery_area/ILANDB/fullbackup/full_bkp_%d_DB_%u_%s_%p';
    CONFIGURE MAXSETSIZE TO UNLIMITED; # default
    CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
    CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
    CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
    CONFIGURE EXCLUDE FOR TABLESPACE 'WEBTASK_DATA';
    CONFIGURE ARCHIVELOG DELETION POLICY TO NONE;
    CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_ORCL.f'; # default

  • Please review the RMAN script and throw any comments which will increase KB

    Dear Sirs:
    I would be grateful if anyone in this forum checks whether the RMAN strategy taken by me is OK or require any room for improvement. I have not yet
    moved into production.
    Environment: ORACLE 10G R2 running on RAC, RHEL 4.0 for Intel Itanium. RMAN script runs every night at 10PM from node 1 of 2.
    ASM is used and all datafiles, controlfiles, arc, redo in SAN
    Process:
    <1> Empty folder "PreviousdayBackup
    <2> Move backup of yesterday night to "PreviousdayBackup"
    <3> Execute RMAN the script provided below.
    run {
         backup
              filesperset=15
              incremental level 0
              spfile format '/archive/backup/rman/spfile_%d_%s_%T.bak' tag 'spfile_backup'
              database format '/archive/backup/rman/data_%d_%s_%T.bak' tag 'full_data_backup';
              crosscheck backup;
              sql 'alter system archive log current';
              crosscheck archivelog all;
              backup filesperset 288 format '/archive/backup/rman/cscdb_data_archive_%d_%u' archivelog all delete input;
              delete archivelog all completed before 'sysdate-7';
              delete noprompt expired archivelog all;
              delete noprompt obsolete;
              backup current controlfile format '/archive/backup/rman/%d_data_control_%s_%p_%u' tag 'control_file';
    The Tape runs at 3:00AM in the morning and takes all the files from '/archive/backup/rman/'
    _*RMAN Configuration*_
    CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
    CONFIGURE BACKUP OPTIMIZATION OFF;
    CONFIGURE DEFAULT DEVICE TYPE TO DISK;
    CONFIGURE CONTROLFILE AUTOBACKUP ON;
    CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/archive/backup/rman/ctrl_%F';
    CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET;
    CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
    CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1;
    CONFIGURE MAXSETSIZE TO UNLIMITED;
    CONFIGURE ENCRYPTION FOR DATABASE OFF;
    CONFIGURE ENCRYPTION ALGORITHM 'AES128';
    CONFIGURE ARCHIVELOG DELETION POLICY TO NONE;
    CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/oracle/product/1020/db_1/database/snapcf_cscdb1.f';
    I am also not getting the concepts properly on :
    delete archivelog all completed before 'sysdate-7';
    delete noprompt expired archivelog all;
    delete noprompt obsolete;
    Is the delete within the RMAN pieces or within the folder. It would be great if someone can explain me on these
    Awaiting for your kind response
    Caesar
    Edited by: caesar dutta on 10-May-2012 00:10

    Hi emre baransel :
    Step 1: Delete from folder "previousdaybackup"
    Step 2: Move last night backup from "/archive/backup/rman" to "previousdaybackup"
    Step 3: Run RMAN and backup is stored at "/archive/backup/rman"
    Stpe 4: Data is backed up to DLT cartridge from "/archive/backup/rman"
    The folder "/archive/backup/rman" is a separate partition from SAN mounted in the LINUX SYSTEM as ext3
    Why did you chose filesperset=15, do you have specific purpose?Well I am looking at existing RMAN in the place and not changing any basic configuration. Frankly speaking I do not have answer to this.
    I have changed the RMAN commands as
    run {
         backup
              filesperset=15
              incremental level 0
              spfile format 'D:\archive\backup\rman\cscdb1\spfile_%d_%s_%T.bak' tag 'spfile_backup'
              database format 'D:\archive\backup\rman\cscdb1\data_%d_%s_%T.bak' tag 'full_data_backup';
              crosscheck backup;
              sql 'alter system archive log current';
              crosscheck archivelog all;
              backup filesperset 288 format 'D:\archive\backup\rman\cscdb1\cscdb_data_archive_%d_%u' archivelog all not backed up 2 times;
              delete noprompt archivelog all completed before 'sysdate-7';
              delete noprompt expired archivelog all;
              delete noprompt obsolete;
    I feel that I will be in a safer side.
    Please provide comments. Anything that will increase knowledge base and will educate others too in this forum.
    regards,
    caesar

  • 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.

  • RMAN script errors out for some DB's

    I have a single RMAN script that uses env variables to execute RMAN for two databases. It runs fine. I cloned the two DB's (changed DBID's), all four are on the same host. Now I try to use same script for all four. I receive an error when trying to run against the cloned databases. Here is script:
    spool log to full.log append;
    connect catalog rman/xxxxxx@iasrman
    connect target /
    run {
    sql 'ALTER SYSTEM SWITCH LOGFILE';
    backup incremental level 0 database diskratio=0 plus archivelog delete input;
    And here is error, it stops same place everytime, input appreciated.
    Recovery Manager: Release 9.2.0.5.0 - 64bit Production
    RMAN>
    connected to recovery catalog database
    RMAN>
    connected to target database: PRSMQ02 (DBID=944525168)
    RMAN> 2> 3> 4>
    sql statement: ALTER SYSTEM SWITCH LOGFILE
    Starting backup at 30-MAY-07
    current log archived
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: sid=20 devtype=DISK
    allocated channel: ORA_DISK_2
    channel ORA_DISK_2: sid=19 devtype=DISK
    allocated channel: ORA_DISK_3
    channel ORA_DISK_3: sid=18 devtype=DISK
    allocated channel: ORA_DISK_4
    channel ORA_DISK_4: sid=17 devtype=DISK
    allocated channel: ORA_DISK_5
    channel ORA_DISK_5: sid=11 devtype=DISK
    channel ORA_DISK_1: starting archive log backupset
    channel ORA_DISK_1: specifying archive log(s) in backup set
    input archive log thread=1 sequence=25 recid=25 stamp=623931644
    channel ORA_DISK_1: starting piece 1 at 30-MAY-07
    channel ORA_DISK_2: starting archive log backupset
    channel ORA_DISK_2: specifying archive log(s) in backup set
    input archive log thread=1 sequence=26 recid=26 stamp=623931644
    channel ORA_DISK_2: starting piece 1 at 30-MAY-07
    channel ORA_DISK_1: finished piece 1 at 30-MAY-07
    piece handle=/iasrman/q02/prsmq02/prsmq02_df623931649_s59_s1 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
    channel ORA_DISK_1: deleting archive log(s)
    archive log filename=/q02/archive/prism/log_prsmq02_25.arc recid=25 stamp=623931644
    channel ORA_DISK_2: finished piece 1 at 30-MAY-07
    piece handle=/iasrman/q02/prsmq02/prsmq02_df623931649_s60_s1 comment=NONE
    channel ORA_DISK_2: backup set complete, elapsed time: 00:00:02
    channel ORA_DISK_2: deleting archive log(s)
    archive log filename=/q02/archive/prism/log_prsmq02_26.arc recid=26 stamp=623931644
    Finished backup at 30-MAY-07
    Starting backup at 30-MAY-07
    using channel ORA_DISK_1
    using channel ORA_DISK_2
    using channel ORA_DISK_3
    using channel ORA_DISK_4
    using channel ORA_DISK_5
    channel ORA_DISK_1: starting incremental level 0 datafile backupset
    channel ORA_DISK_1: specifying datafile(s) in backupset
    input datafile fno=00009 name=/q02/oradata01/prsmdata/Data_13.dbf
    input datafile fno=00016 name=/q02/oradata01/prsmdata/Data_20.dbf
    input datafile fno=00025 name=/q02/oradata01/prsmdata/Data_04.dbf
    input datafile fno=00005 name=/q02/oraindx01/prsmdata/Index_11.dbf
    input datafile fno=00020 name=/q02/oradata01/prsmdata/Tools02.dbf
    input datafile fno=00022 name=/q02/oraindx01/prsmdata/index_12.dbf
    channel ORA_DISK_1: starting piece 1 at 30-MAY-07
    channel ORA_DISK_2: starting incremental level 0 datafile backupset
    channel ORA_DISK_2: specifying datafile(s) in backupset
    input datafile fno=00010 name=/q02/oradata01/prsmdata/Data_14.dbf
    input datafile fno=00015 name=/q02/oradata01/prsmdata/Data_19.dbf
    input datafile fno=00024 name=/q02/oradata01/prsmdata/Data_03.dbf
    input datafile fno=00003 name=/q02/oratmp01/prsmdata/rbs01.dbf
    input datafile fno=00001 name=/q02/orasys01/prsmdata/system01.dbf
    input datafile fno=00012 name=/q02/orasys01/prsmdata/system02.dbf
    channel ORA_DISK_2: starting piece 1 at 30-MAY-07
    channel ORA_DISK_3: starting incremental level 0 datafile backupset
    channel ORA_DISK_3: specifying datafile(s) in backupset
    input datafile fno=00008 name=/q02/oradata01/prsmdata/Data_12.dbf
    input datafile fno=00014 name=/q02/oradata01/prsmdata/Data_18.dbf
    input datafile fno=00023 name=/q02/oradata01/prsmdata/Data_02.dbf
    input datafile fno=00028 name=/q02/oradata01/prsmdata/Data06.dbf
    input datafile fno=00019 name=/q02/oratmp01/prsmdata/rbs02.dbf
    input datafile fno=00021 name=/q02/orasys01/prsmdata/DRSYS.dbf
    channel ORA_DISK_3: starting piece 1 at 30-MAY-07
    channel ORA_DISK_4: starting incremental level 0 datafile backupset
    channel ORA_DISK_4: specifying datafile(s) in backupset
    input datafile fno=00007 name=/q02/oradata01/prsmdata/Data_11.dbf
    input datafile fno=00013 name=/q02/oradata01/prsmdata/Data_17.dbf
    input datafile fno=00018 name=/q02/oradata01/prsmdata/Data_01.dbf
    input datafile fno=00006 name=/q02/oradata01/prsmdata/Tools01.dbf
    input datafile fno=00002 name=/q02/oradata01/prsmdata/Users01.dbf
    input datafile fno=00026 name=/q02/oradata01/prsmdata/Data05.dbf
    channel ORA_DISK_4: starting piece 1 at 30-MAY-07
    channel ORA_DISK_5: starting incremental level 0 datafile backupset
    channel ORA_DISK_5: specifying datafile(s) in backupset
    input datafile fno=00004 name=/q02/oradata01/prsmdata/Data_15.dbf
    input datafile fno=00011 name=/q02/oradata01/prsmdata/Data_16.dbf
    input datafile fno=00017 name=/q02/oradata01/prsmdata/Data_22.dbf
    input datafile fno=00027 name=/q02/oradata01/prsmdata/Data_05.dbf
    channel ORA_DISK_5: starting piece 1 at 30-MAY-07
    channel ORA_DISK_1: finished piece 1 at 30-MAY-07
    piece handle=/iasrman/q02/prsmq02/prsmq02_df623931654_s61_s1 comment=NONE
    channel ORA_DISK_1: starting piece 2 at 30-MAY-07
    channel ORA_DISK_2: finished piece 1 at 30-MAY-07
    piece handle=/iasrman/q02/prsmq02/prsmq02_df623931654_s62_s1 comment=NONE
    channel ORA_DISK_2: starting piece 2 at 30-MAY-07
    channel ORA_DISK_3: finished piece 1 at 30-MAY-07
    piece handle=/iasrman/q02/prsmq02/prsmq02_df623931654_s63_s1 comment=NONE
    channel ORA_DISK_3: starting piece 2 at 30-MAY-07
    channel ORA_DISK_4: finished piece 1 at 30-MAY-07
    piece handle=/iasrman/q02/prsmq02/prsmq02_df623931654_s64_s1 comment=NONE
    channel ORA_DISK_4: starting piece 2 at 30-MAY-07
    channel ORA_DISK_5: finished piece 1 at 30-MAY-07
    piece handle=/iasrman/q02/prsmq02/prsmq02_df623931654_s65_s1 comment=NONE
    channel ORA_DISK_5: starting piece 2 at 30-MAY-07
    channel ORA_DISK_2: finished piece 2 at 30-MAY-07
    piece handle=/iasrman/q02/prsmq02/prsmq02_df623931654_s62_s2 comment=NONE
    channel ORA_DISK_2: starting piece 3 at 30-MAY-07
    channel ORA_DISK_1: finished piece 2 at 30-MAY-07
    piece handle=/iasrman/q02/prsmq02/prsmq02_df623931654_s61_s2 comment=NONE
    channel ORA_DISK_1: starting piece 3 at 30-MAY-07
    channel ORA_DISK_4: finished piece 2 at 30-MAY-07
    piece handle=/iasrman/q02/prsmq02/prsmq02_df623931654_s64_s2 comment=NONE
    channel ORA_DISK_4: starting piece 3 at 30-MAY-07
    channel ORA_DISK_5: finished piece 2 at 30-MAY-07
    piece handle=/iasrman/q02/prsmq02/prsmq02_df623931654_s65_s2 comment=NONE
    channel ORA_DISK_5: starting piece 3 at 30-MAY-07
    channel ORA_DISK_3: finished piece 2 at 30-MAY-07
    piece handle=/iasrman/q02/prsmq02/prsmq02_df623931654_s63_s2 comment=NONE
    channel ORA_DISK_3: starting piece 3 at 30-MAY-07
    channel ORA_DISK_2: finished piece 3 at 30-MAY-07
    piece handle=/iasrman/q02/prsmq02/prsmq02_df623931654_s62_s3 comment=NONE
    channel ORA_DISK_2: starting piece 4 at 30-MAY-07
    channel ORA_DISK_4: finished piece 3 at 30-MAY-07
    piece handle=/iasrman/q02/prsmq02/prsmq02_df623931654_s64_s3 comment=NONE
    channel ORA_DISK_4: starting piece 4 at 30-MAY-07
    channel ORA_DISK_1: finished piece 3 at 30-MAY-07
    piece handle=/iasrman/q02/prsmq02/prsmq02_df623931654_s61_s3 comment=NONE
    channel ORA_DISK_1: starting piece 4 at 30-MAY-07
    channel ORA_DISK_2: finished piece 4 at 30-MAY-07
    piece handle=/iasrman/q02/prsmq02/prsmq02_df623931654_s62_s4 comment=NONE
    channel ORA_DISK_2: backup set complete, elapsed time: 00:53:23
    channel ORA_DISK_5: finished piece 3 at 30-MAY-07
    piece handle=/iasrman/q02/prsmq02/prsmq02_df623931654_s65_s3 comment=NONE
    channel ORA_DISK_5: starting piece 4 at 30-MAY-07
    channel ORA_DISK_3: finished piece 3 at 30-MAY-07
    piece handle=/iasrman/q02/prsmq02/prsmq02_df623931654_s63_s3 comment=NONE
    channel ORA_DISK_3: starting piece 4 at 30-MAY-07
    channel ORA_DISK_4: finished piece 4 at 30-MAY-07
    piece handle=/iasrman/q02/prsmq02/prsmq02_df623931654_s64_s4 comment=NONE
    channel ORA_DISK_4: starting piece 5 at 30-MAY-07
    channel ORA_DISK_1: finished piece 4 at 30-MAY-07
    piece handle=/iasrman/q02/prsmq02/prsmq02_df623931654_s61_s4 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:59:04
    channel ORA_DISK_3: finished piece 4 at 30-MAY-07
    piece handle=/iasrman/q02/prsmq02/prsmq02_df623931654_s63_s4 comment=NONE
    channel ORA_DISK_3: backup set complete, elapsed time: 01:00:10
    channel ORA_DISK_5: finished piece 4 at 30-MAY-07
    piece handle=/iasrman/q02/prsmq02/prsmq02_df623931654_s65_s4 comment=NONE
    channel ORA_DISK_5: backup set complete, elapsed time: 01:00:25
    channel ORA_DISK_4: finished piece 5 at 30-MAY-07
    piece handle=/iasrman/q02/prsmq02/prsmq02_df623931654_s64_s5 comment=NONE
    channel ORA_DISK_4: backup set complete, elapsed time: 01:01:40
    Finished backup at 30-MAY-07
    Starting backup at 30-MAY-07
    current log archived
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of backup command at 05/30/2007 11:22:38
    RMAN-06004: ORACLE error from recovery catalog database: ORA-03114: not connected to ORACLE

    connect target /You need to inform the connection string to target database.
    Can to be explicitly or with 'export sid' in your script.

  • How to pass a shell variable to rman scripts

    I want to backup datafile to different directory
    depending on the current time,and I can do this to
    pass a shell variable to rman scripts,and this
    variable will used as part of format ,like this:
    backup incremental level=0
    tag rman_inc0_bck
    filesperset 5
    format '$(DIR)/rman_fulldb_%u_%s_%p_%d'
    (database include current controlfile)
    and $(DIR) is shell variable ,but rman will not
    recognize this ,how to achieve this?

    You could send your script to rman thru a pipe | or <<
    echo "backup incremental level=0
    tag rman_inc0_bck
    filesperset 5
    format '$(DIR)/rman_fulldb_%u_%s_%p_%d'
    (database include current controlfile);" | rman target /You could also create a "temp script" and then use it from rman with cmdfile
    sed "s,XXXDIR,$(DIR)," yourtemplate > /tmp/rmanscript.$$
    rman target / cmdfile /tmp/rmanscript.$$
    rm /tmp/rmanscript.$$

  • Schedule rman script in Windows 2003

    Oracle 10.2. I wrote a rman script and tried to schedule auto run in Windows 2003 server. I got this errors:
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-00554: initialization of internal recovery manager package failed
    RMAN-04005: error from target database:
    ORA-12560: TNS:protocol adapter error
    The batch file name: rman_backup.bat
    content: rman target / cmdfile rman_backup.rcv log rman_backup.log
    Here is how I set it up:
    go to Control Panel>Scheduled Tasks>Add Scheduled Task, find rman_backup.bat, choose the run time and finish it. When asking for user name and password, I supply the user which is in oracle dba group.
    But when it run, it just produced the above error and won't run.
    Please advise
    S.
    in SQLnet.log
    fatal NI connect error 12560, connecting to:
    (DESCRIPTION=(ADDRESS=(PROTOCOL=BEQ)(PROGRAM=oracle)(ARGV0=oracleORCL)(ARGS='(DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))'))(CONNECT_DATA=(SID=ORCL)(CID=(PROGRAM=D:\oracle\product\10.2.0\db_1\bin\rman.exe)(HOST=W3TY5Z203)(USER=WELC))))
    VERSION INFORMATION:
         TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
         Oracle Bequeath NT Protocol Adapter for 32-bit Windows: Version 10.2.0.4.0 - Production
    Time: 30-MAR-2010 11:27:00
    Tracing not turned on.
    Tns error struct:
    ns main err code: 12560
    TNS-12560: TNS:protocol adapter error
    ns secondary err code: 0
    nt main err code: 530
    TNS-00530: Protocol adapter error
    nt secondary err code: 2
    nt OS err code: 0

    here is example of script we are using to backup database from windows scheduler:
    set oracle_home=d:\oracle\ora920
    set path=d:\perl\bin;d:\oracle\ora920\bin;c:\winnt;c:\WINDOWS\system32;
    set PERL5LIB=''
    set NLS_LANG=AMERICAN_AMERICA.WE8MSWIN1252
    set TNS_ADMIN=d:\oracle\ora920\network\admin
    d:
    cd \scripts
    set oracle_sid=car
    rman target sys/car_$z3br4 catalog rman/oemrp_pwd@oemrp @rman_level0_car.rman > rman_level0_car.log
    perl email_log.pl "RMAN Level 0 Log" d:\scripts\rman_level0_car.log CARthis script backing up 9i database. 10g and 11g database we backing up via EM grid control.
    You can change this script to backup 10g or 11g databses as well.

  • 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.

Maybe you are looking for

  • Syncing across Subnets

    I have a Dlink dir-655 that functions as my wireless access point for Apple TV and an Imac. Because of the design of my house I have to use two routers, one for the wired and one for the wireless thus putting these items on two different subnets. I h

  • Creating a new drop down menu when an option in an existing one is chosen

    I'm using Coldfusion 9,0,0,251028 on Windows 7 64-bit, with a Microsoft Access 97 database.  I'm having a problem with using a drop-down menu to create another one below it once a certain option is selected (in this case, the option named "Breaking N

  • Connecting wii to tv

    I'm trying to connect my wii to a Sony receiver video input I am getting audio but no picture - can anyone tell me what I'm doing wrong?

  • Interactive SWF files on Smartboards.

    Can Flash interactive SWF files be used on Smartboards with their interactivity intact?

  • GET requests in servlets

    we are using iplanet 4.1 server that invokes our servlet for user requests. in our doGet(), and doPost() methods, we want to get the http GET request as it is received from the client, without any character decoding. we have clients that send us requ