Hey Blizzard, thanks for the help. Just created a php file (backup_bbclone_data_files.php) that is executed via cron everyday in middle of night. It even sends an informative email.
cron command is (you'll have to adjust yours per your server)
Code:
/ramdisk/bin/php4 $HOME/backup/bbclone_data_backups/backup_bbclone_data_files.php
You probably already have something like below php file, named "backup_bbclone_data_files.php". This might be handy for next person who stumbles upon this forum looking for counter. Will need to adjust the email and domain and folder locations to your server setup.
Code:
<?php
// ------------------------------
// Script to backup the two data files for BBClone:
// /bbclone/var/access.php & /bbclone/var/last.php
// should be executed by cron and saved in folder:
// /../backup/bbclone_data_backups/
// with a new name including the date to differentiate files.
// ------------------------------
// Values for my server account
$emailaddress = "email@domain.com";
// today date
$todaydate = date("ymd");
// original and destination (wihout the .gz) filenames
$orig_filename1 = "/home/myfolder/public_html/bbclone/var/access.php";
$dest_filename1 = "/home/myfolder/backup/bbclone_data_backups/access.php_" . $todaydate; // year-month-day format
$orig_filename2 = "/home/myfolder/public_html/bbclone/var/last.php";
$dest_filename2 = "/home/myfolder/backup/bbclone_data_backups/last.php_" . $todaydate; // year-month-day format
// deletes the file if it already exists
if ( file_exists($dest_filename1) ) unlink($dest_filename1);
if ( file_exists($dest_filename2) ) unlink($dest_filename2);
// Perform copy and then gzip
system("cp " . $orig_filename1 ." ". $dest_filename1, $result1); // copy file adding the date in filename
system("gzip " . $dest_filename1, $result2); // will gzip file and add the .gz extension
system("cp " . $orig_filename2 ." ". $dest_filename2, $result3); // copy file adding the date in filename
system("gzip " . $dest_filename2, $result4); // will gzip file and add the .gz extension
//system("cp access.php ~/backup/bbclone_data_backups/access.php_080213",$result1);
//system("gzip ~/backup/bbclone_data_backups/access.php_080213",$result2);
//system("cp last.php ~/backup/bbclone_data_backups/last.php_080213",$result3);
//system("gzip ~/backup/bbclone_data_backups/last.php_080213",$result4);
// Analyze destination files and send email confirmation
$size1 = filesize($dest_filename1.".gz");
switch ($size1) {
case ($size1>=1048576): $size1 = round($size1/1048576) . " MB"; break;
case ($size1>=1024): $size1 = round($size1/1024) . " KB"; break;
default: $size1 = $size1 . " bytes"; break;
}
$size2 = filesize($dest_filename2.".gz");
switch ($size2) {
case ($size2>=1048576): $size2 = round($size2/1048576) . " MB"; break;
case ($size2>=1024): $size2 = round($size2/1024) . " KB"; break;
default: $size2 = $size2 . " bytes"; break;
}
$message = "The bbclone data file backup has been run.\n\n";
$message .= "The return code for cp of access.php was: " . $result1 . "\n";
$message .= "The return code for gzip of access.php_".$todaydate." was: " . $result2 . "\n";
$message .= "The return code for cp of last.php was: " . $result3 . "\n";
$message .= "The return code for gzip of last.php_".$todaydate." was: " . $result4 . "\n\n";
$message .= "The file path of access.php_".$todaydate.".gz is: " . $dest_filename1 . "\n";
$message .= "The file path of last.php_".$todaydate.".gz is: " . $dest_filename2 . "\n\n";
$message .= "Size of access.php_".$todaydate.".gz file: " . $size1 . "\n";
$message .= "Size of last.php_".$todaydate.".gz file: " . $size2 . "\n\n";
$message .= "Server time of the backup: " . date(" F d h:ia") . "\n\n";
mail($emailaddress, "bbclone data backup was complete" , $message, "From: Website <>");
?>
I still need to figure out my .htaccess aside issue.
Bookmarks