Executing a Stored Script
After you’ve stored your scripts, you will want to run them. Once connections have been established to both the catalog and target database, you can call the stored script via the execute script command:
$rman target / catalog rman_901/rman_901_pwd@rman_catalogRecovery Manager: Release 9.0.1.0.0 - Production connected to target database: BRDSTN (DBID=664610428) connected to recovery catalog database RMAN>run {execute script full_back;}executing script: full_back
You can also call stored scripts from other stored scripts. This allows you to modularize your RMAN commands. For example, you may want one script to allocate a channel, another to release a channel, and a third to run a backup command. For example, create a file called stsc.sto and place within it the following commands:
# This script allocates a channel.replace script alloc_disk {allocate channel d1 type disk;}# This script releases the channel.replace script rel_disk {release channel d1;}# This script does a full backup.replace script run_backup{execute script alloc_disk;backup full format '/d0102/backup/rman_%d_%U.bus' database;execute script rel_disk;}
Then, to execute the file and store all of the scripts, issue the following command from the O/S prompt:
$ rman target / catalog rman_901/rman_901_pwd@rman_catalog
@stsc.sto log=str.logThe scripts will be stored in the catalog. And if you look at the log file, str.log, you will see the informational messages. Three scripts ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access