Managed Stored Scripts in RMAN

Create, restore, list & execute the Stored Scripts in RMAN

We can create Scripts for RMAN backup and restore operations for a better and easier way to use. Scripts can be local or global.
The local Script is linked with the target database and the global script is registered in the recovery catalog so that every database can use it from the catalog.

Create Stored RMAN Scripts

The create Script command is used to create the stored script and store it in the target database. If mentions Global, then it is stored in the recovery catalog.

1. Connect RMAN to the target database and recovery catalog

-- create a full backup script used default setting of show all command.
Create script full_backup
(
crosscheck archivelog all;
Backup database plus archivelog;
)

--you can create global script with following syntax:
create global script full_backup_global
(
Backup database plus archivelog;
)

— Create script from file
Create script full_backup from file ‘C:\script\rmanbackup.txt’;

Replace Stored Scripts
The replace script command is used to modify the existing script present in the target/catalog database.

-- Only database backup
Replace script full_backup
(
backup database;
)

Execute Stored RMAN Script
Execute script is the command to run the script on the RMAN prompt.

Run
{
EXECUTE SCRIPT full_backup;
}
--For global script:
RUN
{
EXECUTE GLOBAL SCRIPT full_backup_global;
}

List Stored RMAN Script
List script command to display the name of script present in database.

-- List all the script from connected target database
LIST SCRIPT NAMES;

-- List global script
LIST GLOBAL SCRIPT NAMES;

–LIST ALL SCRIPT
LIST ALL SCRIPT NAMES;

Print Stored RMAN Scripts
PRINT SCRIPT Command is used to display the content of the script.

-- Print the local script
PRINT SCRIPT full_backup;

-- Pring the global script
PRINT GLOBAL SCRIPT full_backup_global;

— Pring the script to a text file
PRINT SCRIPT full_back TO FILE ‘C:\scripts\fullbackup.txt’;

Delete RMAN Stored script
Delete command is used to delete the stored script in the catalog/target database

DELETE SCRIPT 'full_backup';
DELETE GLOBAL SCRIPT 'full_backup_global';

Execute script directly from OS command prompt

Rman target / catalog rman@catdb script 'C:\script\fullbackup.txt';

Leave a Reply