#!/bin/bash
mailto=mail@example.com
database=db_for_backup
mysqluser=dbuser
mysqlpassword=dbpassword
mysqldump -u ${mysqluser} --password=${mysqlpassword} ${database} > /tmp/data.sql
bzip2 /tmp/data.sql
DATE=`date +"%Y-%m-%d %H:%M"`
host=`hostname`
uuencode /tmp/data.sql.bz2 ${database}.sql.tbz2 > /tmp/data.uuc
mailx -s "[backup] MySQL DB: ${database} ${host} @ ${DATE}" ${mailto} < /tmp/data.uuc
rm /tmp/data.sql.bz2
rm /tmp/data.uuc |
#!/bin/bash
mailto=mail@example.com
database=db_for_backup
mysqluser=dbuser
mysqlpassword=dbpassword
mysqldump -u ${mysqluser} --password=${mysqlpassword} ${database} > /tmp/data.sql
bzip2 /tmp/data.sql
DATE=`date +"%Y-%m-%d %H:%M"`
host=`hostname`
uuencode /tmp/data.sql.bz2 ${database}.sql.tbz2 > /tmp/data.uuc
mailx -s "[backup] MySQL DB: ${database} ${host} @ ${DATE}" ${mailto} < /tmp/data.uuc
rm /tmp/data.sql.bz2
rm /tmp/data.uuc