Skip Headers
Oracle® Database Backup and Recovery Quick Start Guide
10g Release 2 (10.2)

Part Number B14193-02
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Master Index
Master Index
Go to Feedback page
Feedback

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

9 Repetitive Tasks: RMAN and Scripting

While the use of configured channels and other settings reduces many common RMAN operations to a single command, your backup routine may include frequently-used multi-step processes. RMAN supports the use of stored scripts (discussed in Oracle Database Backup and Recovery Advanced User's Guide) and command files to help manage these recurring tasks. The RMAN RUN command provides a degree of flow-of-control in your scripts.

Using Command Files

A command file is a client-side text file containing RMAN commands, exactly as you enter them at the RMAN prompt. Execute the contents of a command file using the RMAN @ command:

RMAN> @/my_dir/my_command_file.txt  # runs specified command file 

Any file extension may be used. You can also launch RMAN with a command file to run, as shown here:

% rman @/my_dir/my_command_file.txt  

Controlling Scripts: The RUN Command

The RUN command lets you issue a series of RMAN commands to be executed as a group. If one command fails, the remaining commands in the block will not be executed. Note, however, that RMAN will still try to execute as many tasks related to a failed command as possible.

Here is an example of a RUN command:

RUN {
    BACKUP ARCHIVELOG ALL DELETE ALL INPUT;
    BACKUP INCREMENTAL LEVEL 0 TAG mon_bkup DATABASE;
}

If backup of one or more of the archived logs fails, RMAN will still back up all archived logs that can be backed up, because those tasks are all caused by the one BACKUP command. However, the BACKUP INCREMENTAL command following the BACKUP ARCHIVELOG command is not executed.

The SET, SWITCH DATAFILE, and ALLOCATE CHANNEL commands, used within a RUN block, override channel configurations and other backup parameters set with the CONFIGURE command for the duration of the RUN block. See Oracle Database Backup and Recovery Reference for details.

Use RUN blocks in command files to stop execution if one command fails.