#!/usr/bin/perl
use warnings;
use strict;
use MySQL::Backup;
use Mail::Sender;
open my $tmp_sql, '>', "backup.sql";
my $mb = new MySQL::Backup('dbname', 'localhost', 'dbuser', 'dbpasswd', {'USE_REPLACE' => 1, 'SHOW_TABLE_NAMES' => 1});
print $tmp_sql $mb->create_structure();
print $tmp_sql $mb->data_backup();
close $tmp_sql;
my $sender = new Mail::Sender { smtp => 'smtp.163.com',
from => '
[email protected]',
# debug => 'backup_debug.log',
auth => 'LOGIN',
authid => 'mailuser',
authpwd => 'mailpasswd',
};
$sender->MailFile({ to => '
[email protected]',
subject => 'Backup Blog SQL_'.time(),
msg => '3Q',
file => 'backup.sql',});