In my Codeigniter Controller I have the following code that zip the backup file from database. The problem is that when I extract the zip file, instead of single file inside, there are other folder from the path inside of it.
$this->load->dbutil();
$this->load->helper('date');
$this->load->helper('file');
set_time_limit(0);
$prefs = array(
'format' => 'txt', // gzip, zip, txt
'filename' => 'backup.sql', // File name - NEEDED ONLY WITH ZIP FILES
'add_drop' => TRUE, // Whether to add DROP TABLE statements to backup file
'add_insert' => TRUE, // Whether to add INSERT data to backup file
'newline' => "
" // Newline character used in backup file
);
$backup = $this->dbutil->backup($prefs);
$file = FCPATH.'GB_dump_backup/backup.txt';
$zip = FCPATH.'GB_dump_backup/'.now().'backup';
write_file($file, $backup);
system('zip -P pass '.$zip.' '.$file .' ');
I'm not sure why the zip creates path folder inside the zip too. I mean instead of just archiving the backup.txt , it backup from the Application folder till to backup.txt file. After extracting the zip file I get below picture :