将下面的代码保存成backup.bat文件,加入到计划任务里。
@echo off
REM ========== mysql ==========
net stop mysql
d:
cd "D:\Program Files\MySQL\MySQL Server 5.5\data\farmer"
xcopy *.* D:\db_bak\farmer\%date:~0,10%\ /y
net start mysql
cd "D:\chinafarmer2013"
xcopy *.* D:\db_bak\www\%date:~0,10%\ /s/e/y
REM ========== reboot ==========
cd\
forfiles /p "D:\db_bak\farmer" /d -15 /c "cmd /c rd /q /s @path"
forfiles /p "D:\db_bak\www" /d -15 /c "cmd /c rd /q /s @path"
shutdown -r -t 30
效果如下图: