backup command cleanup

This commit is contained in:
Saeed Vaziry
2024-03-14 22:27:13 +01:00
parent f907bacdd0
commit 4f12de9586
2 changed files with 28 additions and 49 deletions

View 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);
}
});
}
}