Skip to content

RMAN EXECUTE SCRIPT

    RMAN EXECUTE SCRIPT command is used to run a local or global RMAN script stored in the recovery catalog

    Executing a Stored Script

    This example uses LIST to list the script stored in the recovery catalog and PRINT SCRIPT to show the contents of global_backup_db, the example runs global_backup_db to back up the database.

    RMAN> LIST SCRIPT NAMES;
     
    List of Stored Scripts in Recovery Catalog
    
        Global Scripts
    
           Script Name
           Description
           -----------------------------------------------------------------------
           global_backup_db
           back up any database from the recovery catalog, with logs
    
    RMAN> PRINT SCRIPT global_backup_db;
    
    printing stored global script: global_backup_db
    {
        BACKUP DATABASE PLUS ARCHIVELOG;
    }
    
    RMAN> RUN { EXECUTE GLOBAL SCRIPT global_backup_db; }
    
    executing global script: global_backup_db
    
    
    Starting backup at 07-JUN-13
    current log archived
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=120 device type=DISK
    .
    .
    .

    Creating and Executing a Stored Script That Uses Substitution Variables

    After starting RMAN and connecting to a target database and recovery catalog, use REPLACE SCRIPT to create a backup script that includes three substitution variables. RMAN prompts you to enter initial values for the variables (user input is in bold).

    RMAN> REPLACE SCRIPT 
    2>  backup_df { BACKUP DATAFILE &1 TAG &2.1 FORMAT '/disk1/&3_%U'; }
     Enter value for 1: 1
     
    Enter value for 2: df1_backup
     
    Enter value for 3: df1
    
    starting full resync of recovery catalog
    full resync complete
    created script backup_df
     

    Later, you can execute the backup_df script with different values. The following example passes the values 3test_backup, and test to the substitution variables in the stored script:

    RMAN> RUN { EXECUTE SCRIPT backup_df USING 3 test_backup df3; }
    

    After the values are substituted, RMAN executes the BACKUP command as follows:

    BACKUP DATAFILE 3 TAG test_backup1 FORMAT '/disk1/df3_%U';

    When you run an RMAN EXECUTE SCRIPT command within a RUN block, RMAN places the contents of the script in that RUN block. Therefore, do not allocate a channel within the RUN block if you also allocate it in the script.

    Also See:

    Oracle RMAN

    RMAN script