LINUX备份MYSQL-通过邮件自动发送到指定邮箱
制作:高进波
时间:2009-4-10
主题:LINUX备份MYSQL-通过邮件自动发送到指定邮箱
1.所需要软件
mutt LINUX下命令行邮件工具,可用来接收和发送邮件
sendmail/postfix LINUX下邮件服务器,所有邮件通过本机发送出去
mysqldump 备份MYSQL数据库的程序
2.mutt参数介绍
-a <filename> 附件
-s <subject> 主题
例子:
echo "你好,祝你愉快!" | mutt -a /etc/passwd -s "LINUX发送带附件的邮件" hugwww@163.com
说明:echo打印的内容为邮件正文,发送密码文件passwd到邮箱hugwww@163.com
3.脚本
测试备份的数据库名:
scriptdev2 realmd mmfpm mangos characters
查看数据库使用的字符集
show variables like "char%";
utf8
建立备份脚本
vi /root/send-mysql-data.sh
|
#!/bin/bash #set time format #定义数组 #取数组无元素个数 #循环列出数组元素 while [ $i -lt $lenArray ] #执行备份 # echo ${db_array[$i]} #将所有SQL文件压缩到一个文件 #发送备份文件到邮箱 echo "$date 备份成功并发送到指定邮箱" >> /opt/db-backup/backup.log exit |
完成
五月 12th, 2011 at 07:28
Interesting Posts…
[...]some other related resources on the web that are worth viewing on this subject include[...]…
五月 15th, 2011 at 02:04
Related Websites…
[...]some other related resources on the web that are worth viewing on this subject include[...]…