在做数据库备份操作时,备份生成的sql文件最末几行如果显示异常代码(即:非正常sql语句)会导致数据恢复时,无法正常执行,如果我们在恢复数据时,发现无法正常导入。可以检查以下文件代码,进行修复:
一、打开文件:backend/models/DbForm.php 258行
将代码:
public function downloadBackup($backup_name,$file)
{
$path = $this->getBackUpPath() . DIRECTORY_SEPARATOR . $backup_name . '/' . $file;
if(file_exists($path)){
header('Content-type: application/unknown'),
header('Content-Disposition: attachment; filename="'. $file. '"'),
header("Content-Length: " . filesize($path) ."; "),
readfile($path),
} else {
return false;
}
}
修改为:
public function downloadBackup($backup_name,$file)
{
$path = $this->getBackUpPath() . DIRECTORY_SEPARATOR . $backup_name . DIRECTORY_SEPARATOR . $file;
if(file_exists($path)){
header('Content-type: application/unknown'),
header('Content-Disposition: attachment; filename="'. $file. '"'),
header("Content-Length: " . filesize($path) ."; "),
readfile($path),
exit(0),
}
return false;
}
二、完毕!