每天固定时间用mysqldump 备份mysql数据。
#!/bin/bash
每天早上4点, mysql备份数据 orangleliu
chmod 700 backup.sh
crontab -e
0 4 * /home/erya/run/moniter/mysql_backup.sh
user="radius"
password=""
host="localhost"
db_name="radius"
backup directory
base_dir="/home/backup"
backup_log="${base_dir}/mysql_backup.log"
backup_path=${base_dir}
file info
date=$(date +"%Y-%m-%d")
filename=$backup_path/$db_name-$date.sql.gz
umask 177
back up
mysqldump --user=$user --password=$password --host=$host $db_name | gzip > $filename
Delete files older than 10 days
find $backup_path/* -mtime +10 -exec rm {} \;
echo "backup finished at $(date +'%Y-%m-%d %H:%M:%S')" >> "$backup_log"</pre>
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。