not aesthetically pleasing =) but... p.s. (true for small databases, lock tables locks base in the dump process)
bash script to add in cron:
\r
#!/bin/sh mysqldump -u -p --lock-tables --opt > /sqldata/dump.sql cd /sqldata/ tar-zcvf sqldata.tgz,*.sql perl sendtoemail.pl
The script requires the folder /sqldata, sendtoemail.pl is in /sqldata.
\r
the contents sendtoemail.pl requires MIME::Lite:
\r
#!/usr/bin/perl -w use MIME::Lite; $msg = MIME::Lite->new( From => 'backup@wailaowai.com', To => 'me@wailaowai.com', Subject => 'sqldata.tgz MySQL backup!', Type => 'text/plain', Data => "Here are the MySQL database backups."); $msg->attach(Type=>"application/x-tar", Path =>"/sqldata/sqldata.tgz", Filename =>"sqldata.tgz"); $msg->send;