I found that we can backup database by using Utility Class in command center has many security guard and regular users
security guard belongs to command center
regular user belongs to command center
.
But i'am unable to do backup of @RequestMapping(value="/buyerLandingReport/{LoginID}",method = RequestMethod.GET)
public ResponseEntity<Object> buyerLandingReport(@PathVariable("LoginID") String LoginID) {
try{
List<Rfx_BasicInfo> list1 = rfxBasicInfoRepository.findReportByLoginId(LoginID);
List<Rfx_SupplierInvite> list2 = rfxSupplierInviteRepository.findReportByUniqueId(list1.get(0).getUniqueid());
List<Rfx_Model> body = Arrays.asList(new Rfx_Model(list1, list2);
return new ResponseEntity(body), HttpStatus.OK);
}
catch (Exception ex){
throw ex;
}
}
.
My Question is:
How to backup MySql Database (Codeigniter
) by using MySql Stored Procedures
in including Stored procedures
.
Please help me. Thanks
答案 0 :(得分:0)
尝试这样,
创建的文件将保存在根文件夹中,并在创建后自动下载。
public function database_backup(){
$this->load->helper('file');
$this->load->helper('url');
$this->load->helper('download');
$this->load->library('zip');
$this->load->dbutil();
$db_format = [
'format' => 'zip',
'filename' => $this->db->database.'.sql'
];
$backup =& $this->dbutil->backup($db_format);
$db_name = 'database_backup.zip';
$save = FCPATH . $db_name;
// write the file to your server
write_file($save, $backup);
// download the file
force_download($db_name, $backup);
}
您可以在此处找到相关信息:https://www.codeigniter.com/user_guide/database/utilities.html?highlight=write_file
答案 1 :(得分:0)
我找到了一个解决方案:但是,它并不属于codeigniter数据库实用程序类
$file_name = 'blazonic_db_backup_' . date("d_m_Y_H_i_s") . '.zip';
header( "Content-Type: application/zip" );
header( 'Content-Disposition: attachment; filename="' . $file_name . '"' );
$cmd = "mysqldump -u $user --password=$pwd $db -R | gzip --best";
passthru( $cmd );
exit(0);
这里-R用于备份例程。