Databases Reference
In-Depth Information
How It Works
The RMAN session will terminate immediately after the command file finishes executing. There's an important
difference to be aware of regarding how RMAN reacts to syntax errors in command files. The difference depends upon
whether you invoke RMAN to execute a command file from the operating system prompt or whether you invoke a
command file interactively from the RMAN prompt. Here's what you need to know:
When you run an RMAN file from the operating system line, RMAN will first try to parse all
the RMAN commands in the file. Then RMAN will start executing each in a sequential fashion.
If RMAN encounters any errors at the parse stage or during the execution phase,
it'll immediately exit.
On the other hand, when you run an RMAN file from the RMAN prompt, RMAN executes each
command separately and will exit only after it attempts the execution of the last command in
the file.
In addition to executing a command file from the RMAN prompt, you can also call a command file from within
another command file. Use the double at ( @@ ) command for that purpose. When you issue the @@ command inside
a command file, RMAN will look for the file specified after the @@ command in the same directory as that of the
command file from which it was called. For example:
$ rman @$ORACLE_HOME/rdbms/admin/dba/scripts/cmd1.rman
In this example, the command @@cmd2.rman is specified within the cmd1.rman command file. Once you execute
the main or parent command file (cmd1.rman), the @@ command within the cmd1.rman file makes RMAN l look for
and execute the cmd2.rman command file in the directory $ORACLE_HOME/rdbms/admin/dba/scripts/, the same
directory that holds the parent command file. The @@ command is useful when you have a set of related command files,
because you can place all those files into one directory and they can all find each other automatically after that point.
Creating Dynamic Command Files
Problem
You want to create dynamic command files that can be used for multiple jobs by passing substitution variables.
Solution
You can create dynamic shell scripts by using substitution variables in the RMAN command files inside the shell
scripts. You can specify values for use in substitution variables through the new using clause when calling an RMAN
command file. You use the &integer syntax (&1 , &2 , and so on) to indicate to which variable your substitution values
should be assigned, just as in SQL*Plus.
Let's review an example that shows how to create a dynamic backup shell script.
1.
Create the RMAN command file that uses two substitution variables:
#backup.cmd
connect target sys/<sys_password>@prod1
run {
backup database
tag &1
format '&2 ';
}
exit;
 
Search WWH ::




Custom Search