Use mysqldump to back up MySQL data at a fixed time of day.
#!/bin/bash#每天早上4点, MySQL backup data orangleliu#chmod backup.sh#crontab-E#0 4 * * */home/erya/run/moniter/mysql_backup.shUser="radius"password=""host="localhost"Db_name="radius"#backup DirectoryBase_dir="/home/backup"backup_log="${base_dir}/mysql_backup.log"Backup_path=${base_dir}#file Infodate=$ (date +"%y-%m-%d") filename=$backup _path/$db _name-$date. sql.gzumask177#back upMysqldump--user=$user--password=$password--host=$host $db _name| gzip >$filename#Delete files older thanFind$backup _path/*-mtime +Ten-exec rm {} \;Echo "Backup finished at $ (date + '%y-%m-%d%h:%m:%s ')">>"$backup _log"
References
Copyright notice: This article Orangleliu (http://blog.csdn.net/orangleliu/) original article, the article reproduced the Declaration.
"Shell text" MySQL daily backup shell text