Duplicate db using Shell & RMAN

# Author: Vincent Fenoll another Oracle DBA Montreal

#!/usr/bin/ksh
# SCRIPT: duplicate_db_from_time.sh
################################################
#
# Created: 2009/01/01
# Compatible: Oracle 8i 9i 10g 11g
#
################################################
#
# Duplicate database using rman
#
################################################
#
# PRE-REQUISITES:
#    * Instance: NOMOUNT
#    * local variables setted
#    * Oracle variables setted: log_file_name_convert, db_file_name_convert
#
# EXAMPLE:    ./duplicate_db_from_time.sh sys/***@OLDBASE rman/***@rman "08-03-2009 06:16:49″ host_source
#
# Please modify with your value  :      duplicate target database to NEWBASE
#
################################################


if [ "$ORACLE_HOME" = "" ]; then
        echo "Erreur: ORACLE_HOME must be defined"
        exit 1
fi

if [ "$1" = "" -o "$2" = "" -o "$3" = "" -o "$4" = "" ]; then
        echo "Synt: $0 [connect_target] [connect_rmancatalog] [date=DD-MM-YYYY HH24:MI:SS] [server_source_name]"
        exit 1
fi

export NLS_DATE_FORMAT="DD-MM-YYYY HH24:MI:SS"

$ORACLE_HOME/bin/rman target $1 rcvcat $2 auxiliary / << EOF run { set until time "to_date('$3', 'DD-MM-YYYY HH24:MI:SS')"; allocate auxiliary channel t1 type 'SBT_TAPE'; -- If using Networker send 'NSR_ENV=(NSR_SERVER=networkerxxx, NSR_DATA_VOLUME_POOL=FULLxxx, NSR_CLIENT=$4)'; set command id to 'rman_duplicate_from_time'; duplicate target database to NEWBASE NOFILENAMECHECK; release channel t1; } exit; EOF egrep "RMAN-|ORA-" /tmp/resto_rman_$$.log > /dev/null
  if [ $? -eq 0 ]
  then
    return 12
  fi

  return 0

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.