In php-script through shell_exec I start creating a database table dump.

$cmd = "mysqldump -u{$selfDbConnectArray['dbuser']} -p{$selfDbConnectArray['dbPassword']} {$selfDbConnectArray['dbName']} $table | gzip > `date +{$rootDir}_service/dbbackups/$folder/$table.%Y-%m-%d.%H-%M-%S.sql.gz`"; shell_exec($cmd); 

I run a php script through the console, everything works fine. I run the script through the browser - mysqldump creates an empty file, and if you use gzip compression, then the file size is 20B

Why? Why can't I run backup through the browser? how to do it?

  • Is there any error in the server logs? - plesser
  • Try to specify the full path to mysqldump (look at it with the command which mysqldump ). Most likely, under the web server in the PATH environment variable the path to the folder where mysql is located is not specified. - cronfy
  • Use the analogue of this function exec (). She will show you the error and execute the command. And it would not be bad to check the logs. - LevBazdyrev
  • one
    $ cmd = "cmd.exe / c mysqldump -u {$ sel ..... sql.gz`"; - Akina

0