Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14342

backup database problem

$
0
0
hi this is my controller :

Code:
public function backup_database(){

       $data=[];

       $oggi=date ("d-m-Y");

       // Load the DB utility class
       $this->load->dbutil();

       // Backup your entire database and assign it to a variable
       $backup = $this->dbutil->backup();

       $this->load->library('zip');

       // Load the file helper and write the file to your server
       $this->load->helper('file');

       if(write_file("backup_db/backup".$oggi.".txt", $backup)){
           $this->load->view('templates/header_admin');
           $this->load->view('templates/menu_admin');
           $this->load->view('admin/db_backup_ok', $data);
           $this->load->view('templates/footer_admin');


       }else{
          $this->load->view('templates/header_admin');
           $this->load->view('templates/menu_admin');
           $this->load->view('admin/db_backup_error', $data);
           $this->load->view('templates/footer_admin');

       }




   }

It work but the file made with this command have problem , if i set txt i have the document isn't a valid UTF-8 .
If i set zip , the archive cannot open ....

How can i solve ?

Viewing all articles
Browse latest Browse all 14342

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>