Saturday, February 5, 2011

RMAN - full Database Backup

RMAN Script for Full Database Backup
-------------------------------------------------------
Below is the code for RMAN full backup of a database ( between the horizontal lines).
Note : Make sure the Database is running in archive log mode before you proceed.

1. We need to create the directory structure for RMANBKUP,RMANLOGS variables as per space availability in the server.
2. Replace the word oracle_sid with the present ORACLE_SID value , This value can be obtained by the command ( echo $ORACLE_SID)
3. Place this code in “fullbackup.sh” file in any path and run this script by one of the two ways as listed below(go to the path where .sh file is placed).   
        >./fullbackup.sh  (or)  >sh fullbackup.sh
4.After issuing the above command , nee to chek the log file from other session, So that we can confirm script is being successfully run. ( if we set the wrong directory path script will fail and same will be recorded in this log).

--------------------------------------------------------------
RMANBKUP="/export/home/oracle/rman_script/rmanbkp"
RMANLOGS="/export/home/oracle/rman_script/rmanlog"
TODAYD=`date '+%d%m%y_%H:%M:%S'`
mkdir -p $RMANBKUP/oracle_sidFULLORABKUP_$TODAYD
chmod 777 $RMANBKUP/oracle_sidFULLORABKUP_$TODAYD
 rman log=$RMANLOGS/weekly_full_$TODAYD.log<<EOF
connect target
backup as compressed backupset incremental level = 0 database maxsetsize=20g  format='$RMANBKUP/oracle_sidFULLORABKUP_$TODAYD/%U_%T_.bkp';
sql "alter database backup controlfile to ''/export/home/oracle/rman_script/rmanbkp/oracle_sidFULLORABKUP_$TODAYD/controlfile$TODAYD.ctl''";
crosscheck backupset;
delete noprompt expired backupset;
EOF
exit
--------------------------------------------------------------
---------------------   END OF DOCUMENT ----------------------

2 comments:

  1. Hi Ramesh,

    1. Here you have not mentioned anything about archieve log, as per my information gathering, without archieve log enabling, rman backup(hot backup) cannot be taken..,
    2.Here if we use above script to execute, it must exported or environment variable must be set know, for example "$RMANBKUP" where did exported or setenv??

    ReplyDelete
    Replies
    1. Hi Balaji,

      1. We can take the RMAN backup even "archivelog" not enabled (database should be in "mount" state)
      2. The variable used here are not the ENV variables. Its just a variable wich holds the value through out the progam execution.

      I hope this clarifies.
      -- Ramesh Togara.

      Delete