1. 新健backup.bat文
rem ***********備份數據**************
echo 開始數據庫備份 時間 : %date% %time% >> backup.log
rem 備份督辦回告 1
exp dbhg/dbhg@orcl file=d:\backup\dbbak\dbhg_%date:~0,10%.dmp log=d:\backup\dbbak\dbhg_%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 備份OA 數據庫 2
exp oa/oa@orcl file=d:\backup\dbbak\oa_%date:~0,10%.dmp log=d:\backup\dbbak\oa_%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 壓縮 督辦回告 數據庫備份
C:\progra~1\winrar\winrar.exe a d:\backup\rarbak\dbhg_%date:~0,10%.rar d:\backup\dbbak\dbhg_%date:~0,10%.dmp d:\backup\dbbak\dbhg_%date:~0,10%.log >> backup.log
rem 壓縮 OA 數據庫備份
C:\progra~1\winrar\winrar.exe a d:\backup\rarbak\oa_%date:~0,10%.rar d:\backup\dbbak\oa_%date:~0,10%.dmp d:\backup\dbbak\oa_%date:~0,10%.log >> backup.log
rem *********刪除 數據臨時備份文件*************
del /f d:\backup\dbbak\dbhg_%date:~0,10%.dmp
del /f d:\backup\dbbak\dbhg_%date:~0,10%.log
del /f d:\backup\dbbak\oa_%date:~0,10%.dmp
del /f d:\backup\dbbak\oa_%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 start del d:\backup\rarbak\*_%deldate%.rar at : %date% %time% >> backup.log
del /f d:\backup\rarbak\dbhg_%deldate%.rar
del /f d:\backup\rarbak\oa_%deldate%.rar
echo end del d:\backup\rarbak\*_%deldate%.rar at : %date% %time% >> backup.log
rem 構建 臨時 ftp 連接腳本
echo open 59.208.8.4 >> ftp.tmp
echo user ycoa bester@2010 >> ftp.tmp
echo cd server3 >> ftp.tmp
echo bin >> ftp.tmp
echo prompt off >> ftp.tmp
echo send d:\backup\rarbak\dbhg_%date:~0,10%.rar >> ftp.tmp
echo del dbhg_%deldate%.rar >> ftp.tmp
echo send d:\backup\rarbak\oa_%date:~0,10%.rar >> ftp.tmp
echo del oa_%deldate%.rar >> ftp.tmp
echo bye >> ftp.tmp
rem 開始使用ftp客戶端連接 ,並執行腳本
ftp -n -s:ftp.tmp
rem 刪除臨時文件
del /f ftp.tmp