Welcome Guest, Not a member yet? Register   Sign In
backing up the database
#1

[eluser]brian88[/eluser]
I got this example from the CI userguide http://ellislab.com/codeigniter/user-gui...ities.html

Doing it how they do. but when i open up my sql file is has a bunch of gibberish inside it. like this...
_˝ªø˘˘ßøˇÂfl˝√_ˇÚ˛ÓÁü˛√˛....

controller
Code:
function backupdb(){
  // name the file
  $time = date('n-j-Y', time());
  $filename = 'backup-'.$time.'.sql';

  // and place it in the right folder
  $path = FCPATH.'db/';
              
  // Load the DB utility class and backup db
  $this->load->dbutil();
  $backup =& $this->dbutil->backup();
  
  // load file helper and save the file on the server
  $this->load->helper('file');
  if(!write_file($path.$filename, $backup)){
   echo 'didnt work';
  }else{
   echo 'You backed up the DB. Good job mate!';
  };
}
#2

[eluser]brian88[/eluser]
anyone?
#3

[eluser]xerobytez[/eluser]
By default the backup is gzip encoded. You need to change the format to txt. Look towards the bottom of the database utility page listed above for more info.




Theme © iAndrew 2016 - Forum software by © MyBB