Monday 9 December 2019

Shell Script for RMAN Backup

Here's a simple shell script for taking RMAN Backup

#!/bin/sh
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_home
ORACLE_SID=indigo
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH
NLS_LANG=American_America.UTF8; export NLS_LANG
export ORACLE_HOME;
PATH=$ORACLE_HOME/bin:$PATH; export PATH

sdate=/bin/date
DAY=`$sdate +%d` #1-30/31
HOUR=`$sdate +%H` # HOURS: 0-23
DATE=`$sdate +%h_%d_%Y` # Date as Nov_16_2010
MONTH=`$sdate +%m` #Month 01-12
YEAR=`$sdate +%Y`
thisdate=`$sdate +%d%b%y`
thisminute=`$sdate +%H%M`
backupdate=`$sdate +%Y%m%d`
mkdir -p /b01/rman_backups/indigo/${YEAR}_${MONTH}_${DAY}_${HOUR}


$ORACLE_HOME/bin/rman target 'sys/passwd@indigo catalog rman/rman@rman' << EOF > /b01/rman_backups/indigo/logs/Indigo_FULL_BACKUP_${DATE}_${thisminute}
run{
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ' /b01/rman_backups/indigo/${YEAR}_${MONTH}_${DAY}_${HOUR}/%F';
ALLOCATE CHANNEL c1 DEVICE TYPE disk;
ALLOCATE CHANNEL c2 DEVICE TYPE disk;
ALLOCATE CHANNEL c3 DEVICE TYPE disk;
ALLOCATE CHANNEL c4 DEVICE TYPE disk;
backup full database tag INDIGO_FULL format ' /b01/rman_backups/indigo/${YEAR}_${MONTH}_${DAY}_${HOUR}/%d_%T_%s_%p_FULL';
sql 'alter system archive log current';
backup tag INDIGO_ARCHIVE format ' /b01/rman_backups/indigo/${YEAR}_${MONTH}_${DAY}_${HOUR}/%d_%T_%s_%p_ARCHIVE' archivelog all;
backup tag INDIGO_CONTROL current controlfile format ' /b01/rman_backups/indigo/${YEAR}_${MONTH}_${DAY}_${HOUR}/%d_%T_%s_%p_CONTROL';
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
EOF
exit

8 comments:

  1. Nice blog.we also share information about Italy VPS Hosting so if you want visit this link.

    ReplyDelete
  2. Very Well, This is the best i have ever seen, you explain very well. Totally Impressive. VPS Hosting
    Switzerland VPS Hosting

    ReplyDelete
  3. Thanks, it amazing explanation for shell script, that's very much help full article for a coder.
    Cheap India VPS Hosting

    ReplyDelete
  4. What an awesome written by you! I am too glad to read this kind of informative blog article. Thanks to sharing this with us, really thank you!!!!!!
    Dubai VPS Server

    ReplyDelete
  5. That great posting and too its very help full article for me. thanks for sharing your information.
    Germany VPS Server Hosting

    ReplyDelete
  6. Thank You so much for helping me by sharing your great information!!!
    Linux VPS Server Hosting

    ReplyDelete
  7. Wonderful system security and database restoring solutions!!!!! that is supper technical helps blog posting. I like this article too much. Thanks for sharing!!!!
    Linux VPS Server Hosting

    ReplyDelete
  8. Mindblowing, This is an amazing superb article Keep Sharing this...
    Thanks a lot!!!!

    Germany VPS Hosting

    ReplyDelete