expdb命令版本
@echo off
REM ###########################################################
REM # Windows Server下Oracle数据库自动备份批处理脚本
REM # 使用expdb命令导出需要先在数据库中创建备份文件存贮目录,sql如下:
REM # create or replace directory IRS_DATA_BAK_DIR as 'D:\oraclebak';
REM ###########################################################
REM 取当前系统时间,可能因操作系统不同而取值不一样
set CURDATE=%date:~,%%date:~,%%date:~,%
set CURMON=%date:~,%%date:~,%
set CURTIME=%time:~,%
REM 小时数如果小于10,则在前面补0
if "%CURTIME%"=="" set CURTIME=
if "%CURTIME%"=="" set CURTIME=
if "%CURTIME%"=="" set CURTIME=
if "%CURTIME%"=="" set CURTIME=
if "%CURTIME%"=="" set CURTIME=
if "%CURTIME%"=="" set CURTIME=
if "%CURTIME%"=="" set CURTIME=
if "%CURTIME%"=="" set CURTIME=
if "%CURTIME%"=="" set CURTIME=
if "%CURTIME%"=="" set CURTIME=
set CURTIME=%CURTIME%%time:~,%%time:~,%
REM 设置所有者、用户名和密码
set OWNER=orcl
set USER=app
set PASSWORD=app
REM 创建备份用目录,目录结构为oraclebak/
REM 切换目录
d:
if not exist "oraclebak" mkdir oraclebak
cd oraclebak
set FILENAME=%OWNER%_%CURDATE%_%CURTIME%.DMP
set EXPLOG=%OWNER%_%CURDATE%_%CURTIME%_log.log
REM 调用ORACLE的exp命令导出用户数据
REM IRS_DATA_BAK_DIR已事先创建好
expdp %USER%/%PASSWORD%@%OWNER% DIRECTORY=IRS_DATA_BAK_DIR DUMPFILE=%FILENAME% LOGFILE=%EXPLOG%
REM exp %USER%/%PASSWORD%@%OWNER% file=%FILENAME% owner=%USER% log=%EXPLOG% grants=n
REM 调用rar进行压缩
"C:\Program Files (x86)\winrar\Rar" a -m5 -dw D:\oraclebak\%OWNER%_%CURDATE%_%CURTIME%".rar" D:\oraclebak\%OWNER%_%CURDATE%_%CURTIME%.DMP
exit
复制内容后,粘贴到扩展名为bat的文件中,然后创建一个windows任务定时调用此文件就可以了