Linux系统下的定时任务主要是用crontab来做。
cd /home
mkdir backup
cd backup
vi DatabaseName.sh
#!/bin/bash
/usr/local/mysql/bin/mysqldump -uusername -ppassword DatabaseName > /home/backup/DatabaseName_$(date +%Y%m%d_%H%M%S).sql
#!/bin/bash
/usr/local/mysql/bin/mysqldump -uusername -ppassword DatabaseName | gzip > /home/backup/DatabaseName_$(date +%Y%m%d_%H%M%S).sql.gz
赋权限
chmod u+x DatabaseName.sh
创建定时任务
crontab -e
01 3 * * * root/home/backup/DatabaseName.sh
## 表示每天 3 点钟执行备份
参考
https://ken.io/note/mysql-full-backup-linux-mysqldump-crontab