mkdir -p /data/mysql/backup
mkdir -p /opt/shell
cd /opt/shell
echo '#!/bin/sh
dbName=test
filename="${dbName}-"`date +%F`
mysqldump -u root -p123456 $dbName >/data/mysql/backup/$filename.sql' > mysql_backup.sh
chmod +x mysql_backup.sh
crontab -e
#添加定时任务
0 0 * * * /bin/bash /opt/shell/backup_mysql.sh
#保存退出
Mysql定时备份(简单版)
于 2023-02-07 10:59:30 首次发布