#perl
#
# Script to backup the Analytica Wiki database to our local computer

#create the postfix
($sec, $min, $hour, $day, $month, $year, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime();
$month++;
$year = $year + 1900;
$postfix_Files = "_".$year."_".$month."_".$day.".tar.gz";
$postfix_Database = "_".$year."_".$month."_".$day.".sql";

$mwfiles = "mwFiles";
$mwdatabase ="mwDatabase";
$eefiles = "eeFiles";
$eedatabase = "eeDatabase";
$wpfiles = "wpFiles";
$wpdatabase = "wpDatabase";


print "PostfixFiles : " . $postfix_Files . "\n";
print "PostfixDatabase : " . $postfix_Database . "\n";
print "Transferring the files to this machine.\n";
#get the dump file
use Net::FTP;
$ftp = Net::FTP->new( "www.lumina.com" , Debug=>0) or die "Cannot connect to lumina.com";
$ftp->login("analytica", "Password1") or die "Cannot login to lumina.com.";
$ftp->binary();
print "Starting file transfer.\n";

$ftp->get($mwfiles, 'C:\\Backups\\LuminaWebsite\\mwFiles'.$postfix_Files) or die "Getting MediaWiki files failed.";
print "Transferring Mediawiki files complete.\n";
$ftp->get($mwdatabase, 'C:\\Backups\\LuminaWebsite\\mwDatabase'.$postfix_Database) or die "Getting Mediawiki database failed.";
print "Transferring Mediawiki database complete.\n";


$ftp->get($eefiles, 'C:\\Backups\\LuminaWebsite\\eeFiles'.$postfix_Files) or die "Getting EE files failed.";
print "Transferring EE files complete.\n";
$ftp->get($eedatabase, 'C:\\Backups\\LuminaWebsite\\eeDatabase'.$postfix_Database) or die "Getting EE database failed.";
print "Transferring EE database complete.\n";

$ftp->get($wpfiles, 'C:\\Backups\\LuminaWebsite\\wpFiles'.$postfix_Files) or die "Getting WordPress files failed.";
print "Transferring WordPress files complete.\n";
$ftp->get($wpdatabase, 'C:\\Backups\\LuminaWebsite\\wpDatabase'.$postfix_Database) or die "Getting WordPress database failed.";
print "Transferring WordPress database complete.\n";

$ftp->quit();
print "File transfer complete.\n";