Hi...for some reason, when run via Telnet, I get this showing, and just staying like it for ages (have to press Ctrl-Z to get it to stop)....
The code is;
sub do_backup {
print "Running backup...\n";
# DO THE SQL DATABASES...
# first of all do the
$path_to_db = $current_dir . "databases.pl";
chmod(0666, "$path_to_db");
open(DATABASE_LIST,"$path_to_db") || &mail_error("Unable to open $path_to_db. Reason: $!");
@databases = <DATABASE_LIST>;
close(DATABASE_LIST);
# now work out what we need in the query;
if ($add_locks) { $opts .= "--add-locks "; }
if ($add_drop_table) { $opts .= "--add-drop-table "; }
if ($delayed) { $opts .= "--delayed "; }
if ($extended_insert) { $opts .= "--extended-insert "; }
if ($lock_tables) { $opts .= "--lock-tables "; }
if ($xml) { $opts .= "--xml "; }
foreach (@databases) {
chomp;
@divided = split /\:\:/, $_;
$database_name = $divided[0];
$save_to = $divided[1];
$username = $divided[2];
$password = $divided[3];
$host = $divided[4];
chmod(0666, "$current_dir/sql/$save_to.sql.dump");
print "Backing up $database_name\n";
$results_database .= "Results for database '$database_name' (nothing is normally good) :: \n";
$bad = 0; # reset for each loop...
print "$path_to_mysql_dump -u$username -p$password $opts $database_name > $current_dir/sql/$save_to.sql.dump |\n";
open PIPE, "$path_to_mysql_dump -u$username -p$password $opts $database_name > $current_dir/sql/$save_to.sql.dump |";
@res = <PIPE>;
close PIPE or $bad = "$?,$!";
if ($bad) { $report = "ERROR: Could not backup '$database_name' database!"; } else { $report = "Backed Up '$database_name' to '$save_to'"; }
$results_database .= "$report \n\n";
}
# NOW THE FOLDERS!
# first of all do the
$path_to_folder = $current_dir . "folder.pl";
chmod(0666, $path_to_folder);
open(FOLDER_LIST,$path_to_folder) || &mail_error("Unable to open $path_to_folder. Reason: $!");
@folders = <FOLDER_LIST>;
close(FOLDER_LIST);
foreach (@folders) {
chomp;
@divided = split /\:\:/, $_;
$folder_path = $divided[0];
$folder_name = $divided[1];
# chmod em in case they dont haver correct permissions...
chmod(0666, "$folder_name.tar");
chmod(0666, "$folder_name.tar.gz");
print "Backing up $folder_name\n";
$results_database .= "Results for folder '$folder_name'\n";
$bad = 0; # reset for each loop...
open PIPE, "tar -cf $folder_name.tar $folder_path |";
@res = <PIPE>;
close PIPE or $bad = "$?,$!";
if ($bad) { $report = "ERROR: Could not backup '$folder_path' to '$folder_name'"; } else { $report = "Backed Up '$folder_path' to '$folder_name.tar.gz'"; }
`gzip -c $folder_name.tar > $current_dir$folder_name.tar.gz`;
`rm $folder_name.tar`;
$results_database .= "$report \n\n";
}
# if they want an email, then send it here...
if ($send_mail_to_admin) {
open(MAIL,"|$sendmail -t");
print MAIL "To: $webmaster \n";
print MAIL "From: $webmaster \n";
print MAIL "Reply-to: $webmaster \n";
print MAIL "Subject: RE Backup...\n\n";
print MAIL "Here is the resuilts of your server backup. It did both MySQL and Folder backups. \n\n$results_database\n";
print MAIL "\n \n Thanks";
print MAIL "\n";
print MAIL "A.J.Newby \n";
print MAIL "Ace Installer \n";
close(MAIL);
}
print "done backup";
exit; # stop it here, otherwise it will carry on showing HTML :)
}
I've been playing with this code for ages, adding debug info, printing something at the top (ino case it was waiting to print something), and several other things...but nothing seem to sort it out Has anyone else ever had this problem?
Cheers
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote:
(offline mode: enter name=value pairs on standard input)The code is;
Code:
# do the backup... sub do_backup {
print "Running backup...\n";
# DO THE SQL DATABASES...
# first of all do the
$path_to_db = $current_dir . "databases.pl";
chmod(0666, "$path_to_db");
open(DATABASE_LIST,"$path_to_db") || &mail_error("Unable to open $path_to_db. Reason: $!");
@databases = <DATABASE_LIST>;
close(DATABASE_LIST);
# now work out what we need in the query;
if ($add_locks) { $opts .= "--add-locks "; }
if ($add_drop_table) { $opts .= "--add-drop-table "; }
if ($delayed) { $opts .= "--delayed "; }
if ($extended_insert) { $opts .= "--extended-insert "; }
if ($lock_tables) { $opts .= "--lock-tables "; }
if ($xml) { $opts .= "--xml "; }
foreach (@databases) {
chomp;
@divided = split /\:\:/, $_;
$database_name = $divided[0];
$save_to = $divided[1];
$username = $divided[2];
$password = $divided[3];
$host = $divided[4];
chmod(0666, "$current_dir/sql/$save_to.sql.dump");
print "Backing up $database_name\n";
$results_database .= "Results for database '$database_name' (nothing is normally good) :: \n";
$bad = 0; # reset for each loop...
print "$path_to_mysql_dump -u$username -p$password $opts $database_name > $current_dir/sql/$save_to.sql.dump |\n";
open PIPE, "$path_to_mysql_dump -u$username -p$password $opts $database_name > $current_dir/sql/$save_to.sql.dump |";
@res = <PIPE>;
close PIPE or $bad = "$?,$!";
if ($bad) { $report = "ERROR: Could not backup '$database_name' database!"; } else { $report = "Backed Up '$database_name' to '$save_to'"; }
$results_database .= "$report \n\n";
}
# NOW THE FOLDERS!
# first of all do the
$path_to_folder = $current_dir . "folder.pl";
chmod(0666, $path_to_folder);
open(FOLDER_LIST,$path_to_folder) || &mail_error("Unable to open $path_to_folder. Reason: $!");
@folders = <FOLDER_LIST>;
close(FOLDER_LIST);
foreach (@folders) {
chomp;
@divided = split /\:\:/, $_;
$folder_path = $divided[0];
$folder_name = $divided[1];
# chmod em in case they dont haver correct permissions...
chmod(0666, "$folder_name.tar");
chmod(0666, "$folder_name.tar.gz");
print "Backing up $folder_name\n";
$results_database .= "Results for folder '$folder_name'\n";
$bad = 0; # reset for each loop...
open PIPE, "tar -cf $folder_name.tar $folder_path |";
@res = <PIPE>;
close PIPE or $bad = "$?,$!";
if ($bad) { $report = "ERROR: Could not backup '$folder_path' to '$folder_name'"; } else { $report = "Backed Up '$folder_path' to '$folder_name.tar.gz'"; }
`gzip -c $folder_name.tar > $current_dir$folder_name.tar.gz`;
`rm $folder_name.tar`;
$results_database .= "$report \n\n";
}
# if they want an email, then send it here...
if ($send_mail_to_admin) {
open(MAIL,"|$sendmail -t");
print MAIL "To: $webmaster \n";
print MAIL "From: $webmaster \n";
print MAIL "Reply-to: $webmaster \n";
print MAIL "Subject: RE Backup...\n\n";
print MAIL "Here is the resuilts of your server backup. It did both MySQL and Folder backups. \n\n$results_database\n";
print MAIL "\n \n Thanks";
print MAIL "\n";
print MAIL "A.J.Newby \n";
print MAIL "Ace Installer \n";
close(MAIL);
}
print "done backup";
exit; # stop it here, otherwise it will carry on showing HTML :)
}
I've been playing with this code for ages, adding debug info, printing something at the top (ino case it was waiting to print something), and several other things...but nothing seem to sort it out Has anyone else ever had this problem?
Cheers
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!