mirror of
https://github.com/coollabsio/coolify.git
synced 2026-10-06 05:58:14 -04:00
# Conflicts: # app/Actions/Database/StartDatabase.php # app/Models/StandaloneClickhouse.php # app/Models/StandaloneDragonfly.php # app/Models/StandaloneKeydb.php # app/Models/StandaloneMariadb.php # app/Models/StandaloneMongodb.php # app/Models/StandaloneMysql.php # app/Models/StandalonePostgresql.php # app/Models/StandaloneRedis.php # resources/views/livewire/project/shared/storages/all.blade.php # tests/Feature/PersistentStorageVolumesLayoutTest.php # tests/Feature/UserSeederTest.php
41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Project\Database;
|
|
|
|
use App\Jobs\DatabaseBackupJob;
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
|
use Livewire\Component;
|
|
|
|
class BackupNow extends Component
|
|
{
|
|
use AuthorizesRequests;
|
|
|
|
public $backup;
|
|
|
|
public function backupNow()
|
|
{
|
|
try {
|
|
$this->authorize('manageBackups', $this->backup->database);
|
|
|
|
$database = $this->backup->database->refresh();
|
|
if ($database->id !== 0 && ! str($database->status)->startsWith('running')) {
|
|
$this->dispatch('error', 'The database must be running to start a backup.');
|
|
|
|
return;
|
|
}
|
|
|
|
DatabaseBackupJob::dispatch($this->backup);
|
|
$database = $this->backup->database;
|
|
auditLog('ui.database.backup_started', [
|
|
'team_id' => $database->team()?->id,
|
|
'database_uuid' => $database->uuid,
|
|
'database_name' => $database->name,
|
|
'backup_uuid' => $this->backup->uuid,
|
|
]);
|
|
$this->dispatch('success', 'Backup queued. It will be available in a few minutes.');
|
|
} catch (\Throwable $e) {
|
|
return handleError($e, $this);
|
|
}
|
|
}
|
|
}
|