Results 1 to 1 of 1
  1. #1
    Join Date
    Aug 2009
    Posts
    55

    Unanswered: relationship between different instance in RMAN

    Hi,
    I have a database and there are several instance in DB like FRWK RCA SAS rman.
    I have below scrip to do database backup .
    But in rman command it only target to rman.
    So, in this script , will the instance FRWK ,RCA ,SAS will be backup ??
    which part of script is doing that ???
    Can you point out ???
    I attach the script in here .
    Below is the script :
    #! /bin/ksh
    ###############################################
    # #
    # Script : db_oracle.bck #
    # #
    # Param : None #
    # Description : #
    # Use RMAN to Backup database <SID> #
    # to BACKUP_DIR #
    # #
    ###############################################

    ###############################################
    # Customized Parameters
    #
    ###############################################

    # LIST_SID = List of Database to backup.
    LIST_SID="FRWK RCA SAS"

    # RMAN_SID = SID of RMAN Database
    RMAN_SID=rman

    # CONNECT_RMAN = Connect string of RMAN Database
    CONNECT_RMAN="rman"

    # RMAN_USER = Name of RMAN User Database
    RMAN_USER="rman"

    # RMAN_PASSWD = Password of RMAN User Database
    RMAN_PASSWD="rman"

    # BACKUP_DIR = directory used by RMAN to backup the files Database
    BACKUP_DIR=/database/backup_data
    export BACKUP_DIR

    # SVG_DIR = Device to backup all files of database
    SVG_DIR=/dev/rmt/0

    # RMAN_DATAFILE_DIRECTORY_LIST = List of directories where RMAN database is installed
    RMAN_DATAFILE_DIRECTORY_LIST="/database/oradata1/rman /database/oradata2/rman"

    SCRIPT_DIRECTORY=/product/WarmBackup
    LOG_DIRECTORY=/product/WarmBackup/log

    # ORACLE_HOME =
    ORACLE_HOME=/opt/oracle/product/9ir2

    # End of section customized parameters
    #############################################


    DATE=`/usr/bin/date +%Y%m%d%OH%OM`
    BACKUP_DATE=${DATE}

    ###############################
    # ENVIRONNEMENT
    ###############################
    # LD_LIBRARY_PATH=
    LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
    # SHLIB_PATH=
    SHLIB_PATH=$SHLIB_PATH:$ORACLE_HOME/lib

    PATH=$PATH:/usr/bin:$ORACLE_HOME/bin
    NLS_LANG=american_america.UTF8
    export NLS_LANG

    export PATH
    export ORACLE_HOME
    export LD_LIBRARY_PATH
    export SHLIB_PATH

    ##############################
    # BEGIN BACKUP
    ##############################
    # Log name
    LOG_FILE=${LOG_DIRECTORY}/${BACKUP_DATE}_bck_db.log

    # Creating log file to permission
    /usr/bin/touch ${LOG_FILE}
    /usr/bin/chmod ug+rw ${LOG_FILE}

    DATE=`/usr/bin/date +"%x %X"`
    /usr/bin/echo "${DATE}: Begin Backup ${BACKUP_DATE}" >> ${LOG_FILE}
    /usr/bin/echo "" >> ${LOG_FILE}

    # Create a new archive with a flag file
    /usr/bin/echo "${BACKUP_DATE}" > ${LOG_DIRECTORY}/flag_${BACKUP_DATE}.file
    /usr/bin/tar -cvpf ${SVG_DIR} ${LOG_DIRECTORY}/flag_${BACKUP_DATE}.file 1>>${LOG_FILE} 2>>${LOG_FILE}
    if [ $? -eq 0 ]
    then
    /usr/bin/rm -f ${LOG_DIRECTORY}/flag_${BACKUP_DATE}.file
    fi


    ##############################
    # DATABASE(S) BACKUP
    ##############################
    # For each database
    for instance in $LIST_SID
    do
    ORACLE_SID=$instance
    export ORACLE_SID

    DATE=`/usr/bin/date +"%x %X"`
    echo "${DATE}: Database ${ORACLE_SID}" >> ${LOG_FILE}

    /usr/bin/echo "${DATE}: Tar init${ORACLE_SID}.ora on ${SVG_DIR}" >> ${LOG_FILE}
    /usr/bin/tar -rhvfp ${SVG_DIR} ${ORACLE_HOME}/dbs/init${ORACLE_SID}.ora 1>>${LOG_FILE} 2>>${LOG_FILE}
    /usr/bin/echo "" >> ${LOG_FILE}

    # Execute RMAN command to Backup
    DATE=`/usr/bin/date +"%x %X"`
    /usr/bin/echo "${DATE}: Execute RMAN command" >> ${LOG_FILE}

    # Build full backup script
    /usr/bin/touch ${LOG_DIRECTORY}/~db_full_backup.rman
    /usr/bin/chmod ug+rw ${LOG_DIRECTORY}/~db_full_backup.rman
    export dir_tmp=`echo $BACKUP_DIR|sed -e "s:\/:\\\\\/:g"`
    sed -e "s/%BACKUP_DIR%/`echo $dir_tmp`/g" $SCRIPT_DIRECTORY/script/db_full_backup.rman >> ${LOG_DIRECTORY}/~db_full_backup.rman

    # Execute RMAN command to Backup
    DATE=`/usr/bin/date +"%x %X"`
    /usr/bin/echo "${DATE}: Execute RMAN command" >> ${LOG_FILE}
    $ORACLE_HOME/bin/rman target / catalog ${RMAN_USER}/${RMAN_PASSWD}@${CONNECT_RMAN} @${LOG_DIRECTORY}/~db_full_backup.rman >> ${LOG_FILE}

    # Delete temporary script file
    rm -f ${LOG_DIRECTORY}/~db_full_backup.rman

    # Move Oracle Bakup File Set to SVG_DIR
    DATE=`/usr/bin/date +"%x %X"`
    /usr/bin/echo "${DATE}: Tar Backup File to ${SVG_DIR}" >> ${LOG_FILE}
    cd ${BACKUP_DIR}
    /usr/bin/tar -rvpf ${SVG_DIR} ./ 1>>${LOG_FILE} 2>>${LOG_FILE}
    if [ $? -eq 0 ]
    then
    /usr/bin/echo "Suppress Backup File to ${BACKUP_DIR}" >> ${LOG_FILE}
    /usr/bin/rm -f ${BACKUP_DIR}/* 1>>${LOG_FILE} 2>>${LOG_FILE}
    fi

    /usr/bin/echo "" >> ${LOG_FILE}
    done

    ##############################
    # Backup RMAN Database Catalog
    ##############################
    # Shutdown RMAN Database Catolog if on same server
    ORACLE_SID=${RMAN_SID}
    export ORACLE_SID

    demarre=`ps -ef | grep ${ORACLE_SID} | grep ora_ | grep -v grep | wc -l`
    if [ ${demarre} -le 4 ]
    then
    /usr/bin/echo "RMAN Database ${ORACLE_SID} is on another server" >>${LOG_FILE}
    /usr/bin/echo "No backup can be done..." >>${LOG_FILE}
    # Date of end Backup
    DATE=`/usr/bin/date +"%x %X"`
    /usr/bin/echo "End of Backup at ${DATE}" >> ${LOG_FILE}
    exit
    fi

    DATE=`/usr/bin/date +"%x %X"`
    /usr/bin/echo "${DATE}: Backup RMAN database" >> ${LOG_FILE}
    /usr/bin/echo "" >> ${LOG_FILE}

    /usr/bin/echo "Shutdown RMAN database : ${ORACLE_SID}" >> ${LOG_FILE}
    $ORACLE_HOME/bin/sqlplus -s "/ as sysdba" <<EOF 1>>${LOG_FILE} 2>>${LOG_FILE}
    shutdown immediate
    EOF

    # Backup database files
    cd ${BACKUP_DIR}
    RMAN_TAR=${BACKUP_DIR}/rman_${BACKUP_DATE}.tar
    DATE=`/usr/bin/date +"%x %X"`
    /usr/bin/echo "${DATE}: Backup database files" >> ${LOG_FILE}

    /usr/bin/tar -cvfp ${RMAN_TAR} ${RMAN_DATAFILE_DIRECTORY_LIST} 1>>${LOG_FILE} 2>>${LOG_FILE}

    # Inititialization files
    DATE=`/usr/bin/date +"%x %X"`
    /usr/bin/echo "${DATE}: Backup initialization file" >> ${LOG_FILE}
    /usr/bin/tar -rhvfp ${RMAN_TAR} ${ORACLE_HOME}/dbs/init${ORACLE_SID}.ora 1>>${LOG_FILE} 2>>${LOG_FILE}

    # Startup RMAN Database Catolog
    DATE=`/usr/bin/date +"%x %X"`
    echo "${DATE}: Startup RMAN database : ${ORACLE_SID}" >> ${LOG_FILE}
    $ORACLE_HOME/bin/sqlplus -s "/ as sysdba" <<EOF 1>>${LOG_FILE} 2>>${LOG_FILE}
    startup
    EOF

    # Tar RMAN on SVG_DIR
    DATE=`/usr/bin/date +"%x %X"`
    /usr/bin/echo "${DATE}: Tar Backup RMAN on ${SVG_DIR}" >> ${LOG_FILE}
    /usr/bin/tar -rvfp ${SVG_DIR} rman_${BACKUP_DATE}.tar 1>>${LOG_FILE} 2>>${LOG_FILE}
    if [ $? -eq 0 ]
    then
    /usr/bin/echo "Remove ${RMAN_TAR}" >> ${LOG_FILE}
    /usr/bin/rm -f ${RMAN_TAR} 1>>${LOG_FILE} 2>>${LOG_FILE}
    fi

    # Date of end Backup
    DATE=`/usr/bin/date +"%x %X"`
    echo "End of Backup at ${DATE}" >> ${LOG_FILE}
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •