Files
nexusphp/app/Console/Commands/BackupAll.php

53 lines
1.1 KiB
PHP
Raw Normal View History

2021-05-02 17:24:05 +08:00
<?php
namespace App\Console\Commands;
use App\Repositories\ToolRepository;
use Illuminate\Console\Command;
2022-07-18 15:13:03 +08:00
class BackupAll extends Command
2021-05-02 17:24:05 +08:00
{
/**
* The name and signature of the console command.
*
* @var string
*/
2022-05-14 15:19:10 +08:00
protected $signature = 'backup:all {--method=}';
2021-05-02 17:24:05 +08:00
/**
* The console command description.
*
* @var string
*/
2022-05-14 15:19:10 +08:00
protected $description = 'Backup all data, include web root and database. options: --method';
2021-05-02 17:24:05 +08:00
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
2022-05-14 15:19:10 +08:00
$method = $this->option('method');
$this->info("method: $method");
2021-05-02 17:24:05 +08:00
$rep = new ToolRepository();
2022-05-14 15:19:10 +08:00
$result = $rep->backupAll($method);
$log = sprintf(
2021-05-16 02:57:00 +08:00
'[%s], %s, result: %s',
2022-03-20 22:14:00 +08:00
nexus()->getRequestId(), __METHOD__, var_export($result, true)
);
2021-05-02 17:24:05 +08:00
$this->info($log);
do_log($log);
}
}