| Welcome to WebmasterWorld Guest from 126.96.36.199 |
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
|Pubcon Platinum Sponsor 2014|
|MySqldump creates empty file?|
Trying to backup database
I am Trying to create a one click backup database script so non-geek office staff can do this, but so far I can only output empty files
$db_user = "root";
$db_password = "";
$db_database = "or";
$db_server = "localhost";
$backup_path = "C:\\xampp\\htdocs\\openreal\\admin\\backup\\";
$path_to_mysqldump = "C:\\xampp\\mysql\\bin\\";
$filename = "backup".date("YmdHis").".sql";
shell_exec ("mysqldump $db_database > $path_to_mysqldump.$filename --user=$db_user --password=$db_password");
I have tried various forms of this syntax with no content output?
have you tried you dump command via command line to see if it works? Start with that
echo your full line to try it
$dumpcmd = 'mysqldump $db_database > $path_to_mysqldump.$filename --user=$db_user --password=$db_password';
then paste it via the command line and see what it does
Good clue -
did some testing on the cmd window and got it all working : ie, this command writes a db dump to the file in temp -
C:\xampp\mysql\bin\mysqldump.exe --databases or --user=root --ignore-table=or.oporeal_controlpanel > C:\temp\.mychat.sql ; system
but in php it writes the file ok but it is empty (0 bytes)
This is my php version of the same command -
$dump_cmd=("$path_to_mysqldump.mysqldump.exe --databases or --user=root --ignore-table=or.oporeal_controlpanel > $backup_path.$filename ");
OK - problem solved -
Seems the "$path_to_mysqldump" has to be in there too.
This code works fine now on my local machine :
$fish= "$path_to_mysqldump\\mysqldump.exe --u $db_user --ignore-table=$db.$config $db > $filename ";
You would need --p=$passwd after User (if it was set)
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved