為了保障服務(wù)器中數(shù)據(jù)的可恢復(fù)性,采用異地備份數(shù)據(jù)庫方案。異地備份數(shù)據(jù)分為異地備份文件數(shù)據(jù)與異地備份數(shù)據(jù)庫數(shù)據(jù)二種。其中異地備份文件數(shù)據(jù)是為了備份網(wǎng)站中用戶上傳的文件而設(shè)計的。而異地備份數(shù)據(jù)庫數(shù)據(jù)是將數(shù)據(jù)庫中數(shù)據(jù)備份文件上傳到異地服務(wù)器。
3. 書寫遠(yuǎn)程ftp連接配置文件
set files=c:\backup\%date:~0,10%.rar
set dbfilesdmp=c:\backup\%date:~0,10%db.dmp
set userdb="jbpmdemo"
set pwddb="jbpmdemo"
set domain="master.jhserver"
set filespath=c:\c\a c:\c\b
set ftpfile="c:\backup\ftp.txt"
set ftpname=admin
set ftppwd=Heroic
set ftpfiles="%date:~0,10%.rar"
set ftpdbfiles="%date:~0,10%db.rar"
set ftpdomain="192.168.0.1"
set rarpath="c:\program files\winrar"
@echo 開始備份數(shù)據(jù)庫
exp %userdb%/%pwddb%@%domain% file="%dbfilesdmp%"
@echo 開始壓縮文件
c:
cd c:\program files\winrar
rar a -r -y %files% %filespath% %dbfilesdmp%
@echo 寫入文件ftp
@echo %ftpname%>%ftpfile%
@echo %ftppwd%>>%ftpfile%
@echo put %files% %ftpfiles%>>%ftpfile%
@echo bye>>%ftpfile%
@echo 上傳%files%.rar文件
ftp -s:%ftpfile% 192.168.0.1
del /f /q %files%
數(shù)據(jù)庫異地備份對一個網(wǎng)站來說是非常必要的,這里談一下使用批處理文件對數(shù)據(jù)庫異地本份的過程,首先需要準(zhǔn)備兩個文件,一個是ftp.txt(存儲ftp命令),一個是movefile.bat(存儲dos命令).