* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0 */ namespace App\Jobs; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Spatie\Backup\Config\Config; use Spatie\Backup\Tasks\Backup\BackupJobFactory; class ProcessBackup implements ShouldQueue { use Dispatchable; use InteractsWithQueue; use Queueable; public int $timeout = 0; public function __construct(protected string $option = '') { } public function handle(): void { $config = Config::fromArray(config('backup')); $backupJob = BackupJobFactory::createFromConfig($config); if ($this->option === 'only-db') { $backupJob->dontBackupFilesystem(); } if ($this->option === 'only-files') { $backupJob->dontBackupDatabases(); } if (!empty($this->option)) { $prefix = str_replace('_', '-', $this->option).'-'; $backupJob->setFilename($prefix.date('Y-m-d-H-i-s').'.zip'); } $backupJob->run(); } }