Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: backuping mysql

by Anonymous Monk
on Jul 03, 2024 at 16:05 UTC ( [id://11160350]=note: print w/replies, xml ) Need Help??


in reply to backuping mysql

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!"; }

Replies are listed 'Best First'.
Re^2: backuping mysql
by Anonymous Monk on Jul 03, 2024 at 19:27 UTC
    I was going to concatenate the filename but didn't like the number of dots:
    my $file = 'db.backup.' . time . '.sql';
    
    So I used join but forgot to clean up the dots:
    my $file = join '', 'db.backup.', time, '.sql';
    
    Still works the same but should be like this:
    my $file = join '.', 'db.backup', time, 'sql';
    

      or even:

      my $file = sprintf 'db.backup.%i.sql', time;

      🦛

Re^2: backuping mysql
by frank1 (Scribe) on Jul 03, 2024 at 17:15 UTC

    thank you, i got it working now by following your demo

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11160350]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-09-18 11:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (24 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.