@echo off
@title Mysql+fileBckup
set files=D:\backup\%date:~0,10%.rar
set userdb="root"
set pwddb="123456"
set filepath="D:\wwwroot"
set ftpfile="C:\ftp.txt"
set ftpname=ftpuser
set ftppwd=ftpuser
set ftpfiles="%date:~0,10%.rar "
set ftpdomian="42.51.153.157"
set rarpath="C:\Program Files\WINRAR"
set "Ymd=%date:~,4%%date:~5,2%%date:~8,2%"
@echo 开始backup Mysql
md "D:\backup\%Ymd%.mysq l"
"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% %Ymd% %filespath% D:\wwwroot
@echo 写入文件ftp
@echo %ftpname%>%ftpfile%
@echo %ftppwd%>>%ftpfile%
@echo put %files% %ftpfiles%>>%ftpfile%
@echo bye>>%ftpfile%
@echo 上传%files%.rar文件
ftp -s:%ftpfile% 42.51.153.157
cd C:\Documents and Settings\Administrator\桌面
echo %date% 备份成功
pause
C:\ftp.txt 内容
ftpuser
123456
put D:\backup\%date:~0,10%.rar
bye