Forum Moderators: coopster

Message Too Old, No Replies

Restore MySQL database backup file through PHP?

         

dbzfyam

9:54 pm on Sep 15, 2007 (gmt 0)

10+ Year Member



I wrote a PHP script to backup my complete database and send it through email. When I import the file through PHPMyAdmin, everything works. However, when I try to restore the database through PHP (I found similar code on several sites), it doesn't do anything:


$restore = "mysqlimport -u $dbuser -p $dbpass $dbname $location";
$importFile = system($restore, $return);

This is what $restore contains: mysqlimport -u user12345 -p pass12345 database12345 tempdata/backuprestore/mp_database_15-09-2007.sql

I also tried shell_exec instead of system aswell, but this didn't work either. Does anyone know how I can do this with PHP? I need this for my admin panel.

Thanks in advance
Stefan

PS: mysqlimport is used to import data into a already existing database, right? Since that's what I need.

eelixduppy

2:46 pm on Sep 18, 2007 (gmt 0)




mysqlimport -u user12345 -p pass12345 database12345 tempdata/backuprestore/mp_database_15-09-2007.sql

Run that manually through the command line and see what you get. My guess if you have a minor error somewhere. Also, make sure that safe_mode [us2.php.net] isn't turned on; this might interfere with what you are trying to do.

dbzfyam

5:34 pm on Sep 21, 2007 (gmt 0)

10+ Year Member



Thanks for the reply, eelixduppy. The server I tried that code on does indeed have safe mode enabled. I tried the same code on my own server (safe mode disabled) and it works perfectly. I just found a script which is able to import my sql files ("manually", not through exec)

EDIT: For those looking for something like this: search on Google for BigDump