后台恢复数据时无法正常执行完成,检查备份sql文件有异常代码的解决办法

admin 发布于 BUG提交 2021-12-02 16:47:10

在做数据库备份操作时,备份生成的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;
}

二、完毕!

最后编辑于 2023-01-08 00:16:31
0 697
Re :

admin 这家伙什么都没留下

  • 回答

    97
  • 发布

    86
  • 经验

    6430

内容精选

联系我们

  • 微信官网

    关注公众号

    系统更新,推送提醒
  • 开发交流群

    技术交流Q群

    安装使用,开发交流

垂询热线:18978189162