Skip to content

Instantly share code, notes, and snippets.

@spidersea
Created December 24, 2013 08:39
Show Gist options
  • Save spidersea/8110447 to your computer and use it in GitHub Desktop.
Save spidersea/8110447 to your computer and use it in GitHub Desktop.
#!/bin/bash
DATE=$(date +%Y%m%d)
/usr/local/webserver/mysql/bin/mysqldump -u root -ppasswd --opt dbname > $DATE
tar cfz $DATE.tar.gz $DATE
(echo "$DATE DB backup";uuencode $DATE.tar.gz $DATE.tar.gz)|mail -s "${DATE}_pangxiang_DB_backup" [email protected]
###############################
#也可以使用如下命令进行附件发送,效果也不错
#echo "$DATE DB backup" |mutt -s "${DATE}_DB_backup" [email protected] -a ${DATE}_all-databases.sql.tar.gz
#
## rpm -qf /usr/bin/mutt
#mutt-1.5.20-2.20091214hg736b6a.el6_1.1.x86_64
###############################
rm -f $DATE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment