ADSM-L

Re: [ADSM-L] restore oracle via rman and tsm

2009-06-10 00:51:06
Subject: Re: [ADSM-L] restore oracle via rman and tsm
From: Grigori Solonovitch <G.Solonovitch AT BKME DOT COM>
To: ADSM-L AT VM.MARIST DOT EDU
Date: Wed, 10 Jun 2009 07:44:54 +0300
To restore single datafile (no database recovery):
-------------------------------------------------------------------
#!/bin/sh
#
# Restore datafile for specified database
#
# Input parameters:
#   1 - database SID;
#   2 - datafile name.
#
export ORACLE_SID=$1
export ORACLE_HOME=`grep "$1:" /etc/oratab | head -n1 | cut -f2 -d":"`
export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=$ORACLE_HOME/bin:$PATH
#
rman <<EOF
#
# Connect to Recovery Catalog database
connect catalog $RC_USER/$RC_PASSWORD@$RC_SERVICE;
#
# Connect to target database
connect target;
#
# Recover database by restoring data file
run {
  #
  # Mount database
  startup mount;
  #
  # Allocate channel for restore
  allocate channel t1 type 'sbt_tape' parms
           'ENV=(TDPO_OPTFILE=/home/oracle/admin/tdpo/$1.opt)';
  #
  # Restore data file
  restore datafile "$2";
  #
  # Release channel
  release channel t1;
  #
  # Shutdown database
  shutdown immediate;
}
exit
EOF
---------------------------------------------------------------------------------------

To restore single tablespace (no database recovery):
====================================================
#!/bin/sh
#
# Restore tablespace for specified database
#
# Input parameters:
#   1 - database SID;
#   2 - tablespace name.
#
export ORACLE_SID=$1
export ORACLE_HOME=`grep "$1:" /etc/oratab | head -n1 | cut -f2 -d":"`
export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=$ORACLE_HOME/bin:$PATH
#
rman <<EOF
#
# Connect to Recovery Catalog database
connect catalog $RC_USER/$RC_PASSWORD@$RC_SERVICE;
#
# Connect to target database
connect target;
#
# Recover database by restoring tablespace
run {
  #
  # Mount database
  startup mount;
  #
  # Allocate channel for restore
  allocate channel t1 type 'sbt_tape' parms
           'ENV=(TDPO_OPTFILE=/home/oracle/admin/tdpo/$1.opt)';
  #
  # Restore tablespace
  restore tablespace $2;
  #
  # Release channel
  release channel t1;
  #
  # Shutdown database
  shutdown immediate;
}
exit
EOF
===============================================================

To restore database (complete recovery):
------------------------------------------------------------------------------------------------------------
#!/bin/sh
#
# Restore specified database
# Recover database to crash time (complete recovery)
#
# Input parameters:
#   1 - database SID.
#
export ORACLE_SID=$1
export ORACLE_HOME=`grep "$1:" /etc/oratab | head -n1 | cut -f2 -d":"`
export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=$ORACLE_HOME/bin:$PATH
#
rman <<EOF
#
# Connect to Recovery Catalog database
connect catalog $RC_USER/$RC_PASSWORD@$RC_SERVICE;
#
# Connect to target database
connect target;
#
# Recover database
run {
  #
  # Start up database
  startup mount;
  #
  # Allocate channel for restore and recovery
  allocate channel t1 type 'sbt_tape' parms
           'ENV=(TDPO_OPTFILE=/home/oracle/admin/tdpo/$1.opt)';
  #
  # Restore database
  restore database;
  #
  # Complete media recovery for database
  recover database;
  #
  # Open database
  alter database open;
  #
  # Release channel
  release channel t1;
}
exit
EOF
-------------------------------------------------------------------------------------------------

To restore database (point in time recovery):
============================================================
#!/bin/sh
#
# Restore specified database to point in time
# Recover database to specified time (incomplete recovery)
#
# Input paramaters:
#   1 - database SID;
#   2 - time stamp in format YYYY-MM-DD:HH24:MI:SS;
#   3 - control file copy.
#
export ORACLE_SID=$1
export ORACLE_HOME=`grep "$1:" /etc/oratab | head -n1 | cut -f2 -d":"`
export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=$ORACLE_HOME/bin:$PATH

OPT_FILE=$1"_restore.opt"

rman <<EOF
#
# Connect to Recovery Catalog database
connect catalog $RC_USER/$RC_PASSWORD@$RC_SERVICE;
#
# Connect to target database
connect target;
#
# Restore control file
run {
  #
  # Startup database instance
  startup nomount;
  #
  # Allocate channel for restore and recovery
  allocate channel t1 type 'sbt_tape' parms
           'ENV=(TDPO_OPTFILE=/home/oracle/admin/tdpo/$OPT_FILE)';
  #
  # Set date and time format
  sql 'alter session set NLS_DATE_FORMAT = "YYYY-MM-DD:HH24:MI:SS"';
  #
  # Set recovery time
  set until time '$2';
  #
  # Restore control file
  restore controlfile to '$3';
  #
  # Replicate control file
  replicate controlfile from '$3';
  #
  # Mount database
  alter database mount;
  #
  # Restore database
  restore database;
  #
  # Incomplete media recovery for database
  recover database;
  #
  # Open database and reset logs
  alter database open resetlogs;
  #
  # Release channel
  release channel t1;
}
exit;
EOF
==================================================================


Grigori G. Solonovitch

Senior Technical Architect

Information Technology  Bank of Kuwait and Middle East  http://www.bkme.com

Phone: (+965) 2231-2274  Mobile: (+965) 99798073  E-Mail: G.Solonovitch AT bkme 
DOT com

Please consider the environment before printing this Email


-----Original Message-----
From: ADSM: Dist Stor Manager [mailto:ADSM-L AT VM.MARIST DOT EDU] On Behalf Of 
Tim Brown
Sent: Tuesday, June 09, 2009 10:53 PM
To: ADSM-L AT VM.MARIST DOT EDU
Subject: [ADSM-L] restore oracle via rman and tsm

Can anyone share an rman script that can be used
to restore an oracle tdp backup from a tsm tape storage pool;

Tim Brown
Systems Specialist - Project Leader
Central Hudson Gas & Electric
284 South Ave
Poughkeepsie, NY 12601
Email: tbrown AT cenhud DOT com <mailto:tbrown AT cenhud DOT com>
Phone: 845-486-5643
Fax: 845-486-5921
Cell: 845-235-4255


This message contains confidential information and is only for the intended 
recipient.  If the reader of this message is not the intended recipient, or an 
employee or agent responsible for delivering this message to the intended 
recipient, please notify the sender immediately by replying to this note and 
deleting all copies and attachments.  Thank you.

Please consider the environment before printing this Email.

"This email message and any attachments transmitted with it may contain 
confidential and proprietary information, intended only for the named 
recipient(s). If you have received this message in error, or if you are not the 
named recipient(s), please delete this email after notifying the sender 
immediately. BKME cannot guarantee the integrity of this communication and 
accepts no liability for any damage caused by this email or its attachments due 
to viruses, any other defects, interception or unauthorized modification. The 
information, views, opinions and comments of this message are those of the 
individual and not necessarily endorsed by BKME."

<Prev in Thread] Current Thread [Next in Thread>