数据库备份 bat
rem ***********备份数据**************
echo =========================================================== >> backup.log
echo 开始数据库备份 时间 : %date% %time% >> backup.log
rem 备份 数据库 2
exp EASYSSH/EASYSSH@148orcl file=d:ackupdbbakvehes_%date:~0,10%.dmp log=d:ackupdbbakEASYSSH_%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~1winrarwinrar.exe a -ibck d:ackup
arbakEASYSSH_%date:~0,10%.rar d:ackupdbbakEASYSSH_%date:~0,10%.dmp d:ackupdbbakEASYSSH_%date:~0,10%.log >> backup.log
rem *********删除 数据临时备份文件*************
del /f d:ackupdbbakEASYSSH_%date:~0,10%.dmp
del /f d:ackupdbbakEASYSSH_%date:~0,10%.log
echo 结束数据库备份 时间 : %date% %time% >> backup.log
rem 得到前7天的日期
echo wscript.echo dateadd("d",-7,date) >%tmp% mp.vbs
for /f "tokens=1,2,3 delims=/- " %%i in ('cscript /nologo %tmp% mp.vbs') do set y=%%i
for /f "tokens=1,2,3 delims=/- " %%i in ('cscript /nologo %tmp% mp.vbs') do set m=%%j
for /f "tokens=1,2,3 delims=/- " %%i in ('cscript /nologo %tmp% mp.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:ackup
arbak*_%deldate%.rar at : %date% %time% >> backup.log
del /f d:ackup
arbak*_%deldate%.rar
echo 结束删除 d:ackup
arbak*_%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:ackup
arbakEASYSSH_%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:ackupdbbakvehes_%date:~0,10%.dmp log=d:ackupdbbakvehes_%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~1winrarwinrar.exe a -ibck d:ackup
arbakvehes_%date:~0,10%.rar d:ackupdbbakvehes_%date:~0,10%.dmp d:ackupdbbakvehes_%date:~0,10%.log >> backup.log
rem *********删除 数据临时备份文件*************
del /f d:ackupdbbakvehes_%date:~0,10%.dmp
del /f d:ackupdbbakvehes_%date:~0,10%.log
echo 结束数据库备份 时间 : %date% %time% >> backup.log
rem 得到前7天的日期
echo wscript.echo dateadd("d",-7,date) >%tmp% mp.vbs
for /f "tokens=1,2,3 delims=/- " %%i in ('cscript /nologo %tmp% mp.vbs') do set y=%%i
for /f "tokens=1,2,3 delims=/- " %%i in ('cscript /nologo %tmp% mp.vbs') do set m=%%j
for /f "tokens=1,2,3 delims=/- " %%i in ('cscript /nologo %tmp% mp.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:ackup
arbak*_%deldate%.rar at : %date% %time% >> backup.log
del /f d:ackup
arbak*_%deldate%.rar
echo 结束删除 d:ackup
arbak*_%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:ackup
arbakvehes_%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:ackupdbbak及D:ackup
arbak 两个文件夹。。