Windows设置定时备份MySQL任务

一、编写批处理脚本

@echo off
forfiles /p "E:\mysql\MySQL BackUp" /m backup_*.sql -d -30 /c "cmd /c del /f @path"
set "Ymd=%date:~0,4%%date:~5,2%%date:~8,2%0%time:~1,1%%time:~3,2%%time:~6,2%"
"E:\mysql\MySQL Server 5.6\bin\mysqldump" --opt --single-transaction=TRUE --user=root --password=123456 --host=127.0.0.1 --protocol=tcp --port=3306 --default-character-set=utf8 --single-transaction=TRUE --routines --events "yumi_website" > "E:\mysql\MySQL BackUp\backup_%Ymd%.sql"
@echo on

运行时间在10点-23点之间,用%time:~0,2%%time:~3,2%%time:~6,2%

运行时间在0点到9点之间,用%time:~1,1%%time:~3,2%%time:~6,2%

 

二、用Windows计划任务程序定时运行脚本

开始 -> Windows管理工具 -> 任务计划程序,在任务计划程序库中选择一个文件较少的文件夹,创建基本任务 -> ... -> 选择脚本

 

 

参考:

https://blog.csdn.net/freezingxu/article/details/78884962

https://blog.csdn.net/weixin_34368949/article/details/93591260

https://www.cnblogs.com/kxxx/p/10729462.html

https://v2ex.com/t/342637

https://dbaplus.cn/news-11-1267-1.html

https://dbaplus.cn/news-11-1138-1.html?utm_source=oschina-app

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值