Page 1 of 1

Mysql Dump - Database Backup

Posted: Thu Jun 03, 2010 1:25 am
by venkatgants
ahm i'm used this

$dump = "mysqldump-u$user-p$pass$dbname>db/backup.sql";

system($dump);

but when i open the backup.sql, its blank

Re: Mysql Dump - Database Backup

Posted: Thu Jun 03, 2010 1:28 am
by requinix
You did put spaces in there, right?

Try running that on the command line yourself and see if there are any error messages.

Re: Mysql Dump - Database Backup

Posted: Thu Jun 03, 2010 1:46 am
by venkatgants

Code: Select all

$backupFile =  "db/".date("Y-m-d-H-i-s")."."."sql";
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$dbname = "pdmr_tracky";

echo $dump = "mysqldump --opt -h ".$dbhost." -u ". $dbuser." -p ". $dbpass. $dbname." > ".$backupFile; 
system($dump);

This is code. How to use in command prompt.
d:wamp this is wamp path...

pls help me...

Re: Mysql Dump - Database Backup

Posted: Thu Jun 03, 2010 2:03 am
by requinix
Like I said, try running that from the command line and see what happens.

Re: Mysql Dump - Database Backup

Posted: Thu Jun 03, 2010 2:05 am
by venkatgants
our wamp path is D:\wamp, we dont know how to enter query and where (path).
so that we included php code. please guide me.

Re: Mysql Dump - Database Backup

Posted: Mon Jul 12, 2010 5:04 am
by kirank
TRy this code

Create a folder named "backup" in current folder where this program runs and chmod to 777

Code: Select all

<?php


/*
 * -------------------------------------------------------------
 	Database backup script 
 * -------------------------------------------------------------
*/



set_time_limit(0);
/*
 * Directory name for storage
 * All back will store to backup folder in the current running folder
 
*/

$dirName	=	dirname(__FILE__)."";  

/*
 * Database configuration 
*/
$dbUser		=	"nroot";
$dbPass		=	"pass";
$dbName		=	"dbname";
$dbHost		=	"localhost";




/*
 * Executes the Mysqldump for backup 
*/

$fileName	=	strtotime(date("Y-m-d H:i:s"))."-{$dbName}-backup.sql";
$command	=	"mysqldump --opt --host={$dbHost} --user={$dbUser} --password={$dbPass} {$dbName} > {$dirName}/backup/{$fileName}";
$res = exec($command);

echo $command;
echo $res;

?>
this will