tags:

views:

302

answers:

2

I found a cool MySQL backup script. It's working fine on some hosting companies. Now I'm trying it on a different host running PHP Version 5.2.8.

I have a php.ini file that contains this (in both root dir and current dir):

disable_functions =.

I'm getting these warnings, and it seems like they are more than warnings. If the exec() doesn't run, the MySQL is not backed-up.

<b>Notice</b>:  Undefined variable: output in <b>/home/nealsent/public_html/backups/backup_dbs.php</b> on line <b>21.  

</b><br />
    <br />
    <b>Notice</b>:  Undefined variable: res in <b>/home/nealsent/public_html/backups/backup_dbs.php</b> on line <b>210</b><br />
    <br />
    <b>Warning</b>:  exec() has been disabled for security reasons in <b>/home/nealsent/public_html/backups/backup_dbs.php</b> on line <b>210</b><br />
    <br />

The code is (line 210 is the exec).

// dump db
unset( $output );
exec( "$MYSQL_PATH/mysqldump $db_auth --opt $db 2>&1 >$BACKUP_TEMP/$db.sql", $output, $res);

Thanks,

Neal Walters

+1  A: 

Many hosts disable certain functions, and do not allow overriding them in custom php.ini's (just because PHP offers the ability to have a custom php.ini, does not mean that all PHP setups are necessarily configured to allow you to change that option via such).

Chances are that host simply doesn't allow exec() period. Not much you can really do about that.

Amber
A: 

Another possibility is that exec has been disable by PHP safe mode. From the referenced page, it looks like you could avoid this by putting the script you are exec-ing into the PHP "safe mode exec dir".

Stephen C