set NOWDATE=%date:~0,4%-%date:~5,2%-%date:~8,2%
::用户名
set ORACLE_USERNAME=bzta
::密码
set ORACLE_PASSWORD=bzta
::数据库实例名
set ORACLE_DB=orcl
::文件保存位置
set DATA_CURDIR_A0=F:\ORACLE_BACKUP
set DATA_CURDIR_A1=F:\ORACLE_BACKUP\%NOWDATE%
set DATA_CURDIR_T0=F:\ORACLE_BACKUP\%NOWDATE%
set DATA_CURDIR_T1=F:\ORACLE_BACKUP
::设定保留日期限制
set DAYS=-7
::WinRAR安装路径
set WINRAR=D:\Program Files\WinRAR\WinRAR.exe
::导出条件
set BACK_OPTION=owner=bzta grants=n
if not exist %DATA_CURDIR_A1% mkdir %DATA_CURDIR_A1%
::导出oracle备份文件
exp userid=%ORACLE_USERNAME%/%ORACLE_PASSWORD%@%ORACLE_DB% file=%DATA_CURDIR_T0%/%NOWDATE%.dmp log=%DATA_CURDIR_T0%/%NOWDATE%.log %BACK_OPTION%
"%WINRAR%" a %DATA_CURDIR_T1%/%NOWDATE%.rar %DATA_CURDIR_T0%/%NOWDATE%.*
::删除临时文件
del/f/s/q %DATA_CURDIR_A0%\%NOWDATE%
rd %DATA_CURDIR_A0%\%NOWDATE%
::删除七天前的文件
forfiles /p "%DATA_CURDIR_A0%" /s /m *.* /d %DAYS% /c "cmd /c del @path"