mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-19 18:01:37 +00:00
backup command cleanup
This commit is contained in:
parent
f907bacdd0
commit
4f12de9586
@ -1,49 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
|
||||||
|
|
||||||
use App\Models\Backup;
|
|
||||||
use Illuminate\Console\Command;
|
|
||||||
|
|
||||||
class RunBackup extends Command
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* The name and signature of the console command.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $signature = 'backups:run {interval}';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'Run backup';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new command instance.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*/
|
|
||||||
public function handle(): void
|
|
||||||
{
|
|
||||||
Backup::query()
|
|
||||||
->where('interval', $this->argument('interval'))
|
|
||||||
->where('status', 'running')
|
|
||||||
->chunk(100, function ($backups) {
|
|
||||||
/** @var Backup $backup */
|
|
||||||
foreach ($backups as $backup) {
|
|
||||||
app(\App\Actions\Database\RunBackup::class)->run($backup);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
28
app/Console/Commands/RunBackupCommand.php
Normal file
28
app/Console/Commands/RunBackupCommand.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Actions\Database\RunBackup;
|
||||||
|
use App\Enums\BackupStatus;
|
||||||
|
use App\Models\Backup;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
class RunBackupCommand extends Command
|
||||||
|
{
|
||||||
|
protected $signature = 'backups:run {interval}';
|
||||||
|
|
||||||
|
protected $description = 'Run backup';
|
||||||
|
|
||||||
|
public function handle(): void
|
||||||
|
{
|
||||||
|
Backup::query()
|
||||||
|
->where('interval', $this->argument('interval'))
|
||||||
|
->where('status', BackupStatus::RUNNING)
|
||||||
|
->chunk(100, function ($backups) {
|
||||||
|
/** @var Backup $backup */
|
||||||
|
foreach ($backups as $backup) {
|
||||||
|
app(RunBackup::class)->run($backup);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user