Gossamer Forum
Home : Products : DBMan : Customization :

Error 500 when backing up

Quote Reply
Error 500 when backing up
Hi,

when executing the backup sub I get a 500. Why??? The backup file is created corectly, however the counter file doesn't save the new value.

Thank you for the help!

sub html_backup_db {
$n=0;
$c=10;
#####--Change the number after $c above to the number of backups you would like (currently set for 10 backups).
#####--CREATE A BLANK COUNTER FILE, whose name will be inserted below.
#####--If you are making several backup routines, make sure the counter files have
#####--different names.
#####--Change the path below after NUM, to the full path and name of your counter file.
open (NUM, $db_BackupCounter) or &cgierr ("unable to open $db_BackupCounter. reason: $!");
$n=<NUM>;
if ($n<$c) {++$n;}
else {$n=1}
print $n;
#####--Change the path below after TEST, to the full path and name of you counter file.
#####--Should be the same file name as above.
open (TEST, ">$db_BackupCounter");
print TEST $n;
close TEST;
close NUM;
#####--Change the path below after DAT, to the full path and of the file you want backed up.
open (DAT, $db_file_name) or &cgierr ("unable to open $db_file_name. reason: $!");
#####--Change the path below after DATTMP, to the full path and name
#####--of the backup files (you can change the file name, but leave the $n -- it will
#####--return the backup count).
open (DATTMP, ">$db_Backup$n") or &cgierr ("unable to open $db_Backup/$_. reason: $!");
while (<DAT> ) {
print DATTMP;
}
close DAT;
close DATTMP;
}

Jakob

Quote Reply
Re: Error 500 when backing up In reply to
Jakob,

I'm gonna take a shot in the dark, but I think you might be missing a ; in the code (shown below):

Code:
sub html_backup_db {
$n=0;
$c=10;
#####--Change the number after $c above to the number of backups you would like (currently set for 10 backups).
#####--CREATE A BLANK COUNTER FILE, whose name will be inserted below.
#####--If you are making several backup routines, make sure the counter files have
#####--different names.
#####--Change the path below after NUM, to the full path and name of your counter file.
open (NUM, $db_BackupCounter) or &cgierr ("unable to open $db_BackupCounter. reason: $!");
$n=<NUM>;
if ($n<$c) {++$n;}

else {$n=1;}

print $n;
#####--Change the path below after TEST, to the full path and name of you counter file.
#####--Should be the same file name as above.
open (TEST, ">$db_BackupCounter");
print TEST $n;
close TEST;
close NUM;
#####--Change the path below after DAT, to the full path and of the file you want backed up.
open (DAT, $db_file_name) or &cgierr ("unable to open $db_file_name. reason: $!");
#####--Change the path below after DATTMP, to the full path and name
#####--of the backup files (you can change the file name, but leave the $n -- it will
#####--return the backup count).
open (DATTMP, ">$db_Backup$n") or &cgierr ("unable to open $db_Backup/$_. reason: $!");
while (<DAT> ) {
print DATTMP;
}
close DAT;
close DATTMP;
}
Try it and tell me if that does the trick.

Regards,



Michael DeLong
Quote Reply
Re: Error 500 when backing up In reply to
Hi,

that didn't do it. I still receive the error message on the server log. malformed header from script. Bad header=2:

Thank you for the try!

Jakob

Quote Reply
Re: Error 500 when backing up In reply to
I believe the problem deals with missing Content/Type statement at the top of the subroutine...I would recommend using text/plain since all you are doing is printing text statements.

Like the following:

Code:

print "Content-type: text/plain\n\n";


Regards,

Eliot Lee


Quote Reply
Re: Error 500 when backing up In reply to
The only other thing I can think of is why would you be putting this sub routine in the html.pl file if it doesn't print anything...Should it be in the db.cgi file?

Regards,



Michael DeLong
Quote Reply
Re: Error 500 when backing up In reply to
Nice try...yet the malformed header message would still result without identifying the Content/Type (header) if the sub was moved to the db.cgi file.

Regards,

Eliot Lee

Quote Reply
Re: Error 500 when backing up In reply to
Thanks...I'm trying to learn and teach at the same time; very hard to do.



Michael DeLong
Quote Reply
Re: Error 500 when backing up In reply to
Good argument!
- Done...

Jakob

Quote Reply
Re: Error 500 when backing up In reply to
Thank you for the hint!!! That did the trick!

Jakob

Quote Reply
Re: Error 500 when backing up In reply to
What did the trick?

Regards,

Eliot Lee

Quote Reply
Re: Error 500 when backing up In reply to
I think he meant your suggestion....

BTW: Do you think the missing ; I pointed out might have been a problem too?

Michael DeLong
Quote Reply
Re: Error 500 when backing up In reply to
Hi,

at first I thought your added line made the difference. However after a little more testing and adding a little html I noticed that your line was just printed to the screen. It makes sence if one looks at the script.
I rechecked all permissions and voila it worked. So.. my appologies... it seemed to be my mistake!!!

The script now is...
sub backup_db {

$n=0;
$c=10;
#####--Change the number after $c above to the number of backups you would like (currently set for 10 backups).
#####--CREATE A BLANK COUNTER FILE, whose name will be inserted below.
#####--If you are making several backup routines, make sure the counter files have
#####--different names.
#####--Change the path below after NUM, to the full path and name of your counter file.
open (NUM, $db_BackupCounter) or &cgierr ("unable to open $db_BackupCounter. reason: $!");
$n=<NUM>;
if ($n<$c) {++$n;}
else {$n=1}
print $n;
print NUM $N;
close NUM;
#####--Change the path below after TEST, to the full path and name of you counter file.
#####--Should be the same file name as above.
open (TEST, ">$db_BackupCounter") or &cgierr ("unable to open $db_BackupCounter. reason: $!");
print TEST $n;
close TEST;

#####--Change the path below after DAT, to the full path and of the file you want backed up.
open (DAT, $db_file_name) or &cgierr ("unable to open $db_file_name. reason: $!");
#####--Change the path below after DATTMP, to the full path and name
#####--of the backup files (you can change the file name, but leave the $n -- it will
#####--return the backup count).
open (DATTMP, ">$db_Backup$n") or &cgierr ("unable to open $db_Backup/$_. reason: $!");
while (<DAT> ) {
print DATTMP;
}
close DAT;
close DATTMP;
&html_backup_success
}
####################################################################################
###
### END OF SCRIPT

sub html_backup_success {
#-----------------------------------------------

my ($message,@users) = @_;

&html_print_headers;

print qq|
<html><head><title>$html_title: Backup</title></head>
<body bgcolor="#DDDDDD">
<center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 align=center valign=top>
<tr><td colspan=2 bgcolor="navy">
<FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: Backup</b></td></tr>
<tr><td><p><center><$font_title><b>
Backup
</b></font></center>

|;

print qq|<$font>Your backup was successfull!.</font>
|;
&html_footer;
print qq|</td></tr></table></body></html>|;
}

Jakob

Quote Reply
Re: Error 500 when backing up In reply to
Hi Michael,

first of all thank you for your help! As you can see in the previous mail of mine, it seems to be a mistake of mine...

I tried the script with and without your ";". It doesn't seem to make a difference.

Jakob