Files
UNIT3D-Community-Edition/app/Jobs/ProcessBackup.php
HDVinnie 3650900c97 update: lint
- not_operator_with_space to false
2023-02-03 16:01:29 -05:00

55 lines
1.4 KiB
PHP

<?php
/**
* NOTICE OF LICENSE.
*
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D Community Edition
*
* @author HDVinnie <hdinnovations@protonmail.com>
* @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\Tasks\Backup\BackupJobFactory;
class ProcessBackup implements ShouldQueue
{
use Dispatchable;
use InteractsWithQueue;
use Queueable;
public int $timeout = 0;
public function __construct(protected $option = '')
{
}
public function handle(): void
{
$backupJob = BackupJobFactory::createFromArray(config('backup'));
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();
}
}