作業系統級別的熱備份工具(windows)
該工具最早由一個外國人建立的,後來國內有人改過。我針對改後的結果在windows下面除錯成功。有喜歡的朋友可以自己改造。
下面是執行檔案runthis.bat
runthis.bat
REM !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! REM 備份指令碼使用說明: REM 這個指令碼的主要功能是提供Oracle 8.1.7 for nt的熱備份. REM 首先資料庫需要在歸檔方式(ARCHIVELOG).這個指令碼的最初作者 REM 是Craig MacPherson 改進的人是Stephen Morse.但是在指令碼 REM 中對8.1.7 的老版本資料庫支援的不是很好.不能夠正常執行. REM 我將這個指令碼加以改進.具有下面的功能: REM 1.在每次備份的時候能夠自動檢測現有的資料庫表空間.動態生成 REM 所需要的備份內容. REM 2.指令碼執行過程中的log 儲存成以日期為開頭的.log檔案.方便 REM 檢查每次備份和壓縮ftp 的過程. REM 3.將備份內容進行壓縮(rar軟體需要單獨安裝,經過測試的是winrar) REM 並按照日期名的格式生成一個壓縮檔案. REM 4.將壓縮檔案ftp到目標ftp伺服器上. REM 使用方法: REM 1.將runthis.bat 和hotgen.bat 複製到oracel資料庫所在的 REM 機器上. REM 2.根據需要更改SID以及資料庫的使用者名稱和口令.以及備份的目標地址 REM 以及log存放的地方. REM 3.建立計劃任務將runthis.bat新增到系統中制訂每天執行的時間. REM 免責宣告: REM 本人並不是專業DBA人員只是將自己工作當中也一些經驗和大家分享. REM 本指令碼並不是要代替商業備份軟體.對於有能力購買商業軟體的人員 REM 或者公司還是推薦購買商業軟體.同樣,本人也不提供對這個指令碼執行 REM 產生的任何責任.但是如果這個指令碼有任何建議和改進的話,如果您願意 REM 請mail告訴我.我的郵件地址是: REM wanghaobj@bj1860.net REM Backup DataBase Run this REM Author: Hao Wang - 2005年2月28日 REM REM data 存放備份檔案 logs存放日誌 rar存放壓縮檔案 scripts存放備份的過程指令碼 REM !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ECHO . REM Backup DataBase script. LogFile SET logdir=C:\arc_zero\backup\logs REM B_SCRIPT_TARGET B_BACKUP_TARGET SET B_SCRIPT_TARGET=C:\arc_zero\backup\scripts if not exist %logdir%\nul mkdir %logdir% call C:\arc_zero\backup\hot_gen.bat %B_SCRIPT_TARGET% %B_BACKUP_TARGET%>%logdir%\hot_gen%DATE:~0,4%"年"%DATE:~5,2%"月"%DATE:~8,2%"日"%TIME:~0,2%"時"%TIME:~3,2%"分".log call %B_SCRIPT_TARGET%\hot_backup.cmd >%logdir%\hot_backup%DATE:~0,4%"年"%DATE:~5,2%"月"%DATE:~8,2%"日"%TIME:~0,2%"時"%TIME:~3,2%"分".log pause
下面是備份指令碼hot_gen.bat
hot_gen.bat
@ECHO off
REM This script. will create the scripts necessary for a complete hot backup of an Oracle database
REM on NT.
REM Datafiles and controlfiles are backed up in this script.
REM These scripts can then be run in batch. Use the AT
REM scheduler to schedule the backup job.
REM
REM Edit the SID, CONNECT and INIT strings used in this command file.
REM
REM
REM Author: Craig MacPherson - Oracle Corporation Canada Inc. June/97
REM Edited: Stephen Morse - Oracle Corporation US, November 97
REM Edited: Hao Wang - Samsung SDS China 2005-2-28
ECHO.
REM ECHO HOT_GEN.CMD Usage:
REM ECHO Enter HOT_GEN SCRIPT_TARGET BACKUP_TARGET
REM ECHO where SCRIPT_TARGET
REM is the location for the backup scripts e.g. c:\oraback\sid\COLD
REM ECHO and BACKUP_TARGET is the location for the Oracle datafile
REM backups when batch is executed
REM ECHO.
REM pause
REM SETlocal
REM 10-DEC-1999
REM 1) commented the above help
REM and pause out
REM 2) replaced the connects as sysdba by connect internal
REM 25-JAN-2000
REM added SET ORACLE_SID=
REM in hot_backup.cmd
REM 3) Add FTP and Compress Function
REM 2005-2-28
REM example uses SID=TTV817
REM %ORACLE_HOME%=D:\oracle\ora92
REM !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
REM These values cannot be derived, please SET them to reflect your environment
REM !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
SET ORACLE_SID=ZERO
SET ORACLE_HOME=D:\oracle\ora92
REM !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
REM SET O_CONNECT="sys/change_on_install as sysdba"
REM !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
SET O_SQL=connect sys/sys@%ORACLE_SID% as sysdba
SET O_INIT=D:\oracle\admin\zero\pfile\init.ora.10202007154955
SET O_SPFILE=D:\oracle\ora92\database\SPFILEZERO.ORA
SET O_ARC=c:\arc_zero
REM Oracle Binaries
SET O_PLUS=%ORACLE_HOME%\bin\sqlplus.exe /nolog
SET O_COPY=%ORACLE_HOME%\bin\ocopy.exe
REM Ftp User and Passwd
SET F_server=192.168.1.1
SET F_user=oracle
SET F_passwd=oracle
SET F_target=/
REM Compress location
SET O_RAR=D:\Program Files\WinRAR
SET R_PATH=C:\arc_zero\backup\rar
SET O_BACKPATH=C:\arc_zero\backup\data
SET O_SCRIPTPATH=C:\arc_zero\backup\scripts
if %O_SCRIPTPATH%.==. goto help
if %O_BACKPATH%.==. goto help
REM ***************************************************************************
REM HOT BACKUP OF THE DATABASE
REM ***************************************************************************
ECHO.
ECHO **********************************************************
ECHO - Create hot_backup.CMD script. to coordinate all backup activities
ECHO - for AT scheduling
ECHO **********************************************************
ECHO.
ECHO REM Backup the init file >%O_SCRIPTPATH%\hot_backup.CMD
ECHO set path=%O_RAR%;%path% >>%O_SCRIPTPATH%\hot_backup.CMD
ECHO copy %O_INIT% %O_BACKPATH% >>%O_SCRIPTPATH%\hot_backup.CMD
ECHO copy %O_SPFILE% %O_BACKPATH% >>%O_SCRIPTPATH%\hot_backup.CMD
ECHO copy %O_ARC%\ARC*.* %O_BACKPATH% >>%O_SCRIPTPATH%\hot_backup.CMD
ECHO SET ORACLE_SID=%ORACLE_SID% >>%O_SCRIPTPATH%\hot_backup.CMD
ECHO REM Run the svrmgr script. to backup the datafiles >>%O_SCRIPTPATH%\hot_backup.CMD
ECHO %O_PLUS% @%O_SCRIPTPATH%\svrmgr1.sql >>%O_SCRIPTPATH%\hot_backup.CMD
ECHO REM Run the svrmgr2.sql script. to backup the controlfiles >>%O_SCRIPTPATH%\hot_backup.CMD
ECHO %O_PLUS% @%O_SCRIPTPATH%\svrmgr2.sql >>%O_SCRIPTPATH%\hot_backup.CMD
ECHO REM compress %O_BACKPATH% FILES >>%O_SCRIPTPATH%\hot_backup.CMD
ECHO winrar.exe a %R_PATH%\hot_back%DATE:~0,4%"年"%DATE:~5,2%"月"%DATE:~8,2%"日"%TIME:~0,2%"時"%TIME:~3,2%"分".rar %O_BACKPATH%\*.* >>%O_SCRIPTPATH%\hot_backup.CMD
ECHO %F_user%>%O_SCRIPTPATH%\FTP_CMD.txt
ECHO %F_passwd%>>%O_SCRIPTPATH%\FTP_CMD.txt
ECHO bin>>%O_SCRIPTPATH%\FTP_CMD.txt
ECHO cd %F_target%>>%O_SCRIPTPATH%\FTP_CMD.txt
ECHO mput %R_PATH%\%date:~4,4%%date:~9,2%%date:~12,2%.rar>>%O_SCRIPTPATH%\FTP_CMD.txt
ECHO BYE>>%O_SCRIPTPATH%\FTP_CMD.txt
ECHO ftp -i -s:%O_SCRIPTPATH%\FTP_CMD.txt %F_server% >>%O_SCRIPTPATH%\hot_backup.CMD
REM ECHO del /S/F/Q %R_PATH%\*.* >>%O_SCRIPTPATH%\hot_backup.CMD
ECHO del /S/F/Q %O_BACKPATH%\*.* >>%O_SCRIPTPATH%\hot_backup.CMD
ECHO.
ECHO **********************************************************
ECHO -- Create a SQL*PLUS script. for the datafile backups
ECHO **********************************************************
ECHO.
ECHO connect sys/sys@%ORACLE_SID% as sysdba >%O_SCRIPTPATH%\plus1.sql
ECHO SET heading off; >>%O_SCRIPTPATH%\plus1.sql
ECHO SET feedback off; >>%O_SCRIPTPATH%\plus1.sql
ECHO SET linesize 1000; >>%O_SCRIPTPATH%\plus1.sql
ECHO spool %O_SCRIPTPATH%\svrmgr1.sql; >>%O_SCRIPTPATH%\plus1.sql
ECHO select 'connect sys/sys@%ORACLE_SID% as sysdba' from dual;>>%O_SCRIPTPATH%\plus1.sql
ECHO select 'alter system archive log current;' from dual; >>%O_SCRIPTPATH%\plus1.sql
ECHO select 'alter system switch logfile;' from dual; >>%O_SCRIPTPATH%\plus1.sql
ECHO Select 'host start /wait D:\oracle\ora92\bin\ocopy.exe '^|^|Member^|^|' %O_BACKPATH%;' From v$logfile; >>%O_SCRIPTPATH%\plus1.sql
ECHO select 'alter tablespace '^|^|tablespace_name^|^|' begin backup;'^|^|' >>%O_SCRIPTPATH%\plus1.sql
ECHO '^|^|'host start /wait %O_COPY% '^|^|file_name^|^|' %O_BACKPATH%;'^|^|' >>%O_SCRIPTPATH%\plus1.sql
ECHO '^|^|'alter tablespace '^|^|tablespace_name^|^|' end backup;' from dba_data_files; >>%O_SCRIPTPATH%\plus1.sql
ECHO select 'alter system switch logfile;' from dual; >>%O_SCRIPTPATH%\plus1.sql
ECHO select 'exit;' from dual; >>%O_SCRIPTPATH%\plus1.sql
ECHO exit; >>%O_SCRIPTPATH%\plus1.sql
ECHO.
ECHO **********************************************************
ECHO -- Run the sql*plus script. to create the svrmgr1.sql script
ECHO **********************************************************
ECHO.
%O_PLUS% @%O_SCRIPTPATH%\plus1.sql
ECHO.
ECHO **********************************************************
ECHO -- Create a SQL*PLUS script. for the control files
ECHO **********************************************************
ECHO.
ECHO connect sys/sys@%ORACLE_SID% as sysdba >%O_SCRIPTPATH%\plus2.sql
ECHO SET heading off; >>%O_SCRIPTPATH%\plus2.sql
ECHO SET feedback off; >>%O_SCRIPTPATH%\plus2.sql
ECHO SET linesize 1000; >>%O_SCRIPTPATH%\plus2.sql
ECHO spool %O_SCRIPTPATH%\svrmgr2.sql; >>%O_SCRIPTPATH%\plus2.sql
ECHO select 'connect sys/sys@%ORACLE_SID% as sysdba' from dual;>>%O_SCRIPTPATH%\plus2.sql
ECHO select 'alter database backup controlfile to '''^|^|'%O_BACKPATH%\'^|^|substr(name,instr(name,'\',-1)+1)^|^|''' REUSE;' from v$controlfile; >>%O_SCRIPTPATH%\plus2.sql
ECHO select 'alter database backup controlfile to trace;' from dual; >>%O_SCRIPTPATH%\plus2.sql
ECHO select 'exit;' from dual; >>%O_SCRIPTPATH%\plus2.sql
ECHO spool off; >>%O_SCRIPTPATH%\plus2.sql
ECHO exit; >>%O_SCRIPTPATH%\plus2.sql
ECHO.
ECHO **********************************************************
ECHO -- Run the sql*plus script. to create the svrmgr2.sql scripts
ECHO **********************************************************
ECHO.
%O_PLUS% @%O_SCRIPTPATH%\plus2.sql
ECHO.
ECHO **********************************************************
ECHO -- Hot Backup Complete
ECHO **********************************************************
ECHO.
goto END_OF_FILE;
REM ***************************************************************************
REM USER HELP
REM ***************************************************************************
:HELP
ECHO.
ECHO HOT_GEN.CMD Usage:
ECHO Enter HOT_GEN SCRIPT_TARGET BACKUP_TARGET
ECHO where SCRIPT_TARGET is the location for the backup
ECHO scripts e.g. c:\oraback\sid\HOT
ECHO and BACKUP_TARGET is the location for the Oracle datafile backups when batch is executed
ECHO.
goto END_OF_FILE
:HELP2
ECHO.
ECHO Error - Cannot write to %O_BACKPATH%
ECHO.
goto END_OF_FILE
REM ***************************************************************************
REM HANDLE ERRORS HERE
REM ***************************************************************************
findstr /in "error" %O_BACKPATH%\backup.log
&& findstr /in "error" %O_BACKPATH%\backup.log >%O_BACKPATH%\error.log
findstr /in "ora-" %O_BACKPATH%\backup.log
&& findstr /in "ora-" %O_BACKPATH%\backup.log >%O_BACKPATH%\error.log
findstr /in "cannot" %O_BACKPATH%\backup.log
&& findstr /in "cannot" %O_BACKPATH%\backup.log >%O_BACKPATH%\error.log
findstr /in "not logged" %O_BACKPATH%\backup.log
&& findstr /in "not logged" %O_BACKPATH%\backup.log >%O_BACKPATH%\error.log
findstr /in "failure" %O_BACKPATH%\backup.log
&& findstr /in "failure" %O_BACKPATH%\backup.log >%O_BACKPATH%\error.log
if exist %O_BACKPATH%\error.log c:\ntreskit\logevent -s E "BACKUP FAILURE!"
pause
endlocal
:END_OF_FILE
下面是執行檔案runthis.bat
runthis.bat
REM !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! REM 備份指令碼使用說明: REM 這個指令碼的主要功能是提供Oracle 8.1.7 for nt的熱備份. REM 首先資料庫需要在歸檔方式(ARCHIVELOG).這個指令碼的最初作者 REM 是Craig MacPherson 改進的人是Stephen Morse.但是在指令碼 REM 中對8.1.7 的老版本資料庫支援的不是很好.不能夠正常執行. REM 我將這個指令碼加以改進.具有下面的功能: REM 1.在每次備份的時候能夠自動檢測現有的資料庫表空間.動態生成 REM 所需要的備份內容. REM 2.指令碼執行過程中的log 儲存成以日期為開頭的.log檔案.方便 REM 檢查每次備份和壓縮ftp 的過程. REM 3.將備份內容進行壓縮(rar軟體需要單獨安裝,經過測試的是winrar) REM 並按照日期名的格式生成一個壓縮檔案. REM 4.將壓縮檔案ftp到目標ftp伺服器上. REM 使用方法: REM 1.將runthis.bat 和hotgen.bat 複製到oracel資料庫所在的 REM 機器上. REM 2.根據需要更改SID以及資料庫的使用者名稱和口令.以及備份的目標地址 REM 以及log存放的地方. REM 3.建立計劃任務將runthis.bat新增到系統中制訂每天執行的時間. REM 免責宣告: REM 本人並不是專業DBA人員只是將自己工作當中也一些經驗和大家分享. REM 本指令碼並不是要代替商業備份軟體.對於有能力購買商業軟體的人員 REM 或者公司還是推薦購買商業軟體.同樣,本人也不提供對這個指令碼執行 REM 產生的任何責任.但是如果這個指令碼有任何建議和改進的話,如果您願意 REM 請mail告訴我.我的郵件地址是: REM wanghaobj@bj1860.net REM Backup DataBase Run this REM Author: Hao Wang - 2005年2月28日 REM REM data 存放備份檔案 logs存放日誌 rar存放壓縮檔案 scripts存放備份的過程指令碼 REM !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ECHO . REM Backup DataBase script. LogFile SET logdir=C:\arc_zero\backup\logs REM B_SCRIPT_TARGET B_BACKUP_TARGET SET B_SCRIPT_TARGET=C:\arc_zero\backup\scripts if not exist %logdir%\nul mkdir %logdir% call C:\arc_zero\backup\hot_gen.bat %B_SCRIPT_TARGET% %B_BACKUP_TARGET%>%logdir%\hot_gen%DATE:~0,4%"年"%DATE:~5,2%"月"%DATE:~8,2%"日"%TIME:~0,2%"時"%TIME:~3,2%"分".log call %B_SCRIPT_TARGET%\hot_backup.cmd >%logdir%\hot_backup%DATE:~0,4%"年"%DATE:~5,2%"月"%DATE:~8,2%"日"%TIME:~0,2%"時"%TIME:~3,2%"分".log pause
下面是備份指令碼hot_gen.bat
hot_gen.bat
@ECHO off
REM This script. will create the scripts necessary for a complete hot backup of an Oracle database
REM on NT.
REM Datafiles and controlfiles are backed up in this script.
REM These scripts can then be run in batch. Use the AT
REM scheduler to schedule the backup job.
REM
REM Edit the SID, CONNECT and INIT strings used in this command file.
REM
REM
REM Author: Craig MacPherson - Oracle Corporation Canada Inc. June/97
REM Edited: Stephen Morse - Oracle Corporation US, November 97
REM Edited: Hao Wang - Samsung SDS China 2005-2-28
ECHO.
REM ECHO HOT_GEN.CMD Usage:
REM ECHO Enter HOT_GEN SCRIPT_TARGET BACKUP_TARGET
REM ECHO where SCRIPT_TARGET
REM is the location for the backup scripts e.g. c:\oraback\sid\COLD
REM ECHO and BACKUP_TARGET is the location for the Oracle datafile
REM backups when batch is executed
REM ECHO.
REM pause
REM SETlocal
REM 10-DEC-1999
REM 1) commented the above help
REM and pause out
REM 2) replaced the connects as sysdba by connect internal
REM 25-JAN-2000
REM added SET ORACLE_SID=
REM in hot_backup.cmd
REM 3) Add FTP and Compress Function
REM 2005-2-28
REM example uses SID=TTV817
REM %ORACLE_HOME%=D:\oracle\ora92
REM !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
REM These values cannot be derived, please SET them to reflect your environment
REM !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
SET ORACLE_SID=ZERO
SET ORACLE_HOME=D:\oracle\ora92
REM !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
REM SET O_CONNECT="sys/change_on_install as sysdba"
REM !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
SET O_SQL=connect sys/sys@%ORACLE_SID% as sysdba
SET O_INIT=D:\oracle\admin\zero\pfile\init.ora.10202007154955
SET O_SPFILE=D:\oracle\ora92\database\SPFILEZERO.ORA
SET O_ARC=c:\arc_zero
REM Oracle Binaries
SET O_PLUS=%ORACLE_HOME%\bin\sqlplus.exe /nolog
SET O_COPY=%ORACLE_HOME%\bin\ocopy.exe
REM Ftp User and Passwd
SET F_server=192.168.1.1
SET F_user=oracle
SET F_passwd=oracle
SET F_target=/
REM Compress location
SET O_RAR=D:\Program Files\WinRAR
SET R_PATH=C:\arc_zero\backup\rar
SET O_BACKPATH=C:\arc_zero\backup\data
SET O_SCRIPTPATH=C:\arc_zero\backup\scripts
if %O_SCRIPTPATH%.==. goto help
if %O_BACKPATH%.==. goto help
REM ***************************************************************************
REM HOT BACKUP OF THE DATABASE
REM ***************************************************************************
ECHO.
ECHO **********************************************************
ECHO - Create hot_backup.CMD script. to coordinate all backup activities
ECHO - for AT scheduling
ECHO **********************************************************
ECHO.
ECHO REM Backup the init file >%O_SCRIPTPATH%\hot_backup.CMD
ECHO set path=%O_RAR%;%path% >>%O_SCRIPTPATH%\hot_backup.CMD
ECHO copy %O_INIT% %O_BACKPATH% >>%O_SCRIPTPATH%\hot_backup.CMD
ECHO copy %O_SPFILE% %O_BACKPATH% >>%O_SCRIPTPATH%\hot_backup.CMD
ECHO copy %O_ARC%\ARC*.* %O_BACKPATH% >>%O_SCRIPTPATH%\hot_backup.CMD
ECHO SET ORACLE_SID=%ORACLE_SID% >>%O_SCRIPTPATH%\hot_backup.CMD
ECHO REM Run the svrmgr script. to backup the datafiles >>%O_SCRIPTPATH%\hot_backup.CMD
ECHO %O_PLUS% @%O_SCRIPTPATH%\svrmgr1.sql >>%O_SCRIPTPATH%\hot_backup.CMD
ECHO REM Run the svrmgr2.sql script. to backup the controlfiles >>%O_SCRIPTPATH%\hot_backup.CMD
ECHO %O_PLUS% @%O_SCRIPTPATH%\svrmgr2.sql >>%O_SCRIPTPATH%\hot_backup.CMD
ECHO REM compress %O_BACKPATH% FILES >>%O_SCRIPTPATH%\hot_backup.CMD
ECHO winrar.exe a %R_PATH%\hot_back%DATE:~0,4%"年"%DATE:~5,2%"月"%DATE:~8,2%"日"%TIME:~0,2%"時"%TIME:~3,2%"分".rar %O_BACKPATH%\*.* >>%O_SCRIPTPATH%\hot_backup.CMD
ECHO %F_user%>%O_SCRIPTPATH%\FTP_CMD.txt
ECHO %F_passwd%>>%O_SCRIPTPATH%\FTP_CMD.txt
ECHO bin>>%O_SCRIPTPATH%\FTP_CMD.txt
ECHO cd %F_target%>>%O_SCRIPTPATH%\FTP_CMD.txt
ECHO mput %R_PATH%\%date:~4,4%%date:~9,2%%date:~12,2%.rar>>%O_SCRIPTPATH%\FTP_CMD.txt
ECHO BYE>>%O_SCRIPTPATH%\FTP_CMD.txt
ECHO ftp -i -s:%O_SCRIPTPATH%\FTP_CMD.txt %F_server% >>%O_SCRIPTPATH%\hot_backup.CMD
REM ECHO del /S/F/Q %R_PATH%\*.* >>%O_SCRIPTPATH%\hot_backup.CMD
ECHO del /S/F/Q %O_BACKPATH%\*.* >>%O_SCRIPTPATH%\hot_backup.CMD
ECHO.
ECHO **********************************************************
ECHO -- Create a SQL*PLUS script. for the datafile backups
ECHO **********************************************************
ECHO.
ECHO connect sys/sys@%ORACLE_SID% as sysdba >%O_SCRIPTPATH%\plus1.sql
ECHO SET heading off; >>%O_SCRIPTPATH%\plus1.sql
ECHO SET feedback off; >>%O_SCRIPTPATH%\plus1.sql
ECHO SET linesize 1000; >>%O_SCRIPTPATH%\plus1.sql
ECHO spool %O_SCRIPTPATH%\svrmgr1.sql; >>%O_SCRIPTPATH%\plus1.sql
ECHO select 'connect sys/sys@%ORACLE_SID% as sysdba' from dual;>>%O_SCRIPTPATH%\plus1.sql
ECHO select 'alter system archive log current;' from dual; >>%O_SCRIPTPATH%\plus1.sql
ECHO select 'alter system switch logfile;' from dual; >>%O_SCRIPTPATH%\plus1.sql
ECHO Select 'host start /wait D:\oracle\ora92\bin\ocopy.exe '^|^|Member^|^|' %O_BACKPATH%;' From v$logfile; >>%O_SCRIPTPATH%\plus1.sql
ECHO select 'alter tablespace '^|^|tablespace_name^|^|' begin backup;'^|^|' >>%O_SCRIPTPATH%\plus1.sql
ECHO '^|^|'host start /wait %O_COPY% '^|^|file_name^|^|' %O_BACKPATH%;'^|^|' >>%O_SCRIPTPATH%\plus1.sql
ECHO '^|^|'alter tablespace '^|^|tablespace_name^|^|' end backup;' from dba_data_files; >>%O_SCRIPTPATH%\plus1.sql
ECHO select 'alter system switch logfile;' from dual; >>%O_SCRIPTPATH%\plus1.sql
ECHO select 'exit;' from dual; >>%O_SCRIPTPATH%\plus1.sql
ECHO exit; >>%O_SCRIPTPATH%\plus1.sql
ECHO.
ECHO **********************************************************
ECHO -- Run the sql*plus script. to create the svrmgr1.sql script
ECHO **********************************************************
ECHO.
%O_PLUS% @%O_SCRIPTPATH%\plus1.sql
ECHO.
ECHO **********************************************************
ECHO -- Create a SQL*PLUS script. for the control files
ECHO **********************************************************
ECHO.
ECHO connect sys/sys@%ORACLE_SID% as sysdba >%O_SCRIPTPATH%\plus2.sql
ECHO SET heading off; >>%O_SCRIPTPATH%\plus2.sql
ECHO SET feedback off; >>%O_SCRIPTPATH%\plus2.sql
ECHO SET linesize 1000; >>%O_SCRIPTPATH%\plus2.sql
ECHO spool %O_SCRIPTPATH%\svrmgr2.sql; >>%O_SCRIPTPATH%\plus2.sql
ECHO select 'connect sys/sys@%ORACLE_SID% as sysdba' from dual;>>%O_SCRIPTPATH%\plus2.sql
ECHO select 'alter database backup controlfile to '''^|^|'%O_BACKPATH%\'^|^|substr(name,instr(name,'\',-1)+1)^|^|''' REUSE;' from v$controlfile; >>%O_SCRIPTPATH%\plus2.sql
ECHO select 'alter database backup controlfile to trace;' from dual; >>%O_SCRIPTPATH%\plus2.sql
ECHO select 'exit;' from dual; >>%O_SCRIPTPATH%\plus2.sql
ECHO spool off; >>%O_SCRIPTPATH%\plus2.sql
ECHO exit; >>%O_SCRIPTPATH%\plus2.sql
ECHO.
ECHO **********************************************************
ECHO -- Run the sql*plus script. to create the svrmgr2.sql scripts
ECHO **********************************************************
ECHO.
%O_PLUS% @%O_SCRIPTPATH%\plus2.sql
ECHO.
ECHO **********************************************************
ECHO -- Hot Backup Complete
ECHO **********************************************************
ECHO.
goto END_OF_FILE;
REM ***************************************************************************
REM USER HELP
REM ***************************************************************************
:HELP
ECHO.
ECHO HOT_GEN.CMD Usage:
ECHO Enter HOT_GEN SCRIPT_TARGET BACKUP_TARGET
ECHO where SCRIPT_TARGET is the location for the backup
ECHO scripts e.g. c:\oraback\sid\HOT
ECHO and BACKUP_TARGET is the location for the Oracle datafile backups when batch is executed
ECHO.
goto END_OF_FILE
:HELP2
ECHO.
ECHO Error - Cannot write to %O_BACKPATH%
ECHO.
goto END_OF_FILE
REM ***************************************************************************
REM HANDLE ERRORS HERE
REM ***************************************************************************
findstr /in "error" %O_BACKPATH%\backup.log
&& findstr /in "error" %O_BACKPATH%\backup.log >%O_BACKPATH%\error.log
findstr /in "ora-" %O_BACKPATH%\backup.log
&& findstr /in "ora-" %O_BACKPATH%\backup.log >%O_BACKPATH%\error.log
findstr /in "cannot" %O_BACKPATH%\backup.log
&& findstr /in "cannot" %O_BACKPATH%\backup.log >%O_BACKPATH%\error.log
findstr /in "not logged" %O_BACKPATH%\backup.log
&& findstr /in "not logged" %O_BACKPATH%\backup.log >%O_BACKPATH%\error.log
findstr /in "failure" %O_BACKPATH%\backup.log
&& findstr /in "failure" %O_BACKPATH%\backup.log >%O_BACKPATH%\error.log
if exist %O_BACKPATH%\error.log c:\ntreskit\logevent -s E "BACKUP FAILURE!"
pause
endlocal
:END_OF_FILE
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/79499/viewspace-154153/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- windows10如何備份系統_windows10製作系統備份Windows
- win10 windows server backup備份方法_windows10怎麼備份作業系統Win10WindowsServer作業系統
- 作業系統備份清單作業系統
- Windows XP 輕鬆實現作業系統備份與還原(轉)Windows作業系統
- Oracle 熱備份和冷備份的區別Oracle
- Windows作業系統Windows作業系統
- 初級安全入門——Windows作業系統的安全加固Windows作業系統
- Windows作業系統教程Windows作業系統
- Linux作業系統定時備份檔案方法Linux作業系統
- UI 測試的作業系統級別的錄製 / 回放UI作業系統
- Windows備份工具——FreeFileSyncWindows
- windows 作業系統裡 git bash 和 git cmd 的區別Windows作業系統Git
- Linux作業系統執行級別介紹Linux作業系統
- 【物理熱備】(下)備份恢復系統表空間 手工備份恢復
- 升級AIX作業系統AI作業系統
- Steam:64位Windows 10作業系統的市場份額為44.94%Windows作業系統
- 獲取windows 作業系統下的硬體或作業系統資訊等Windows作業系統
- 0級備份和全備份的本質區別
- RMAN 全庫備份和 0級備份的區別
- Aix作業系統SMIT工具AI作業系統MIT
- 作業系統資訊收集工具作業系統
- AIX作業系統下的用磁帶進行備份操作步驟AI作業系統
- Linux作業系統中備份恢復技術的應用(轉)Linux作業系統
- Java識別作業系統Java作業系統
- 資訊系統運維中的熱備、備份和歸檔的不同運維
- windows 作業系統映象下載Windows作業系統
- Windows 8 作業系統入門Windows作業系統
- MYSQL 企業級備份MySql
- mysql的冷備份與熱備份MySql
- oracle的熱備份和冷備份Oracle
- Windows作業系統的基本攻擊方式Windows作業系統
- Windows作業系統的防黑經驗Windows作業系統
- 重新整理WINDOWS作業系統的DNSWindows作業系統DNS
- 安卓備份系統教程安卓備份系統教程安卓
- Windows10系統備份驅動的方法【圖文】Windows
- Windows XP系統資料的備份和恢復(轉)Windows
- 國產作業系統如何追趕windows?作業系統Windows
- 計算機重灌Windows作業系統計算機Windows作業系統