...

View Full Version : MYSQL back up gzip file empty ?



Crowds
08-22-2006, 03:49 PM
I have been trying to use the script below to back up my database. It creates a gzip file sure enough but the file inside it has no extension, so i add .sql to it (is that right ?!?) and open it up to find its empty...
Whats going on there ?
<?php
error_reporting (E_ALL);

require '../Connections/CDblog.php';

if($link = mysql_connect($hostname_CDblog,$username_CDblog,$password_CDblog)){
mysql_select_db($database_CDblog);
}

$backupFile = $database_CDblog . date("Y-m-d-H-i-s") . '.gz';
$command = "mysqldump --opt -h $hostname_CDblog -u $username_CDblog -p $password_CDblog $database_CDblog | gzip > $backupFile";
system($command);

?>

I dont want to actualy back up the database in full but just a few tables. But the below method to do this always brings me this error
Access denied for user: '............@%' (Using password: YES)
I have no trouble connecting to the database in any other way.
Could it have something to do with the fact that the MYSQL server is not localhost but on an entirely different server ?

<?php
error_reporting (E_ALL);

require '../Connections/CDblog.php';

if($link = mysql_connect($hostname_CDblog,$username_CDblog,$password_CDblog)){
mysql_select_db($database_CDblog);
}



$backupfile = '/MYSQL_backup/CDblg_article_art.sql';

$sql = "SELECT * INTO OUTFILE '$backupfile' FROM CDblg_article_art";
mysql_query($sql)or die(mysql_error());

?>

Also is there a way to alter the mysql command

mysqldump --opt -h $hostname_CDblog -u $username_CDblog -p $password_CDblog $database_CDblog | gzip > $backupFile
So it selects only one table ?

Crowds



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum