Skip Headers
Oracle® Database Backup and Recovery Reference
11g Release 1 (11.1)

Part Number B28273-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

REPLACE SCRIPT

Purpose

Use the REPLACE SCRIPT command to replace an existing script stored in the recovery catalog. If the script does not exist, then REPLACE SCRIPT creates it.

See Also:

CREATE SCRIPT to learn how to create stored scripts

Prerequisites

Execute REPLACE SCRIPT only at the RMAN prompt. RMAN must be connected to a target database and a recovery catalog. The recovery catalog database must be open.

If you are replacing a local script, then you must be connected to the target database that you connected to when you created the script.

Substitution Variables in Stored Scripts

RMAN supports the use of substitution variables in a stored script. &1 indicates where to place the first value, &2 indicate where to place the second value, and so on. Special characters must be quoted.

The substitution variable syntax is &integer followed by an optional period, for example, &1.3. The optional period is part of the variable and replaced with the value, thus enabling the substitution text to be immediately followed by another integer. For example, if you pass the value mybackup to a command file that contains the substitution variable &1.3, then the result of the substitution is mybackup3. Note that to create the result mybackup.3, you would use the syntax &1..3.

When you create a stored script with substitution variables, you must provide example values at create time. You can provide these values with the USING clause when starting RMAN (see RMAN) or enter them when prompted (see Example 2-60).

Syntax

replaceScript::=

Description of replacescript.gif follows
Description of the illustration replacescript.gif

(backupCommands::=, maintenanceCommands::=, miscellaneousCommands::=, restoreCommands::=)

Semantics

Syntax Element Description
GLOBAL Identifies the script as global.

Note: A virtual private catalog has read-only access to global scripts. Creating or updating global scripts must be done while connected to the base recovery catalog.

See Also: "Usage Notes" for an explanation of the difference between global and local scripts

SCRIPT script_name Identifies the local or global script being replaced.
   COMMENT 'comment' Associates an explanatory comment with the stored script in the recovery catalog. The comment is shown in the output of LIST SCRIPT NAMES.
backupCommands

maintenanceCommands

miscellaneousCommands

restoreCommands

Specifies commands to include in the stored script. The commands allowable within the brackets of the REPLACE SCRIPT 'script_name' {...} command are the same commands supported within a RUN block. Any command that is legal within a RUN command is permitted in the stored script. The following commands are not permitted within stored scripts: RUN, @, and @@.
FROM FILE 'filename' Reads the sequence of commands to define the script from the specified file.

The file should look like the body of a valid stored script. The first line of the file must be a left brace ({) and the last line must contain a right brace (}). The RMAN commands in the file must be valid in a stored script.


Example

Example 2-107 Replacing a Recovery Catalog Script

Assume that you use CREATE SCRIPT to create a global script named backup_db:

CONNECT TARGET SYS/password@prod
CONNECT CATALOG rco/password@catdb
CREATE GLOBAL SCRIPT backup_db
COMMENT "back up any database from the recovery catalog, with logs"
{
    BACKUP DATABASE;
}

You then use LIST SCRIPT NAMES to list all scripts known to the recovery catalog:

RMAN> LIST SCRIPT NAMES;
 
List of Stored Scripts in Recovery Catalog
 
 
    Global Scripts
 
 
       Script Name
       Description
       -----------------------------------------------------------------------
       backup_db
       back up any database from the recovery catalog, with logs

You then run the following REPLACE SCRIPT command with the intention of editing the backup_db global script:

RMAN> REPLACE SCRIPT backup_db { BACKUP DATABASE PLUS ARCHIVELOG; }
 
replaced script backup_db

Because you did not specify the GLOBAL keyword, RMAN creates a local script named backup_db in addition to the global script named backup_db. LIST SCRIPT NAMES shows both the global and local script recorded in the recovery catalog:

RMAN> LIST SCRIPT NAMES;
 
List of Stored Scripts in Recovery Catalog
 
 
    Scripts of Target Database PROD
 
       Script Name
       Description
       -----------------------------------------------------------------------
       backup_db
 
 
    Global Scripts
 
 
       Script Name
       Description
       -----------------------------------------------------------------------
       backup_db
       back up any database from the recovery catalog, with logs

You can then delete the local script named backup_db with DELETE SCRIPT and replace the global script as follows:

RMAN> DELETE SCRIPT backup_db;
 
deleted script: backup_db
 
RMAN> REPLACE GLOBAL SCRIPT backup_db { BACKUP DATABASE PLUS ARCHIVELOG; }
 
replaced global script backup_db

The LIST SCRIPT NAMES command now shows that only one script named backup_db exists in the catalog:

RMAN> LIST SCRIPT NAMES;

List of Stored Scripts in Recovery Catalog
 
    Global Scripts
 
       Script Name
       Description
       -----------------------------------------------------------------------
       backup_db

The PRINT SCRIPT command confirms the changes to the global script:

RMAN> PRINT GLOBAL SCRIPT backup_db;
 
printing stored global script: backup_db
 { BACKUP DATABASE PLUS ARCHIVELOG; }