Custom Search

ScriptLab - RMAN script

Got it go back Home

  

The script:

   # tested on 10gR2 with 11gR1
   #
   #Set enviroment variables
   #
   ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
   ORACLE_SID="orcl"
   BACKUP_LOCATION=/Backups/$ORACLE_SID
   DB_USER="xxxxxx"
   DB_PASSWORD="xxxxxx"
   SERVER_NO="SU_01"
   #
   #End.
   #

   PATH="$ORACLE_HOME/bin":"/usr/sbin":"/etc/rman":"/u01/app/oracle/product/11.2.0/db_1/bin/rman":"/bin"
   TNS_ADMIN=$ORACLE_HOME/network/admin
   NLS_LANG=american
   NLS_DATE_FORMAT='YYYY-MM-DD:HH24:MI:SS'
   CNTRL_BACKUP_LOC=$BACKUP_LOCATION/CNTRL_$ORACLE_SID_%F

   #Export enviroment variables

   export_environment_variables()
   {

   export ORACLE_HOME
   export ORACLE_SID
   export PATH
   export TNS_ADMIN
   export NLS_LANG
   export NLS_DATE_FORMAT

   }

   export_environment_variables;

   rman target $DB_USER/$DB_PASSWORD@$ORACLE_SID <<EOF

   #connect catalog <catalog_username>/<Password>@<Oracle_Sid>

   configure controlfile autobackup format for device type DISK to '$CNTRL_BACKUP_LOC';
   configure controlfile autobackup on;
   configure default device type to disk;

   run
   {
   allocate channel t1 type disk format '$BACKUP_LOCATION/DB_$ORACLE_SID_%U';

   backup as compressed backupset database format '$BACKUP_LOCATION/DB_$ORACLE_SID_%U';
   delete noprompt archivelog all backed up 1 times to disk completed before 'SYSDATE-1';
   backup as compressed backupset archivelog all format '$BACKUP_LOCATION/ARCH_$ORACLE_SID_%U';
   delete noprompt obsolete recovery window of 3 days device type disk;
   release channel t1;
   }
   EOF

  exit 0;