bat script scheduled backup mysql database

1, the timing of all equipment

1.1, according to the date of full data backup once a day

@echo off
:start
set datet=%date:~0,4%%date:~5,2%%date:~8,2%
echo 开始备份,当前数据日期为%datet%,备份文件全路径为:E:\mysql-senior\mysql备份\定时\webchat-%datet%.sql
mysqldump -uroot -pok -h127.0.0.1 --databases webchat > E:\mysql-senior\mysql备份\定时\webchat-%datet%.sql
ping -n 86400 127.1>NUL
goto start

1.2, the index is incremented by an arbitrary time interval all equipment

@echo off
set /a num=1
:start
echo 开始备份,当前索引为%num%,备份文件全路径为:E:\mysql备份\stu-%num%.sql
mysqldump -uroot -pcmh123 -h127.0.0.1 --databases stu > E:\mysql备份\stu-%num%.sql
set /a num+=1
ping -n 10 127.1>NUL
goto start

2, a timing incremental backup (new log file is generated)

@echo off
:start
echo 开始增量备份,增量备份会生成一个新的日志文件,当前每一分钟备份一次
mysql -uroot -pcmh123 -e "flush logs"
ping -n 60 127.1>NUL
goto start

 

Published 89 original articles · won praise 67 · views 70000 +

Guess you like

Origin blog.csdn.net/xl_1803/article/details/103146463
Recommended