[MySQL] daily backup shell script

Source: Internet
Author: User
Tags file info mysql backup shebang

Use mysqldump to back up MySQL data for 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"

Reference

    • Mysql-backup

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

[MySQL] daily backup shell script

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.