点击(此处)折叠或打开
- echo ******MySQL backup start********
- forfiles /p "D:\bakdb" /m kdyp_*.* -d -30 /c "cmd /c del /f @path"
- set "Ymd=%date:~0,4%%date:~5,2%%date:~8,2%_%time:~0,2%%time:~3,2%%time:~6,2%"
- E:\mysql-5.7.16-winx64\bin\mysqldump --opt --single-transaction=TRUE --user=root --password=123^= --host=127.0.0.1 --protocol=tcp --port=3306 --default-character-set=utf8 --routines "kdyp" > D:\bakdb\kdyp_%Ymd%.sql
- echo ******MySQL backup completed********
- ping 127.0.0.1 -n 2 > nul
- echo ******zip start********
- "C:\Program Files\7-Zip\7z.exe" a kdyp_%Ymd%.zip kdyp_%Ymd%.sql
- echo ******zip completed********
- ping 127.0.0.1 -n 2 > nul
- del kdyp_%Ymd%.sql
- echo ******scp start********
- "C:\Program Files\PuTTY\pscp.exe" -l root -pw yourpwd -P 22 kdyp_%Ymd%.zip 122.122.122.122:/remote/
- echo ******scp completed********
- echo on