每天自动备份MySQL数据库的shell脚本
本文地址:http://txm.tongxinmao.com/Article/Detail/id/135
#!/bin/bash# 数据库认证
user=""
password=""
host=""
db_name=""# 其它
backup_path="/path/to/your/home/_backup/mysql"
date=$(date +"%d-%b-%Y")# 设置导出文件的缺省权限
umask 177# Dump数据库到SQL文件
/usr/local/mysql/bin/mysqldump --user=$user --password=$password --host=$host $db_name > $backup_path/$db_name-$date.sql
# 删除30天之前的就备份文件
find $backup_path/* -mtime +30 -exec rm {} \;