@echo off
REM /* MysqlBinPath: MySQL 可執行檔路徑,結尾請不要放 "\"
REM * BackupPath: 放置 sql 備份檔的位置,結尾請不要放 "\"
REM * DBhost: 資料庫主機的位址,可用 dn 或 ip
REM * DBuser: 資料庫使用者名稱
REM * DBpass: 資料庫使用者密碼
REM * DBname: 資料庫名稱 資料表名稱(可省略)
REM * Argument: 其他的參數 */
SET MysqlBinPath=C:\AppServ\MySQL\bin
SET BackupPath=C:\BACKUP
SET DBhost=XXX.XXX.XXX.com.tw
SET DBuser=XXXXXX
SET DBpass=XXXXXX
SET DBname=XXX
SET Argument=--opt --compress --force --default-character-set=utf8
REM /* 以下不必修改 */
REM /* 取得日期。參照: http://alexchuo.blogspot.com/2006/07/blog-post.html */
FOR /F "tokens=1-4 delims=/ " %%a IN ("%date%") DO (
SET _MyDate=%%a-%%b-%%c %%d
)
REM /* 以日期為檔名,匯出 .sql 檔案。 */
echo 資料庫 %DBname% 備份中……
"%MysqlBinPath%\mysqldump" --host=%DBhost% --user=%DBuser% --password=%DBpass% %Argument% %DBname% > "%BackupPath%\%_MyDate%.sql"
REM /* 偵錯處理,發生錯誤就停住畫面以便看清楚錯誤訊息。 */
IF NOT %ERRORLEVEL% == 0 (
del "%BackupPath%\%_MyDate%.sql
echo.
echo 不好了,好像出了什麼問題的樣子。請看上面的訊息吧!
pause
)
歡迎光臨 資訊家電班NO7 (http://imce07.freehostia.com/forums/) | Powered by Discuz! 7.2 |