Oracle® Database Backup and Recovery Reference 10g Release 2 (10.2) Part Number B14194-03 |
|
|
View PDF |
Syntax
createScript::=
Purpose
To create a stored script in the recovery catalog.
A stored script is a sequence of RMAN commands, given a name and stored in the recovery catalog for later execution. A stored script may be local (that is, associated with one target database) or global (available for use with any database registered in the recovery catalog).
Any command that is legal within a RUN command is permitted in the stored script.
Several other commands are used with stored scripts:
The PRINT SCRIPT command is used to view the contents of a stored script.
The REPLACE SCRIPT command is used to update the contents of a stored script.
The EXECUTE SCRIPT command is used to execute the commands in the stored script.
The SCRIPT
command line arguments for RMAN (described in "cmdLine") runs a stored script automatically when starting RMAN.
The LIST SCRIPT NAMES command is used to find out what stored scripts are defined for the current target database and recovery catalog.
The DELETE SCRIPT command is used to delete a stored script from the recovery catalog.
See Also:
Oracle Database Backup and Recovery Advanced User's Guide to learn how to use stored scriptsRestrictions and Usage Notes
Note the following restrictions:
Execute CREATE
SCRIPT
only at the RMAN prompt, not within a RUN block.
When creating a script, RMAN must be connected to a target database and a recovery catalog, and the catalog database must be open.
You cannot run CREATE
SCRIPT
once to create a local script, and then use this same script on multiple target databases. If you want to create a global script, you must connect to some target database (as well as a recovery catalog) and then use CREATE GLOBAL SCRIPT
instead of CREATE SCRIPT
.
You cannot execute a RUN command within a stored script.
Quotes must be used around the script name when the name contains either spaces or reserved words.
RMAN returns an error RMAN-20401: script already exists
if you try to create a local script when another local script already exists for the same target database with the same name. The same error is returned if you try to create a global script and a global script already exists with the same name in the recovery catalog. If the script already exists, you must use REPLACE SCRIPT
to update its contents.
Keywords and Parameters
Syntax Element | Description |
---|---|
GLOBAL |
Identifies the script being created as global. If omitted, RMAN creates a local stored script script_name defined on the current target database. If no such script is defined on the target database, RMAN creates for a global stored script script_name . |
' script_name ' |
The name of the script to create. |
COMMENT [=] 'comment' |
Associates an explanatory comment with the stored script in the catalog. |
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 ' |
backupCommands
|
Commands valid in a stored script. The statements allowable within the brackets of the CREATE SCRIPT 'script_name' { ... } command are the same commands supported within a RUN block. See "RUN" for more details. |
Example
Creating a Local Stored Script: Example This example creates a stored script called backup_whole
that backs up the database and archived redo logs:
# creates recovery catalog script to back up database and archived logs CREATE SCRIPT backup_whole COMMENT "backup whole database and logs" { BACKUP INCREMENTAL LEVEL 0 TAG b_whole_l0 DATABASE PLUS ARCHIVELOG; }
Creating a Global Stored Script: Example This example creates a stored script called backup_whole
that backs up the database and archived redo logs:
# creates recovery catalog script to back up database and archived logs CREATE GLOBAL SCRIPT global_backup_db COMMENT "backup any database from the recovery catalog, with logs" { BACKUP DATABASE PLUS ARCHIVELOG; }