I have found this backup script for mysql databases, now I run it, everything is successfull and the file is added to the spicific folder, but nothing is in it, its 0kb's whys that? Any reason? I have tryed many different backup scripts but still none work.
<?php
//================================================
// Auto backup your databases
//================================================
$backup_dir = dirname( __FILE__ ) . '/backups/';
$u = 'xxx';
$p = 'xxx';
$db = 'xxx';//This is just the name of a database just to make the query work. The script will backup all the databases that your use has access to.
$db_link = mysql_connect($h,$u,$p);
$res = mysql_db_query($db, 'SHOW DATABASES', $db_link) or die('Could not connect: ' . mysql_error());
echo 'Found '. mysql_num_rows($res) . ' databases' . "\n";
while ( $rec = mysql_fetch_array($res) )
{
//Parse time :
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
echo $rec[0] . "\n";
shell_exec( 'mysqldump --default-character-set=greek --result-file='.$backup_dir.$rec[0].'.'.date('Y-m-d').'.sql --password='.$p.' '.$rec[0] );
//Parse time :
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round(($finish - $start), 6);
echo 'Parsed in ' . $total_time . ' secs' . "\nStarting with compression\n";
}
//Let's tar those backups :
shell_exec( 'tar cvf '.$backup_dir.date('Y-m-d').'.tar '.$backup_dir.'*.sql' );
?>
Any help is appreciated
Edited by Braunson, 15 July 2007 - 11:18 AM.
