MySQL Backup Creating Empty File

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
illmapu
Forum Commoner
Posts: 47
Joined: Fri Aug 22, 2003 1:48 pm

MySQL Backup Creating Empty File

Post by illmapu »

Hi,

I am trying to copy a backup of the database on the server, here is the code:

Code: Select all

$ste_backup = $db . date("Y-m-d-H-i-s") . '.sql';
$ste_backup2 = "mysqldump --opt -h $dbhost -u $dbuser -p $dbpass $db > $ste_backup";
system($ste_backup2);
It is correctly naming the file by date, time and it ends in .sql etc, but the file is empty.

So, what happens is that it all looks perfect on the server, but no data in the file. I have set chmod to 777 too.

Any idea why the file would be empty or what I could do to fix it?

Thanks in advance! :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

check your error logs, check the string to make sure all the variables are in there as you expect them.
illmapu
Forum Commoner
Posts: 47
Joined: Fri Aug 22, 2003 1:48 pm

Post by illmapu »

Hi,

I have no error logs, all variables are as I expect, it is just creating an empty file, like it is not getting the data from doing the mysqldump.

Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

have you tried using shell_exec() or exec() by chance?
illmapu
Forum Commoner
Posts: 47
Joined: Fri Aug 22, 2003 1:48 pm

Post by illmapu »

Hi,

No I haven't.

The only problem is that the file has no data in it.

Thanks!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

well.. your syntax is wrong, it appears.

Code: Select all

$ste_backup = $db . date("Y-m-d-H-i-s") . '.sql';
$ste_backup2 = "mysqldump --opt -h$dbhost -u$dbuser -p$dbpass $db > $ste_backup";
system($ste_backup2);
Post Reply