Databases Reference
In-Depth Information
Here's one more example, this time showing how you use the
set
command to temporarily change the value of a
parameter within a
run
block. Let's say you configured data file copies to three using the following command:
RMAN> configure datafile backup copies for device type sbt to 3;
You can override the default of three copies by using the following
run
block, where the
set
command sets
the number of backup copies to only two. You'll thus get two copies of each data file and archive log that's part of
the backup.
run
{
allocate channel dev1 device type sbt;
set backup copies = 2;
backup datafile 1,2,3,4,5;
backup archivelog all;
}
Once the run block finishes executing, the data file copies for tape devices will be set to three again, per your
configured settings.
How It Works
You can execute a
run
block from the RMAN command line by entering each line sequentially, but it's more common
to employ the
run
block from inside a command file. You can then execute the command file from the RMAN prompt
or use it inside a
cron
job. The
run
block is useful when you want to schedule RMAN jobs, say, through the
cron
facility. Once RMAN completes checking the syntax of the input lines in the
run
block, it'll execute each statement
sequentially.
When RMAN encounters the closing brace of a
run
block, it groups the commands into one or more job steps
and starts executing the job step(s) immediately. Frequently you use a
run
block to override the default configured
channels or other parameters for a certain task and then reset the channels or parameters to their original values
before finishing the
run
block. RMAN uses the
allocate channel
and
release channel
commands to override
the default configured channels for a task. You use the
set
command to change other parameters. You can specify
the allocate channel and set commands within a
run
block to override the default values of key RMAN backup and
recovery settings for a particular job.
You can use some RMAN commands only within a
run
block. These commands, such as
allocate channel
and
set newname for datafile
, are typically used to set the execution environment for the other RMAN commands
within the
run
block. Conversely, you can't use some of the RMAN commands dealing with configuration and
environmental settings within a
run
block. For example, you can't use the following commands from within a
run
block:
connect, configure
create catalog, drop catalog, upgrade catalog
create script, delete script, replace script
list
report
Note that you can use any of the commands listed previously inside a command file, as long as you don't enclose
them inside a
run
block. In Chapter 9 you'll learn about storing RMAN scripts, known as
stored scripts
, within the
recovery catalog. Since all commands inside a stored script must be enclosed in a
run
block, it means you can't use
any of the commands listed here in a stored script as well.