Files
UNIT3D-Community-Edition/app/Jobs/ProcessBackup.php
HDVinnie ea4c9300eb refactor: property promotions
- convert classes with simple constructors to use property promotion available in PHP 8.
2021-07-12 20:54:00 -04: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 $timeout = 0;
public function __construct(protected $option = '')
{
}
public function handle()
{
$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();
}
}