Changeset 748 for trunk

Show
Ignore:
Timestamp:
09/02/08 17:38:47 (3 months ago)
Author:
aarkerio
Message:

backups scripts

Location:
trunk/app/controllers
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/controllers/treasures_controller.php

    r747 r748  
    2727 * 
    2828 */ 
    29   
    3029 public function chksw() 
    3130 { 
     
    107106  $this->layout    = $this->Edublog->layout($data['Treasure']['user_id']); 
    108107       
    109   $this->pageTitle = 'Treasure Hunt'; 
     108  $this->pageTitle = __('Scavengers hunts', true); 
    110109       
    111110  $this->Edublog->blog($data['Treasure']['user_id']); // blogger elements 
  • trunk/app/controllers/users_controller.php

    r696 r748  
    540540    $this->set('data', $this->User->findAll($conditions));        
    541541 } 
     542 
    542543 /** 
    543544 * 
     
    547548 public function admin_backup()  
    548549 { 
    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); 
    553570   $this->autoRender = false; 
    554571   Configure::write('debug', 0); 
    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 
    559587   return true; 
    560588 }