Managing File Copies   «Prev 

Backup Command Syntax

run { 
 allocate ch1 type disk;
 allocate ch2 type disk;
 copy datafile 'file1.ora' to 'd:\file2.ora'
 copy datafile 'file3.ora' to 'd:\file4.ora.'
 ;
}             

Format of RMAN Commands

The RMAN language is free-form. Keywords must be separated by at least one white space character (such as a space, tab, or line break). An RMAN command starts with a keyword corresponding to a command. The following example shows an RMAN backup command:

BACKUP DATABASE;

A command can span multiple lines. For example, you can rewrite each keyword in the preceding command on a separate line as follows:
BACKUP
DATABASE;

The maximum length for an RMAN command in a single line is 4000 characters. When a command exceeds this length, you can either split the command into multiple commands or use multiple lines for the command (use the Enter key to make the command span multiple lines).
For example, if a BACKUP command that backs up multiple data files exceeds 4000 characters, then you can either split this command into two separate BACKUP commands or make the single BACKUP command span multiple lines. You can insert a comment by using a pound (#) character at any point in a line. After the # character, the remainder of the line is ignored. For example:

# run this command once each day
BACKUP INCREMENTAL LEVEL 1
FOR RECOVER OF COPY # using incrementally updated backups
WITH TAG "DAILY_BACKUP" # daily backup routine
DATABASE;

@ (at sign)

Purpose: Use the @ command to execute a series of RMAN commands stored in an operating system file with the specified path name.
Note: The file must contain complete RMAN commands. Partial commands generate syntax errors.
Prerequisites: The command file must contain complete RMAN commands.
If you use the @ command within a RUN command, then the @ command must be on its own line

Example 6.9.1: Running a Command File from the Operating System Command Line

This example creates an RMAN command file and then executes it from the operating system command line.
% echo "BACKUP DATABASE;" > backup_db.rman
% rman TARGET / @backup_db.rman

Example 6.9.2: Running a Command File Within RMAN

This example shows how you can execute a command file from the RMAN prompt and from within a RUN command. User-entered text appears in bold.
RMAN> @backup_db.rman
RMAN> RUN {
2> @backup_db.rman
3> backup database;
4> **end-of-file**
5> }

Example 6.9.3: Specifying Substitution Variables

Suppose that you use a text editor to create command file whole_db.rman with the following contents:
# name: whole_db.rman
BACKUP TAG &1 COPIES &2 DATABASE;
EXIT;

The following example starts RMAN from the operating system prompt and connects to the target database. The example then runs the @ command, passing variables to the command file to create two database backups with tag Q106:
% rman TARGET /
RMAN> @/tmp/whole_db.rman Q106 2