MySQL8定时备份
1.修改MySQL配置 /etc/my.cnf
vim /etc/my.cnf
[mysqldump] user=xxx password=xxx
2.创建脚本
touch /var/www/wwwroot/dbbaks/项目名称_bak.sh
vim /var/www/wwwroot/dbbaks/项目名称_bak.sh
#!/bin/bash mysqldump 数据库名称| gzip > /var/www/wwwroot/dbbaks/数据库名称/$(date +%Y%m%d_%H%M%S).sql.gz
... 支持多个
chmod +x /var/www/wwwroot/dbbaks/项目名称_bak.sh
3.添加定时(每周日凌晨2点执行一次)
crontab -e
0 2 * * 0 /var/www/wwwroot/dbbaks/项目名称_bak.sh
systemctl restart crond.service
systemctl restart mysqld.service
来源:https://blog.csdn.net/u012750106/article/details/82221866