Automating RMAN Backups via Catalog Scripts

Activity Flow

  • Connect to catalog and create your RMAN run block
  • On target create shell script to call catalog script

Create Catalog Stored Script

create global script db_full_bkp
{
backup database plus archivelog;
}

Execute Stored Scripts

Within RMAN

RUN { EXECUTE SCRIPT db_full_bkp; }

Shell Prompt

$ rman target / catalog rman_rc/[email protected] script 'db_full_bkp'

Create Script To Run From Corntab

/u02/rman/scripts/PRODDB_CATSCRIPT_rman_bkp.sh

#!/bin/bash
. /home/oracle/.bash_profile
export DATE=$(date +%m%d%y_%H%M%S)
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=proddb
$ORACLE_HOME/bin/rman target / catalog rman_rc/[email protected] script 'db_full_bkp' log=/u01/rman/logs/${DATE}_proddb_cat_BACKUP.log

give execute permission on backup script file:

chmod 775 /u01/rman/scripts/SID_rman_bkp.sh

Schedule the script in crontab to run at 4pm daily

crontab -e
00 16 * * * /u01/rman/scripts/SID_rman_bkp.sh

Updating Stored Scripts

REPLACE SCRIPT full_bkp
{
BACKUP DATABASE PLUS ARCHIVELOG;
}

Stored Scripts Administration

Deleting Stored Scripts:

DELETE SCRIPT full_bkp;

Display Stored Scripts:

LIST SCRIPT NAMES;
LIST GLOBAL SCRIPT NAMES;
LIST ALL SCRIPT NAMES;
PRINT SCRIPT full_bkp;

Was this article helpful?

Related Articles

Leave a Comment