网上找的代码,因为我的路径有空格,有点问题,做个记录修改如下:
rem *******************************Code Start*****************************
@echo off
set "Ymd=%date:~,4%%date:~5,2%%date:~8,2%"
set EXE_PATH="D:\Program Files\MySQL\MySQL Workbench 6.3 CE\mysqldump.exe"
%EXE_PATH% --opt -u root --password=123456 test > D:\backup\db\test_%Ymd%.sql
@echo on
rem *******************************Code End*******************************
windows自动备份后使用7z压缩:
rem *******************************Code Start*****************************
@echo off
set "Ymd=%date:~,4%%date:~5,2%%date:~8,2%"
set EXE_PATH="D:\backup\mysqldump.exe"
%EXE_PATH% --opt -u root --password=123456 -h 192.168.0.101 -P 3306 test > D:\backup\db\test_%Ymd%.sql
set zpath="C:\Program Files\7-Zip\7z.exe"
%zpath% a D:\backup\db\lm-web_%Ymd%.7z D:\backup\db\lm-web_%Ymd%.sql
del "D:\backup\db\lm-web_%Ymd%.sql"
@echo on
rem *******************************Code End*******************************