windows自动备份mysql数据库bat脚本

windows自动备份mysql脚本bat
MysqlDump_AutoBackUp.bat:

@echo off
echo Perform backup tasks 
set hour=%time:~0,2%
if "%time:~0,1%"==" " set hour=0%time:~1,1%
set now=%Date:~0,4%%Date:~5,2%%Date:~8,2%%hour%%Time:~3,2%%Time:~6,2%
echo %now%
set host=localhost
set port=3306
set user=root
set pass=rootpass
set dbname=Weekly%backup
set backupfile=D:\mysqlautobackup\%dbname%-%now%.sql
"D:\PHPWEB\MySQL Server 5.6\bin\mysqldump" -h%host% -P%port% -u%user% -p%pass% -c --all-databases > %backupfile%
echo delete files before 30 days
forfiles /p D:\mysqlautobackup /s /m *.sql /d -30 /c "cmd /c del @file /f"
echo Exiting the backup task
ping /n 3 127.0.0.1 >nul
exit

未经允许不得转载:Villain博客 » windows自动备份mysql数据库bat脚本

赞 (0) 打赏

评论 0

评论前必须登录!

登陆 注册

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏