Home » RDBMS Server » Backup & Recovery » Share: Rman backup scripts, version: 8.1.6 on windows32bit  () 1 Vote
Share: Rman backup scripts, version: 8.1.6 on windows32bit [message #169457] Wed, 26 April 2006 22:24 Go to next message
alexzeng
Messages: 133
Registered: August 2005
Location: alexzeng.wordpress.com
Senior Member
Hi friends,
I have joined in this forum many months. Many of you help me a lot, especially Mahesh Rajendran.

Now I'd like to share a suit of scripts for bakup and restore using rman on windows.

readme.txt
Purpose: Backup whole database by rman and then compress it by winrar, 
         also delete the old backup sets
Auth: Alex zeng | Skype me: hans9zeng
Date: 2006.03.07

1. How to run?
   run run_rman.bat, also you can add it to your schedule tasks list
   check log files run.sql.log and rman logfile F:\backupdata\poi6\rmanbackup\poi6_"date".log

2. What's the purpose of each file?
   run_rman.bat:     main batch script
   run_sql.txt:      sql script for backup controlfile to trace
   rman_cmf.txt:     rman script for backup database and old archived logs
   run_bak_ctl.txt:  sql script for backup controlfile
   restore_steps.txt:steps for restore whole database from backup files
   
3. What's the processes of this scripts?
   Step1. delete old backup files.
   Step2. create controlfile trace file and then copy it to the backup folder
   Step3. rum rman backup scritps 
   Step4. using winrar compress the backup files

4. Which parameters do you need to modify before using?
   paths in run_rman.bat, rman_cmf.txt, run_bak_ctl.txt
   NowDate, Month, Day definition in run_rman.bat according to your windows system.
   winrar in run_rman.bat. You may need add the path of winrar to system path or use absolute path



run_rman.bat
@echo on

echo "----------start----------"
set oracle_sid=poi

set bakscrp_base=D:\backup\rman\poi6
set bakdata_base1=F:\backupdata\poi6
set bakdata_base=F:\backupdata\poi6\rmanbackup
set controlfile_trc=E:\Oracle\admin\poi\udump

set cmdfile=%bakscrp_base%\rman_cmf.txt
set logfile=%bakdata_base%\

set NowDate=%DATE:~-10%
set Month=%NowDate:~5,2%
set Day=%NowDate:~8,2%

set logfile=%logfile%POI6_%Month%%Day%.log
set rarfile=F:\backupdata\poi6\%oracle_sid%_%Month%%Day%_rman.rar

del /Q %bakdata_base1%\*
del /Q %bakdata_base%\*
del /Q %controlfile_trc%\*

sqlplus "/ as sysdba" @run_sql.txt > run.sql.log
move %controlfile_trc%\* %bakdata_base%

rman nocatalog target=sys/oracle msglog=%logfile% cmdfile=%cmdfile%
sqlplus "sys/oracle as sysdba" @run_bak_ctl.txt >> run.sql.log
winrar a %rarfile% %bakdata_base%

echo "----------end----------"


run_sql.txt
alter database backup controlfile to trace;
exit;


rman_cmf.txt
set snapshot controlfile name to 'F:\backupdata\poi6\rmanbackup\snap_ctlfile.ctl';
run
 {
  allocate channel c1 type disk format 'F:\backupdata\poi6\rmanbackup\poi6_%U';
  backup filesperset 4 database;
  sql 'alter system archive log current';
  backup current controlfile;
  release channel c1;
 };
run{
allocate channel c1 type disk format 'F:\backupdata\poi6\rmanbackup\poi6_arch_%U';
backup archivelog until time 'trunc(SYSDATE)-7' delete input;
release channel c1;
};

exit;



run_bak_ctl.txt
alter system archive log current;
alter database backup controlfile to 'F:\backupdata\poi6\rmanbackup\poi6_backup.ctl';
exit;


restore_steps.txt
1. copy initpoi.ora file to E:\Oracle\Ora81\DATABASE\initpoi.ora
copy backup controlfile POI6_BACKUP.CTL to E:\Oracle\oradata\poi\CONTROL01.CTL,CONTROL02.CTL,CONTROL03.CTL

2. startup poi service and mount database
startup mount

3.
rman nocatalog target / 
rman> 
run
  {
   allocate channel c1 type disk format 'F:\backupdata\poi6\rmanbackup\poi6_%U';
   restore database;
   recover database;
   release channel c1;
  }
 exit;

RMAN-06053: unable to perform media recovery because of missing log
RMAN-06025: no backup of log thread 1 seq 28391 scn 496015137 found to restore

4.copy log file to F:\oradata\poi\archive from sequence 28391

5.
SQL> conn / as sysdba
Connected.
SQL> recover database using backup controlfile until cancel;
auto

SQL> recover database using backup controlfile until cancel;
cancel

SQL> alter database open resetlogs;


Any suggestions are welcome!

Alex zeng | Skype me: hans9zeng

[Updated on: Wed, 26 April 2006 22:32]

Report message to a moderator

Re: Share: Rman backup scripts, version: 8.1.6 on windows32bit [message #171271 is a reply to message #169457] Tue, 09 May 2006 04:26 Go to previous messageGo to next message
Frank Naude
Messages: 4587
Registered: April 1998
Senior Member
Great scripts - thanks!
Re: Share: Rman backup scripts, version: 8.1.6 on windows32bit [message #197414 is a reply to message #169457] Wed, 11 October 2006 03:34 Go to previous message
babuknb
Messages: 1736
Registered: December 2005
Location: NJ
Senior Member


This is very usefull for me..

Thanks Razz
Previous Topic: Recovery Question
Next Topic: Control file recovery
Goto Forum:
  


Current Time: Mon Dec 23 11:48:45 CST 2024