| 549 | | |
| 550 | | $output_file = sprintf($DB_NAME."_%s.db", date("Ymd-hi")); |
| 551 | | $DB_EXPORT_PATH =''; |
| 552 | | system("pg_dump -u ".$DB_NAME." < ".AUTH_USER_FILE_PATH." > ".DB_EXPORT_PATH.$output_file); |
| | 550 | $DB_NAME = (string) 'DBKARAMELO'; |
| | 551 | $DB_USER = (string) 'postgres'; |
| | 552 | $output_file = sprintf($DB_NAME."_%s.sql", date("Ymd-hi")); |
| | 553 | $DB_EXPORT_PATH ='/tmp'; |
| | 554 | $command = (string) "pg_dump ".$DB_NAME." -O -U ".$DB_USER." -f ".$DB_EXPORT_PATH.'/'.$output_file; |
| | 555 | //die($command); |
| | 556 | exec($command); |
| | 557 | $karamelo_path = (string) '/var/chipotle/sites/karamelo/sugus/webroot'; |
| | 558 | $tar_file = sprintf('KARAMELO_'."_%s.tar", date("Ymd-hi")); |
| | 559 | $command = (string) 'tar -rvf '. $DB_EXPORT_PATH .'/'. $tar_file .' '.$karamelo_path; |
| | 560 | exec($command); |
| | 561 | |
| | 562 | $command = (string) 'tar -rvf '. $DB_EXPORT_PATH .'/'. $tar_file . ' '. $DB_EXPORT_PATH.'/'.$output_file; |
| | 563 | exec($command); |
| | 564 | $tgz_file = $tar_file.'.gz'; |
| | 565 | $command = (string) 'tar -czvf '.$DB_EXPORT_PATH .'/'.$tgz_file.' '.$DB_EXPORT_PATH.'/'.$tar_file; |
| | 566 | exec($command); |
| | 567 | unlink($DB_EXPORT_PATH.'/'.$output_file); |
| | 568 | unlink($DB_EXPORT_PATH.'/'.$tar_file); |
| | 569 | //die($tgz_file); |
| 555 | | header("Content-disposition: attachment; filename=".$output_file); |
| 556 | | header("Content-type: application/octet-stream; name=".$output_file); |
| 557 | | $result = file_get_contents(DB_EXPORT_PATH.$output_file); |
| 558 | | print($result); |
| | 572 | header('Content-type: application/x-compressed'); |
| | 573 | header("Content-disposition: attachment; filename=".$tgz_file); |
| | 574 | header("Content-type: force-download; name=".$tgz_file); |
| | 575 | header("Content-Transfer-Encoding: binary"); |
| | 576 | header("Cache-Control: no-cache, must-revalidate"); |
| | 577 | header("Pragma: no-cache"); |
| | 578 | |
| | 579 | readfile($DB_EXPORT_PATH .'/'.$tgz_file); |
| | 580 | //$file=fopen($DB_EXPORT_PATH .'/'.$tgz_file,ârâ); |
| | 581 | //fpassthru($file); |
| | 582 | //fclose($file); |
| | 583 | |
| | 584 | //delete temporary files |
| | 585 | //unlink($DB_EXPORT_PATH.'/'.$tgz_file); |
| | 586 | |