电脑技术学习

Oracle 自动冷备份脚本

dn001

冷备份,就是关闭db,物理copy数据文件、日志文件、控制文件、归档文件。

rem ***** COLDBACKUP ORACLE DATABASE ON WINDOWS NT *****

set ShutDownFile=C:ShutDown.SQL
echo connect internal/oracle > %ShutDownFile%
echo shutdown immediate >> %ShutDownFile%
echo startup >> %ShutDownFile%
echo shutdown normal >> %ShutDownFile%
echo exit >> %ShutDownFile%

rem ***** SHUTDOWN THE DATABASE *******
set oracle_sid=dbprim
svrmgrl @%ShutDownFile%

net stop OracleStart%oracle_sid%
net stop OracleService%oracle_sid%

rem ***** SET BACKUP FILES DIRECTORY *****
e:
md oradb
cd oradb
md backups
cd backups

rem *****cold backup for "dbprim" database on 2009-3-17 10:56:40 ... *****

rem ***** COPY FILES *****
rem Redo logs

copy C:ORACLE-DATAREDO03.LOG
copy C:ORACLE-DATAREDO02.LOG
copy C:ORACLE-DATAREDO01.LOG

rem Datafile

copy C:ORACLE-DATADBPRIMSYSTEM01.DBF
copy C:ORACLE-DATADBPRIMUNDOTBS01.DBF
copy C:ORACLE-DATADBPRIMSYSAUX01.DBF
copy C:ORACLE-DATADBPRIMUSERS01.DBF
copy C:ORACLE-DATADBPRIMEXAMPLE01.DBF
copy C:ORACLE-DATADBPRIMORATBS.DBF

6 rows selected

rem Control files

copy C:ORACLE-DATADBPRIMCONTROL01.CTL
copy C:ORACLE-DATADBPRIMCONTROL02.CTL
copy C:ORACLE-DATADBPRIMCONTROL03.CTL

rem *********START UP DATABASE AND SERVICES********
net start OracleService%oracle_sid%
net start OracleStart%oracle_sid%

set StartFile=C:start.SQL
echo connect internal/oracle > %StartFile%
echo startup >> %StartFile%
echo exit >> %StartFile%

set oracle_sid=dbprim
svrmgrl @%StartFile%

del /Q %ShutDownFile%
del /Q %StartFile%
exit
;