日期:2014-05-16  浏览次数:20760 次

mysql在WIN下的备份BAT
@echo off
set errorlevel=0
set dump_command="C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqldump"

set db_bbs=bbscs8
set db_bug=jtrac
set db_wiki=wiki

set backup_dir=U:\bak\mysql\
set timestamp=%date:~,4%%date:~5,2%%date:~8,2%_%time:~0,2%-%time:~3,2%-%time:~6,2%

set backup_bbs_file=%backup_dir%%db_bbs%_backup_%timestamp%.sql
set backup_bug_file=%backup_dir%%db_bug%_backup_%timestamp%.sql
set backup_wiki_file=%backup_dir%%db_wiki%_backup_%timestamp%.sql

set user_mysql=root
set password_mysql=virtual

echo backup mysql database:%db_bbs%
%dump_command% -u%user_mysql% -p%password_mysql% %db_bbs% > %backup_bbs_file%

echo backup mysql database:%db_bug%
%dump_command% -u%user_mysql% -p%password_mysql% %db_bug% > %backup_bug_file%

echo backup mysql database:%db_wiki%
%dump_command% -u%user_mysql% -p%password_mysql% %db_wiki% > %backup_wiki_file%

echo end backup