Taking PostgreSQL backup through PHP on Windows server 2008 R2 -


i trying backup of database through php.i using yii postgresql. have tried below code , working on local wamp server. below code not working on server windows server 2008 r2. if echo result of join(' ', $dumpcmd) , copy command prompt, works.

public function actionbackup()         {             $path       = yii::app()->basepath . '/data/backup/';             $file=$path."data.backup";             unlink($file);              putenv("pgpassword=postgres");             $dumpcmd = array("pg_dump", "-i", "-u", escapeshellarg("postgres"), "-f", "c", "-b", "-v", "-f", escapeshellarg($file), escapeshellarg("mydb"));             exec( join(' ', $dumpcmd), $cmdout, $cmdresult );             putenv("pgpassword");             if ($cmdresult != 0)             {                 # handle error here...                 echo "error: couldn't backup data.";                 print_r($dumpcmd).'<br>';                 print_r($cmdout).'<br>';                 print_r($cmdresult).'<br>';             }              else {                   $this->renderpartial('download_backup',array('file'=>$file));              }         } 

print_r of variables below

array ( [0] => pg_dump [1] => -i [2] => -u [3] => "postgres" [4] => -f [5] => c [6] => -b [7] => -v [8] => -f [9] => "path_to/data/backup/data.backup" [10] => "mydb" ) array ( ) 1 


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -