增加数据库备份

This commit is contained in:
win10 committed 2020-09-10 16:10:42 +08:00
1 parent 320bab1fa3
commit b1d3c5a88e
14 files changed
+94 -61447

No files matched your search

+44 -17
View File
@@ -21,42 +21,55 @@ class BackUp extends AdminBase
public function index()
{
$db= new up($this->upcnf);
// 设置要给模板赋值的信息
$list['webtitle'] = '文件列表';
$list['dataurl'] = 'file/data';
$fileList = $db->fileList();
foreach ($fileList as $key => $value) {
$fileList[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
}
$list['data'] = $fileList;
halt($list['data']);
$list['dataurl'] = '/system/backup/data';
// 模板赋值
$this->view->assign('list', $list);
// 渲染模板
return $this->view->fetch();
}
// 获取单位列表数据
public function ajaxData()
{
// 获取参数
$src = $this->request
->only([
'page' => '1'
,'limit' => '10'
,'field' => 'time'
,'order' => 'desc'
],'POST');
$db= new up($this->upcnf);
$data = $db->fileList();
foreach ($data as $key => $value) {
$data[$key]['ltime'] = date('Y-m-d H:i:s', $value['time']);
$data[$key]['lsize'] = round($value['size'] / 1024 / 1024, 2) . 'Mb';
}
$data = reSetArray($data, $src);
return json($data);
}
// 数据库备份
public function create()
{
$db= new up($this->upcnf);
$aa = $db->dataList();
$start = 0;
// $rand = mt_rand(1000, 9999);
// $file = time() . $rand;
// $file = (string)$file;
// $file = array_column($aa, 'name');
foreach ($aa as $key => $value) {
foreach ($aa as $key => $value) {
$start1= $db->setFile()->backup($value['name'], $start);
}
$bb = $db->fileList();
// 根据更新结果设置返回提示信息
$data = ['msg' => '创建成功', 'val' => 1];
// 返回信息
return json($data);
}
@@ -67,4 +80,18 @@ class BackUp extends AdminBase
}
// 删除备份
public function delete($time)
{
$db= new up($this->upcnf);
$data = $db->delFile($time);
// 根据更新结果设置返回提示信息
$data ? $data = ['msg' => '删除成功', 'val' => 1]
: $data = ['msg' => '数据处理错误', 'val' => 0];
// 返回信息
return json($data);
}
}
+1 -3
View File
@@ -28,7 +28,7 @@ class Fields extends AdminBase
}
// 获取单位列表数据
// 获取文件列表数据
public function ajaxData()
{
// 获取参数
@@ -47,10 +47,8 @@ class Fields extends AdminBase
->visible([
'id'
,'flCategory'=>['title']
// ,'flTeacher'=>['xingming']
,'oldname'
,'fieldsize'
// ,'flTeacher'=>['xingming']
,'bianjitime'
,'update_time'
,'userInfo'
+3 -1
View File
@@ -53,7 +53,9 @@ Route::group('category', function () {
// 类别管理
Route::group('backup', function () {
Route::rule('index', 'BackUp/index', 'get'); # 获取数据
Route::rule('create', 'BackUp/create', 'get'); # 获取数据
Route::rule('create', 'BackUp/create', 'post'); # 获取数据
Route::rule('data', 'BackUp/ajaxData', 'post'); # 获取数据
Route::rule('delete/<time>', 'BackUp/delete', 'post'); # 获取数据
});
Loaded 3 of 14 files, more files were not shown because too many files have changed in this diff. Show more