@echo off
@title Mysqlbackup
echo MySQL数据库备份
echo ***********************
echo Today %date%
echo Time %time%
echo ***********************
rem 设置文件路径
set files=D:\backup\
rem 当前日期(格式YYYYMMDD)
set bak_date=%date:~0,4%%date:~5,2%%date:~8,2%
rem 临时文件夹
set bak_tmpFile=C:\~UpTemp\
rem 日志文件夹
set bak_logPath=C:\~bak_log\
md %bak_tmpFile%
md %bak_logPath%
echo -------- 开始压缩 [%bak_timeStart%] >%bak_logPath%log-%bak_date%.txt
rem ftp信息
set bak_ftpServer=42.51.152.166
set bak_ftpUserName=anymous
set bak_ftpUserPass=anymous
set bak_timeStart=%time%
@echo 开始backup Mysql
md "D:\backup\%Ymd%mysql"
"D:\phpStudy\MySQL\bin\mysqldump.exe" --opt -Q -uroot -p123456 --default-character-set=utf8 discuz > "D:\backup\%Ymd%mysql\discuz.sql"
"D:\phpStudy\MySQL\bin\mysqldump.exe" --opt -Q -uroot -p123456 --default-character-set=utf8 dede > "D:\backup\%Ymd%mysql\dede.sql"
"D:\phpStudy\MySQL\bin\mysqldump.exe" --opt -Q -u root -p123456 --default-character-set=utf8 weixin > "D:\backup\%Ymd%mysql\weixin.sql"
@echo 开始压缩文件
C:
cd C:\Program Files\WINRAR
RAR.EXE a -r -y %files%%date%.rar %files%*
rem 生成ftp命令文件
echo open %bak_ftpServer% >ftp.up
echo %bak_ftpUserName%>>ftp.up
echo %bak_ftpUserPass%>>ftp.up
echo bin >>ftp.up
echo mput %files%\* >>ftp.up
echo bye >>ftp.up
FTP -s:ftp.up -i >>%bak_logPath%log-%bak_date%.txt
del ftp.up /q
rem Xcopy %bak_tmpFile%* C:\Temp /y
del %bak_tmpFile%*.* /q /s
rd %bak_tmpFile% /q
echo "Backup OK~ Please Cat FTP"
pause