\n"; goto donebackup; } } foreach $db (@dbs) { my $deletefile = 0; if ($in{'all'}) { # File in a directory $dir = &date_subs($in{'file'}); $prefix = &date_subs($in{'prefix'}); &make_dir($dir, 0755) if ($in{'mkdir'}); $file = $dir."/".$prefix.$db.".sql". ($in{'compress'} == 1 ? ".gz" : $in{'compress'} == 2 ? ".bz2" : ""); $deletefile = 1; } elsif (!$in{'dest'}) { # Single file $file = &date_subs($in{'file'}); $deletefile = 1; } else { # Temp file for download $file = &transname(); if ($access{'buser'} && $access{'buser'} ne 'root') { # Need to pre-create file owned by user who # will be doing the writing &open_tempfile(FILE, ">$file", 0, 1); &close_tempfile(FILE); &set_ownership_permissions($access{'buser'}, undef, undef, $file); } } if (-d $file) { print &text('backup_eisdir', &html_escape($file)),"
\n"; next; } if ($cron && $cmode == 0) { # Run and check before-backup command (for one DB) $bok = &execute_before($db, STDOUT, 1, $file, $in{'all'} ? undef : $db); if (!$bok) { print $text{'backup_ebefore'},"
\n"; next; } } &unlink_file($file) if ($deletefile); local $err = &backup_database($db, $file, $in{'compress'}, $in{'drop'}, $in{'where_def'} ? undef : $in{'where'}, $in{'charset_def'} ? undef : $in{'charset'}, \@compat, \@tables, $access{'buser'}, $in{'single'}, $in{'quick'}, undef, $in{'parameters'}); if ($err) { print &text('backup_ebackup', "
".&html_escape($err)."
\n"; } elsif (!$in{'dest'}) { @st = stat($file); print &text('backup_done', "$db", "$file", int($st[7])),"
\n"; } &execute_after($db, STDOUT, 1, $file, $in{'all'} ? undef : $db) if ($cron && $cmode == 0); if ($in{'dest'}) { # Sent to browser open(OUT, "<$file"); while() { print $_; } close(OUT); &unlink_file($file); } } &execute_after(undef, STDOUT, 1, $in{'file'}, undef) if ($cmode == 1); donebackup: } if ($cron) { &lock_file($cron_cmd); &cron::create_wrapper($cron_cmd, $module_name, "backup.pl"); &unlock_file($cron_cmd); &lock_file(&cron::cron_file($job)); if ($in{'sched'} && !$oldjob) { &cron::create_cron_job($job); $what = "backup_ccron"; } elsif (!$in{'sched'} && $oldjob) { # Need to delete cron job &cron::delete_cron_job($job); $what = "backup_dcron"; } elsif ($in{'sched'} && $oldjob) { # Need to update cron job &cron::change_cron_job($job); $what = "backup_ucron"; } else { $what = "backup_ncron"; } &unlock_file(&cron::cron_file($job)); # Tell the user what was done print $text{$what},"\n" if ($what && !$in{'dest'}); } &webmin_log("backup", undef, $in{'all'} ? "" : $in{'db'}, \%in); if (!$in{'dest'}) { if ($in{'all'}) { &ui_print_footer("", $text{'index_return'}); } else { &ui_print_footer( "edit_dbase.cgi?db=$in{'db'}", $text{'dbase_return'}, &get_databases_return_link($in{'db'}), $text{'index_return'}); } }
\n" if ($what && !$in{'dest'}); } &webmin_log("backup", undef, $in{'all'} ? "" : $in{'db'}, \%in); if (!$in{'dest'}) { if ($in{'all'}) { &ui_print_footer("", $text{'index_return'}); } else { &ui_print_footer( "edit_dbase.cgi?db=$in{'db'}", $text{'dbase_return'}, &get_databases_return_link($in{'db'}), $text{'index_return'}); } }