Help with script - 11/15/2005 8:53 PM
I run a small Perl script to back up my UBB directory and MySQL database. I would like to make an addition that would chack for space so that if X amount of space is not free the back up would abort then send me an email.
Here is what I have so far... Can someone give me a hand or point me in the right direction? Still very poor in writting code
Here is what I have so far... Can someone give me a hand or point me in the right direction? Still very poor in writting code
Code
#!/usr/bin/perl
# System backup
#------ Variables ------
$backupdir = "/usr/local/pwrhouse"; # "." for current
$other_dirs = "/usr/local/hostboard/mainboard/cgi-bin /usr/local/hostboard/mainboard/htdocs";
#-----------------------
print "Backup Initiated...n";
@timenow = localtime(time);
$newfilename = sprintf("%02d",$timenow[4]+1) .
sprintf("%02d",$timenow[3]) . ($timenow[5] + 1900);
print "Using Filename: $newfilename.sql n";
print "Starting database backup... n";
system "mysqldump -qce -r $newfilename.sql -u root ubb";
print "Starting Compression... n";
system "tar czf $backupdir/$newfilename.tar.gz $other_dirs $newfilename.sql";
unlink "$newfilename.sql" || print "Error: Cannot delete file specified: $newfilename - $_ n";
print "Done. n"