发布网友 发布时间:2022-04-20 00:03
共1个回答
热心网友 时间:2022-04-08 12:39
利用任务计划、批处理文件和ORACLE的EXP导出功能,可以根据日期自动生成ORACLE备份文件,大大方便了ORACLE数据备份。
建议一(做周备份并压缩为RAR)以下为ORACLE 自动备份批处理文件内容,请配合任务计划实现 :
例:
@ECHO OFF
SET BACKPATH=d:\
ECHO 准备备份数据库
REM 7天一个循环
IF EXIST %BACKPATH%\ONE GOTO ONE
IF EXIST %BACKPATH%\TWO GOTO TWO
IF EXIST %BACKPATH%\THREE GOTO THREE
IF EXIST %BACKPATH%\FOUR GOTO FOUR
IF EXIST %BACKPATH%\FIVE GOTO FIVE
IF EXIST %BACKPATH%\SIX GOTO SIX
IF EXIST %BACKPATH%\SEVEN GOTO SEVEN
ECHO E > %BACKPATH%\ONE
:ONE
SET BACKPATH_FULL=%BACKPATH%\ONE
REN %BACKPATH%\ONE TWO
GOTO BACK
:TWO
SET BACKPATH_FULL=%BACKPATH%\TWO
REN %BACKPATH%\TWO THREE
GOTO BACK
:THREE
SET BACKPATH_FULL=%BACKPATH%\THREE
REN %BACKPATH%\THREE FOUR
GOTO BACK
:FOUR
SET BACKPATH_FULL=%BACKPATH%\FOUR
REN %BACKPATH%\FOUR FIVE
GOTO BACK
:FIVE
SET BACKPATH_FULL=%BACKPATH%\FIVE
REN %BACKPATH%\FIVE SIX
GOTO BACK
:SIX
SET BACKPATH_FULL=%BACKPATH%\SIX
REN %BACKPATH%\SIX SEVEN
GOTO BACK
:SEVEN
SET BACKPATH_FULL=%BACKPATH%\SEVEN
REN %BACKPATH%\SEVEN ONE
GOTO BACK
:BACK
EXP ccense/ccense FILE=%BACKPATH_FULL%.DMP
RAR a %BACKPATH_FULL%.rar %BACKPATH_FULL%.DMP
DEL %BACKPATH_FULL%.DMP
SET BACKPATH=
SET BACKPATH_FULL=
EXIT
说明:
文件名以星期来命名
备份后调用rar进行压缩
这样可以保存一个星期的历史数据
注意:需要把program files/winrar目录下的rar.exe拷贝到系统system32目录下
建议二:
1,批处理文件backup.bat\.
exp system/manager file=d:\backup\oracle\oracle%date:~0,10%.dmp owner=system log=d:\backup\oracle\oracle%date:~0,10%.log
将生成oracle2006-01-09.dmp文件
exp system/manager file=d:\backup\oracle\oracle%date:~11,3%.dmp owner=system log=d:\backup\oracle\oracle%date:~11,3%.log
将生成oracle星期一.dmp文件,则每周循环保留一个备份文件,共7个备份文件循环 $date$日期参数可灵活运用。