Hello
I have been using Net::FTP in a script to backup server data with a cron run at night. It was working, then I bumped my head and ran out of allocated space on the backup server. I contracted for additional space but it [green]*seems*[/green] like the process [green]*may*[/green] still be hanging..... that is, transferring some data but not all. I have figured the script doesn't complete, because it has not been stopping the FTP server (proftpd) like it did at first, and the data transferred shows one file incomplete, and the other not transferred.
I have looked at /var/log/messages but that only lists logins. The config file /etc/proftpd.conf does not seem suited to writing error messages.
I am testing the following cron statement to send output to a log file.... I will know if it worked tomorrow:
[blue]01 1 * * 2,4,6 /backup/serverbackup.pl >>/backup/backup.log[/blue]
I will be grateful for any suggestions to write results to a log file when the ftp->put procedure is completed, or if it is interrupted, stalled or shut down prematurely.
Thanks, Mike
I have been using Net::FTP in a script to backup server data with a cron run at night. It was working, then I bumped my head and ran out of allocated space on the backup server. I contracted for additional space but it [green]*seems*[/green] like the process [green]*may*[/green] still be hanging..... that is, transferring some data but not all. I have figured the script doesn't complete, because it has not been stopping the FTP server (proftpd) like it did at first, and the data transferred shows one file incomplete, and the other not transferred.
I have looked at /var/log/messages but that only lists logins. The config file /etc/proftpd.conf does not seem suited to writing error messages.
I am testing the following cron statement to send output to a log file.... I will know if it worked tomorrow:
[blue]01 1 * * 2,4,6 /backup/serverbackup.pl >>/backup/backup.log[/blue]
I will be grateful for any suggestions to write results to a log file when the ftp->put procedure is completed, or if it is interrupted, stalled or shut down prematurely.
Thanks, Mike
Code:
#!/usr/bin/perl
# START FTP
system "/backup/startftp.pl";
$dateStamp = `/bin/date +"%w%a"`; chop ($dateStamp);
$HostingbackupPath = "/htdocs";
$HostingtarPath = "/backup/hostingfiles";
$HostingtarName = "HOSTING.$dateStamp.tar";
$HostinggzName = "$HostingtarPath/$HostingtarName.gz";
$MysqltarPath = "/backup/mysqlfiles";
$MysqltarName = "MYSQL.$dateStamp.tar";
$MysqlgzName = "$MysqltarPath/$MysqltarName.gz";
$EtctarPath = "/backup/etcfiles";
$EtcbackupPath = "/etc";
$EtctarName = "ETC.$dateStamp.tar";
$EtcgzName = "$EtctarPath/$EtctarName.gz";
@db = `cat /backup/dblist`;
foreach $db (@db) {
chomp $db;
{
$dbase = "$db.$dateStamp";
`/usr/bin/mysqldump -u root -pPASS $db > $MysqltarPath/$dbase`;
}
}
system "tar cvfp $MysqltarPath/$MysqltarName $MysqltarPath/*.$dateStamp ";
system "gzip -f $MysqltarPath/$MysqltarName";
system "tar cvfp $HostingtarPath/$HostingtarName $HostingbackupPath/*";
system "gzip -f $HostingtarPath/$HostingtarName";
use Net::FTP;
$ftp = Net::FTP->new("111.222.333.444") or die "Couldn't connect to 111.222.333.444 $@\n";
$ftp->login("USER", "PASS") or die "Couldn't login\n";
$ftp->put("$HostinggzName") or die "Couldn't upload $HostinggzName\n";
$ftp->put("$MysqlgzName") or die "Couldn't upload $MysqlgzName\n";
$ftp->quit();
# STOP FTP
system "/backup/stopftp.pl";