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_passw...@$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_passw...@$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_passw...@$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_passw...@$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.solonovi...@bkme.com Please consider the environment before printing this Email -----Original Message----- From: ADSM: Dist Stor Manager [mailto:ads...@vm.marist.edu] On Behalf Of Tim Brown Sent: Tuesday, June 09, 2009 10:53 PM To: ADSM-L@VM.MARIST.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: tbr...@cenhud.com <mailto:tbr...@cenhud.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."