#压缩数据库包 #打包/root目录下的SQL文件夹,SQL目录需要手动建立 tar -czvPf mysql_$d.tar.gz -C /root SQL
#压缩后删除备份目录中的sql文件 rm$BackPath*.sql
#发送邮件的标题和内容 title="MySQL-Backup-$d" content="Hello,Master!MySQL backup has been completed!Backup Time:$d"
#用自带的mail发邮件,需要配置/etc/mail.rc,在最后添加smtp信息,需要使用25端口 echo"$content" | mail -s "$title" -a /root/mysql_$d.tar.gz your@mail.com
#退出当前脚本 exit
更新:
最近发现在使用上面的脚本时,存在Warning和Error,具体提示如下:
1 2
mysqldump: [Warning] Using a password on the command line interface can be insecure. mysqldump: Error: 'Access denied; you need (at least one of) the PROCESS privilege(s) for this operation'when trying to dump tablespaces