my $mb = new MySQL::Backup($database,$host,$user,$pwd,{'USE_REPLACE' =
+> 0, 'SHOW_TABLE_NAMES' => 0});
$mb->create_structure();
my $backup_db = $mb->data_backup();
my $file = $backup_db;
$file .= ".sql";
if ($backup_db) {
open ( UPLOADFILE, "+>$backup_folder/$file" ) or die "$!";
binmode UPLOADFILE;
while ( <UPLOADFILE> )
{
print UPLOADFILE;
}
close UPLOADFILE;
}
else {
exit 1;
}
This is not tested or anything but notice the differences:
if (my $mb = new MySQL::Backup($database,$host,$user,$pwd,{'USE_REPLAC
+E' => 0, 'SHOW_TABLE_NAMES' => 0})) {
my $file = join '', 'db.backup.', time, '.sql';
if (my $backup_db = $mb->data_backup) {
open my $fh, "+>", "$backup_folder/$file" or die "Can't open $back
+up_folder/$file: $!";
print $fh $backup_db;
close $fh;
}
else {
die "Can't backup database!";
}
else {
die "Can't connect to database!";
}