You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.1 KiB

4 years ago
<?php
namespace app\admin\command;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Db;
use think\Log;
class RollBack extends Command
{
//定义任务名和描述
protected function configure(){
$this->setName('RollBack')->setDescription("php think backup 还原mysql数据库");
}
//调用该类时,会自动运行execute方法
protected function execute(Input $input, Output $output,$num = 1){
$config = [
// 服务器地址
'host' => "127.0.0.1",
// 数据库名
'database' => "hospital_web",
// 用户名
'user' => "root",
// 密码
'password' =>"123456",
// 端口
'port' => "3306",
// 字符编码
'charset' => "utf-8"
];
$dir = "./backup/sql";//备份路径
// 还原
$data = \cocolait\sql\Backup::instance($config)->recover('hospital_web15.sql',$dir);
print_r($data);die;
}
}