[Mysql] daily backup shell script and mysql backup shell script
Use mysqldump to back up mysql Data at a fixed time every day.
#! /Bin/bash # mysql backup data orangleliu # chmod 700 backup every morning. sh # crontab-e #0 4 ***/home/erya/run/moniter/mysql_backup.shuser = "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 infodate = $ (date + "% Y-% m -% d ") filename = $ backup_path/mongodb_name-mongodate. SQL .gz umask 177 # back up mysqldump -- user = $ user -- password = $ password -- host = $ host $ db_name | gzip> $ filename # Delete files older than 10 daysfind $ backup_path/*-mtime + 10-exec rm {}\; echo "backup finished at $ (date + '% Y-% m-% d % H: % M: % s')"> "$ backup_log"
Reference
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.