数据库备份 bat
rem ***********备份数据**************
echo =========================================================== >> backup.log
echo 开始数据库备份 时间 : %date% %time% >> backup.log
rem 备份 数据库 2
exp EASYSSH/EASYSSH@148orcl file=d:\backup\dbbak\vehes_%date:~0,10%.dmp log=d:\backup\dbbak\EASYSSH_%date:~0,10%.log compress=n buffer=8092 consistent=y direct=n constraints=y feedback=10000 grants=y record=y indexes=y triggers=y rows=y
rem ********压缩 数据库备份*************
rem 压缩 VEHES 数据库备份
C:\progra~1\winrar\winrar.exe a -ibck d:\backup\rarbak\EASYSSH_%date:~0,10%.rar d:\backup\dbbak\EASYSSH_%date:~0,10%.dmp d:\backup\dbbak\EASYSSH_%date:~0,10%.log >> backup.log
rem *********删除 数据临时备份文件*************
del /f d:\backup\dbbak\EASYSSH_%date:~0,10%.dmp
del /f d:\backup\dbbak\EASYSSH_%date:~0,10%.log
echo 结束数据库备份 时间 : %date% %time% >> backup.log
rem 得到前7天的日期
echo wscript.echo dateadd("d",-7,date) >%tmp%\tmp.vbs
for /f "tokens=1,2,3 delims=/- " %%i in ('cscript /nologo %tmp%\tmp.vbs') do set y=%%i
for /f "tokens=1,2,3 delims=/- " %%i in ('cscript /nologo %tmp%\tmp.vbs') do set m=%%j
for /f "tokens=1,2,3 delims=/- " %%i in ('cscript /nologo %tmp%\tmp.vbs') do set d=%%k
if %m% LSS 9 set m=0%m%
if %d% LSS 9 set d=0%d%
set deldate=%y%-%m%-%d%
rem 删除7天前程序备份
echo 开始删除 d:\backup\rarbak\*_%deldate%.rar at : %date% %time% >> backup.log
del /f d:\backup\rarbak\*_%deldate%.rar
echo 结束删除 d:\backup\rarbak\*_%deldate%.rar at : %date% %time% >> backup.log
rem 开始使用ftp客户端连接 ,并执行脚本
@echo off
echo open 10.131.98.80 >> backup_ftp.log
echo xk >> backup_ftp.log
echo xk >> backup_ftp.log
echo send d:\backup\rarbak\EASYSSH_%date:~0,10%.rar >> backup_ftp.log
echo bye >> backup_ftp.log
ftp -s:backup_ftp.log
rem 删除临时文件
del /f backup_ftp.log
rem ***********备份数据**************
echo =========================================================== >> backup.log
echo 开始数据库备份 时间 : %date% %time% >> backup.log
rem 备份 数据库 2
exp vehes_admin/oracle@orcl92 file=d:\backup\dbbak\vehes_%date:~0,10%.dmp log=d:\backup\dbbak\vehes_%date:~0,10%.log compress=n buffer=8092 consistent=y direct=n constraints=y feedback=10000 grants=y record=y indexes=y triggers=y rows=y
rem ********压缩 数据库备份*************
rem 压缩 VEHES 数据库备份
C:\progra~1\winrar\winrar.exe a -ibck d:\backup\rarbak\vehes_%date:~0,10%.rar d:\backup\dbbak\vehes_%date:~0,10%.dmp d:\backup\dbbak\vehes_%date:~0,10%.log >> backup.log
rem *********删除 数据临时备份文件*************
del /f d:\backup\dbbak\vehes_%date:~0,10%.dmp
del /f d:\backup\dbbak\vehes_%date:~0,10%.log
echo 结束数据库备份 时间 : %date% %time% >> backup.log
rem 得到前7天的日期
echo wscript.echo dateadd("d",-7,date) >%tmp%\tmp.vbs
for /f "tokens=1,2,3 delims=/- " %%i in ('cscript /nologo %tmp%\tmp.vbs') do set y=%%i
for /f "tokens=1,2,3 delims=/- " %%i in ('cscript /nologo %tmp%\tmp.vbs') do set m=%%j
for /f "tokens=1,2,3 delims=/- " %%i in ('cscript /nologo %tmp%\tmp.vbs') do set d=%%k
if %m% LSS 9 set m=0%m%
if %d% LSS 9 set d=0%d%
set deldate=%y%-%m%-%d%
rem 删除7天前程序备份
echo 开始删除 d:\backup\rarbak\*_%deldate%.rar at : %date% %time% >> backup.log
del /f d:\backup\rarbak\*_%deldate%.rar
echo 结束删除 d:\backup\rarbak\*_%deldate%.rar at : %date% %time% >> backup.log
rem 开始使用ftp客户端连接 ,并执行脚本
@echo off
echo open 127.0.0.1 >> backup_ftp.log
echo xk >> backup_ftp.log
echo xk >> backup_ftp.log
echo send d:\backup\rarbak\vehes_%date:~0,10%.rar >> backup_ftp.log
echo bye >> backup_ftp.log
ftp -s:backup_ftp.log
rem 删除临时文件
del /f backup_ftp.log
前提是:在D盘需要手动创建好D:\backup\dbbak及D:\backup\rarbak 两个文件夹。。