Bat备份MySQL

windows环境下定时备份MySQL数据经常用到,实测过的脚本如下,希望能为你节约一些时间^_^

set backup_dir="D:\backup"
set "ymd=%date:~,4%%date:~5,2%%date:~8,2%"

"C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqldump.exe" -Q db_name -uroot -pedu@2018 > %backup_dir%\db_name_%ymd%.sql

forfiles /p %backup_dir% /s /m *.* /c "cmd /c Del @path" /d -30

实现备份数据库db_name到某一目录下(以当日日期命名),然后删除30天以前的备份

转载于:https://www.cnblogs.com/roostinghawk/p/11598192.html

你可能感兴趣的:(Bat备份MySQL)