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

54 lines
1.1 KiB
PHP
Raw Normal View History

2021-05-15 01:24:44 +08:00
<?php
namespace App\Console\Commands;
use App\Repositories\ToolRepository;
use Illuminate\Console\Command;
class BackupCronjob extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
2022-04-04 17:26:26 +08:00
protected $signature = 'backup:cronjob {--force=}';
2021-05-15 01:24:44 +08:00
/**
* The console command description.
*
* @var string
*/
2022-04-04 17:26:26 +08:00
protected $description = 'Backup all data cronjob, and upload to Google drive. options: --force';
2021-05-15 01:24:44 +08:00
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle(): int
{
2022-04-04 17:26:26 +08:00
$force = $this->option('force');
$this->info("force: $force");
2021-05-15 01:24:44 +08:00
$rep = new ToolRepository();
2022-04-04 17:26:26 +08:00
$result = $rep->cronjobBackup($force);
2021-05-15 01:24:44 +08:00
$log = sprintf(
'[%s], %s, result: %s',
2022-04-04 17:26:26 +08:00
nexus()->getRequestId(), __METHOD__, var_export($result, true)
2021-05-15 01:24:44 +08:00
);
$this->info($log);
do_log($log);
return 0;
}
}