Page 1 of 1

Please help on this MySQL backup script...

Posted: Sat Feb 26, 2005 11:32 am
by compuXP
Hi,

I would like to know why this doesn't work:

Code: Select all

<?PHP
/* Function to backup a mysql database table
* @param host
*     The database host name (server)
* @param user
*     Database user
* @param password
*     Database password
* @param table
*     Database table name
* @param backup_path
*     The path to backup directory
* @param backup_name
*     The name of the backup file - no extension
*/


function mysql_backup($host, $user, $password, $table, $backup_path, $backup_name) &#123;
 $day = date('w');
 # gzip (.gz)
 $backup = $backup_path.$backup_name.'_'.$day.'.gz';
 exec(sprintf('mysqldump --host=%s --user=%s --password=%s %s --quick --lock-tables --add-drop-table | gzip > %s', $host, $user, $password, $table, $backup));
 # sql (.sql)
 //$backup = $backup_path.$backup_name.'_'.$day.'.sql';
 //exec(sprintf('mysqldump --host=%s --user=%s --password=%s %s --quick --lock-tables --add-drop-table > %s', $host, $user, $password, $table, $backup));
&#125;
mysql_backup('localhost', 'username', 'password', 'members', '/home/*******/public_html/path/backups/', 'members_bckp');
//exec("/home/********/public_html/path/backups/mysql_backup_grabber.php");
?>
How come this won't backup the table? It does not give me any errors but does not copy the table "membes". Also, how can I get it to do the whole database as a compressed file?

Thanks,

-compuXP

Posted: Sat Feb 26, 2005 11:43 am
by feyd
are you sure you have permission to call exec() ?

Posted: Sat Feb 26, 2005 12:23 pm
by compuXP
oh... I'm not sure... actually :?

I need permission? I set the folder CHMOD's to 777...

Posted: Thu Mar 03, 2005 5:46 pm
by compuXP
i still need some help :( How do I know if I have permission to call the function?

Posted: Fri Mar 04, 2005 3:23 pm
by thegreatone2176
if you did have perms it would say

exec() : permission denied in /folder/script.php

b/c ive tryed to use chmod before and it told me that so im sure it would do the same ehre

Posted: Sat Mar 05, 2005 6:22 pm
by compuXP
so now what? How can I get it to work? :(

Posted: Sat Mar 05, 2005 8:10 pm
by timvw
as usual, debugging 101:

ini_set('error_reporting', E_ALL);
ini_set('display_errors', TRUE);

then probably you will have to find out the complete path for mysqlump and change that in your code...

and the same will go for gzip too....

Posted: Sun Mar 06, 2005 3:23 pm
by compuXP
hm thanks, I'll try that and get back to you.