<?php

if (defined('IN_PMBT'))die ("You can't include this file");
define("IN_PMBT",true);
$backupdir = '/backups'; //Ensure this folder (under your main tracker root) is chmod 777



require_once("include/configdata.php");
$host= $db_host;       
$user= $db_user;             
$pass= $db_pass;
$db= $db_name;

 $today = getdate();
 $day = $today[mday];
 if ($day < 10) {
    $day = "0$day";
 }
 $month = $today[mon];
 if ($month < 10) {
    $month = "0$month";
 }
 $year = $today[year];
 $hour = $today[hours];
 $min = $today[minutes];
 $sec = "00";

 // Execute mysqldump command.
 // It will produce a file named $db-$year$month$day-$hour$min.gz
 // under $DOCUMENT_ROOT/$backupdir
 system(sprintf(
 //'mysqldump --opt -h %s -u %s -p%s %s > %s/%s/%s-%s-%s-%s.sql',    
 'mysqldump --opt -h %s -u %s -p%s %s | gzip > %s/%s/%s-%s-%s-%s.gz',                                    
  
  $host,
  $user,
  $pass,
  $db,
  getenv('DOCUMENT_ROOT'),
  $backupdir,
  $db,
  $day,
  $month,
  $year
 )); 


$name = $db."-".$day."-".$month."-".$year.".gz";
$date = date("Y-m-d");
$day = date("d");
?>
