refactor: Update StandalonePostgresql database initialization and backup handling
This commit is contained in:
@@ -16,7 +16,7 @@ class SettingsBackup extends Component
|
|||||||
|
|
||||||
public $s3s;
|
public $s3s;
|
||||||
|
|
||||||
public StandalonePostgresql|null|array $database = [];
|
public ?StandalonePostgresql $database = null;
|
||||||
|
|
||||||
public ScheduledDatabaseBackup|null|array $backup = [];
|
public ScheduledDatabaseBackup|null|array $backup = [];
|
||||||
|
|
||||||
@@ -43,26 +43,19 @@ class SettingsBackup extends Component
|
|||||||
{
|
{
|
||||||
if (isInstanceAdmin()) {
|
if (isInstanceAdmin()) {
|
||||||
$settings = InstanceSettings::get();
|
$settings = InstanceSettings::get();
|
||||||
$database = StandalonePostgresql::whereName('coolify-db')->first();
|
$this->database = StandalonePostgresql::whereName('coolify-db')->first();
|
||||||
$s3s = S3Storage::whereTeamId(0)->get() ?? [];
|
$s3s = S3Storage::whereTeamId(0)->get() ?? [];
|
||||||
if ($database) {
|
if ($this->database) {
|
||||||
if ($database->status !== 'running') {
|
if ($this->database->status !== 'running') {
|
||||||
$database->status = 'running';
|
$this->database->status = 'running';
|
||||||
$database->save();
|
$this->database->save();
|
||||||
}
|
}
|
||||||
$this->database = $database;
|
$this->backup = $this->database->scheduledBackups->first();
|
||||||
|
$this->executions = $this->backup->executions;
|
||||||
}
|
}
|
||||||
$this->settings = $settings;
|
$this->settings = $settings;
|
||||||
$this->s3s = $s3s;
|
$this->s3s = $s3s;
|
||||||
|
|
||||||
$scheduledBackups = data_get($this->database, 'scheduledBackups');
|
|
||||||
if ($scheduledBackups) {
|
|
||||||
$this->backup = $scheduledBackups->first();
|
|
||||||
}
|
|
||||||
$executions = data_get($this->backup, 'executions');
|
|
||||||
if ($executions) {
|
|
||||||
$this->executions = $executions;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return redirect()->route('dashboard');
|
return redirect()->route('dashboard');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="pb-4">Backup configuration for Coolify instance.</div>
|
<div class="pb-4">Backup configuration for Coolify instance.</div>
|
||||||
<div>
|
<div>
|
||||||
@if (isset($database))
|
@if (isset($database) && isset($backup))
|
||||||
<div class="flex flex-col gap-3 pb-4">
|
<div class="flex flex-col gap-3 pb-4">
|
||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
<x-forms.input label="UUID" readonly id="database.uuid" />
|
<x-forms.input label="UUID" readonly id="database.uuid" />
|
||||||
@@ -27,14 +27,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<livewire:project.database.backup-edit :backup="$backup" :s3s="$s3s" :status="data_get($database, 'status')" />
|
<livewire:project.database.backup-edit :backup="$backup" :s3s="$s3s" :status="data_get($database, 'status')" />
|
||||||
|
<div class="py-4">
|
||||||
|
<livewire:project.database.backup-executions :backup="$backup" />
|
||||||
|
</div>
|
||||||
@else
|
@else
|
||||||
To configure automatic backup for your Coolify instance, you first need to add a database resource
|
To configure automatic backup for your Coolify instance, you first need to add a database resource
|
||||||
into Coolify.
|
into Coolify.
|
||||||
<x-forms.button class="mt-2" wire:click="add_coolify_database">Add Database</x-forms.button>
|
<x-forms.button class="mt-2" wire:click="add_coolify_database">Add Database</x-forms.button>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
<div class="py-4">
|
|
||||||
<livewire:project.database.backup-executions :backup="$backup" />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user