Database Backup Stored Where?

Hi Guys,



Ok another nub question for you all. I do backups nightly for our website, and was going to start downloading the backups as well to our harddrive.



Questions …


  1. Where the heck can I find the backups in our Ftp area?


  2. Is there a script that will do auto backups each night on a set time?



    Thanks



    Milezone
  1. /var/database/


  2. No, unless you write it yourself.

Awesome thanks. Now gotta find a willing programmer to look into that kind of mod. :slight_smile:



Milezone

hi you had asked about a backup script…if you know how to use cron…you can have it automatically execute this nightly or whenever you want it to trigger.


  1. please make sure you check the settings correctly on this one. you have to replace a few sections.


  2. i have my setup to be like

    /httpdocs/mydomain.com/cron/backup.php



    then i execute cron from my plesk/cpanel to execute that nightly.


  3. ensure that the place you have as your TARGET directory, can hold the data (chmod permissions etc) and you have the capacity to do this.


  4. once u have for example gone thru 01/01/2010

    on 02/01/2010 it auto overwrites 01/01/2010 so you can have a daily backup done and save it for up to 1 month with this script:







// SYSTEM BACKUP
$emailaddress = "admin@yourdomainname.com";
$target = "/var/backup/your_folder_name/backup." . date("d") . ".tar.gz";
//if (file_exists($target)) unlink($target);
system("tar -C / --create --preserve --gzip --file=".$target." var/www/vhosts/yourdomain.com/httpdocs ",$result);
$size = filesize($target);
switch ($size) {
case ($size>=1048576): $size = round($size/1048576) . " MB"; break;
case ($size>=1024); $size = round($size/1024) . " KB"; break;
default: $size = $size . " bytes"; break;
}
$message = "Your Domain backup has been run.\n\n";
$message .= "The return code was: " . $result . "\n\n";
$message .= "The file path is: " . $target . "\n\n";
$message .= "Size of the backup: " . $size . "\n\n";
$message .= "Server time of the backup: " . date(" F d h:ia") . "\n\n";
mail($emailaddress, "Site Backup Complete" , $message, "From: Website <>");


//DATABASE BACKUP

$host="localhost"; // database host
$dbuser="add_your_username_here"; // database user name
$dbpswd="add_your_pass_here"; // database password
$mysqldb="db_name_here"; // name of database

$filename = "/var/backup/foldername/backup" . date("d") . ".sql";

if ( file_exists($filename) ) unlink($filename);
system("mysqldump --user=$dbuser --password=$dbpswd --host=$host $mysqldb > $filename",$result);
$size = filesize($filename);
switch ($size) {
case ($size>=1048576): $size = round($size/1048576) . " MB"; break;
case ($size>=1024): $size = round($size/1024) . " KB"; break;
default: $size = $size . " bytes"; break;
}
$message = "The database backup for " . $mysqldb . " has been run.\n\n";
$message .= "The return code was: " . $result . "\n\n";
$message .= "The file path is: " . $filename . "\n\n";
$message .= "Size of the backup: " . $size . "\n\n";
$message .= "Server time of the backup: " . date(" F d h:ia") . "\n\n";
mail($emailaddress, "DB Backup Complete" , $message, "From: Website <>");

?>

There is no need for a mod, people are doing it through chron for any kinds of similar needs.



The script above has too much of needless output, 2 lines would do it.

I used cron, …google cron backups. But martofx do 4 backups a day anyways, so now i dont bother.



John