Getting 0KB of size file while backup mysql database using mysql dump
I don't know how to write this in php, but you should write mysqldump command like below, there is no need to write three command one is enough

mysqldump --user=root --password=root --host=localhost --single-transaction --routines db_name &gt; db_name.sql




UPDATE

I did it here is the php script

&lt;?php
define("BACKUP_PATH", "/home/abdul/");

$server_name   = "localhost";
$username      = "root";
$password      = "root";
$database_name = "world_copy";
$date_string   = date("Ymd");

$cmd = "mysqldump --routines -h {$server_name} -u {$username} -p{$password} {$database_name} &gt; " . BACKUP_PATH . "{$date_string}_{$database_name}.sql";

exec($cmd);
?&gt;


It generate backup file named as 20140225_world_copy.sql in /home/abdul/

For reference have a look at This link.