kocor / tp5-databackup
THINKPHP5
Installs: 15
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 1
Open Issues: 0
Type:project
This package is not auto-updated.
Last update: 2024-05-20 16:34:56 UTC
README
THINKPHP5 数据库备份还原
初始化
$this->config = [ 'path' => RUNTIME_PATH.'/Backup/',//数据库备份路径 'part' => 20971520,//20M 数据库备份卷大小 'compress' => 1,//数据库备份文件是否启用压缩 0不压缩 1 压缩 'level' => 9 //数据库备份文件压缩级别 1普通 4 一般 9最高 ];
数据库表列表
$backup = new BackupModel($this->config); $tableList = $backup->dataList();
备份
$backup = new BackupModel($this->config); foreach ($tableList as $key => $value) { $start= $backup->backup($value, 0); if($start !== 0){ bleak; } }
还原
$backup = new BackupModel($this->config); $file = ['name' => date('Ymd-His',$time), 'part' => ($part)]; $backup->setFile($file)->import($compress);
删除
$time = Request::instance()->param('time/s'); $backup = new BackupModel($this->config); $tableList = $backup->delFile($time);
下载
$backup = new BackupModel($this->config); $tableList = $backup->downloadFile($time,$part);