tags:

views:

44

answers:

3

Hi, i've programmed a mysql backup system for my CMS which dumps all the DB data and structure into a gzipped .sql file:

$filename = DB_NAME.'_'.date('Y.m.d_H\hi_(s.'.round(microtime()*100,0).')').'.sql.gz';
exec('mysqldump --default-character-set=UTF8 --opt --compress --host='.DB_HOST.' --user='.DB_USER.' --password='.DB_PASS.' '.DB_NAME.' | gzip > '.DIR_BACKUP.$filename);

It works fine on my development server, but when i try to run the same code in my production server, the file is never created. Is this a permission issue? What should i configure for it to work? Thanks!

--- It seems the problem relies on the exec() function. Where can i allow permission for php to run that function?

A: 

Could be a permission issue, either you can't write to the filesystem, or more likely (certainly if your on a shared hosting service) the use of the exec command is not allowed. I believe you can check that with php_info();

Do you not get an error message? If not maybe enable displaying of error/warnings etc in php

Redlab
actually i own a VP server and have shell access. Where can i give php the proper permissions to run exec()?
andufo
I assume in php.ini. But if you run php in safe mode (also in php.ini) you could disable safe_mode and it should work also. If that is the cause of the problem of course. (safe_mode will be removed in PHP6 anyway) But before starting to mess in php ini perhaps take a look at http://www.php.net/manual/en/ini.php
Redlab
and http://www.php.net/manual/en/configuration.php
Redlab
A: 

Is the folder chmoded properly?

cypher
A: 

sounds like a permissions issue. Have you tried setting DIR_BACKUP to /tmp or similar?

Vidar Nordnes
It seems the problem relies on the exec() function. Where can i allow permission for php to run that function?
andufo
First you may check if the function is actually enabled by echoing ini_get('disable_functions') (returns a comma-separated list of disabled function). Then make sure your safe_mod is off, if it isn't, exec() may execute files only in safe_mode_exec_dir.
cypher
safe mode is off. and disable_functions is also empty. what else could it be?
andufo
Does it print out any errors / warnings? Try using error_reporting(E_ALL | E_STRICT)
cypher