RMAN CREATE SCRIPT command is used to create a stored script in the recovery catalog
Creating a Global Stored Script
This example connects RMAN to target database prod
and recovery catalog database catdb
as catalog user rco
. The example creates a global script called global_backup_db
that backs up the database and archived redo log files:
RMAN> CONNECT TARGET "[email protected] AS SYSBACKUP" target database Password: password connected to target database: PROD (DBID=39525561) RMAN> CONNECT CATALOG [email protected] recovery catalog database Password: password connected to recovery catalog database RMAN> CREATE GLOBAL SCRIPT global_backup_db { BACKUP DATABASE PLUS ARCHIVELOG; } RMAN> EXIT;
You can now connect RMAN to a different target database such as prod2
and run the global stored script:
RMAN> CONNECT TARGET "[email protected] AS SYSBACKUP" target database Password: password connected to target database: PROD2 (DBID=36508508) RMAN> CONNECT CATALOG [email protected] recovery catalog database Password: password connected to recovery catalog database RMAN> RUN { EXECUTE SCRIPT global_backup_db; }
Creating a Stored Script That Uses Substitution Variables
The following example connects RMAN to a target database and recovery catalog and uses CREATE SCRIPT
to create a backup script that includes three substitution variables. RMAN prompts you to enter initial values for the variables (user input is shown in bold).
RMAN> CONNECT TARGET / RMAN> CONNECT CATALOG [email protected] recovery catalog database Password: password connected to recovery catalog database RMAN> CREATE SCRIPT backup_df 2> { BACKUP DATAFILE &1 TAG &2.1 FORMAT '/disk1/&3_%U'; } Enter value for 1: 1 Enter value for 2: df1_backup Enter value for 3: df1 starting full resync of recovery catalog full resync complete created script backup_df
When you run EXECUTE SCRIPT
, you can pass different values to the script. The following example passes the values 3
, test_backup
, and test
to the substitution variables in the stored script:
RMAN> RUN { EXECUTE SCRIPT backup_df USING 3 test_backup df3; }
After the values are substituted, the script executes as follows:
BACKUP DATAFILE 3 TAG test_backup1 FORMAT '/disk1/df3_%U';
Deleting a Global Script
This example deletes global script backup_db
from the recovery catalog:
RMAN> LIST SCRIPT NAMES; List of Stored Scripts in Recovery Catalog Scripts of Target Database PROD Script Name Description ----------------------------------------------------------------------- backup_whole backup whole database and archived redo log files Global Scripts Script Name Description ----------------------------------------------------------------------- global_backup_db back up any database from the recovery catalog, with logs RMAN> DELETE GLOBAL SCRIPT global_backup_db; deleted global script: global_backup_db RMAN> LIST SCRIPT NAMES; List of Stored Scripts in Recovery Catalog Scripts of Target Database PROD Script Name Description ----------------------------------------------------------------------- backup_whole backup whole database and archived redo log files
Also See: