diff --git a/app/Actions/Server/UpdateCoolify.php b/app/Actions/Server/UpdateCoolify.php index 3e5f2b19a8..0ee8424ce1 100644 --- a/app/Actions/Server/UpdateCoolify.php +++ b/app/Actions/Server/UpdateCoolify.php @@ -135,7 +135,7 @@ class UpdateCoolify private function backupDatabase(): void { $backup = StandalonePostgresql::find(0)?->scheduledBackups()->first(); - if (! $backup || ! instanceSettings()->is_backup_before_update_enabled) { + if (! $backup?->enabled || ! instanceSettings()->is_backup_before_update_enabled) { return; } @@ -144,7 +144,8 @@ class UpdateCoolify $job = new DatabaseBackupJob($backup); $job->handle(); if ($job->backup_log?->status !== 'success') { - throw new \Exception('The database backup failed, so the update was not started.'); + $reason = $job->backup_log?->message; + throw new \Exception('The database backup failed, so the update was not started.'.($reason ? " Error: {$reason}" : '').' You can turn off "Backup before update" in Settings > Backup to update without a backup.'); } } diff --git a/app/Jobs/DatabaseBackupJob.php b/app/Jobs/DatabaseBackupJob.php index b72a1ee8d4..8e50b32571 100644 --- a/app/Jobs/DatabaseBackupJob.php +++ b/app/Jobs/DatabaseBackupJob.php @@ -140,7 +140,10 @@ class DatabaseBackupJob implements ShouldBeEncrypted, ShouldQueue $this->server = $this->database->service->server; } else { $this->database = data_get($this->backup, 'database'); - $this->server = $this->database->destination->server; + // The coolify-db container always runs on the Coolify host, whatever its destination row says. + $this->server = $this->database instanceof StandalonePostgresql && $this->database->isInstanceDatabase() + ? Server::find(0) + : $this->database->destination->server; } if (is_null($this->server)) { throw new \Exception('Server not found?!'); diff --git a/resources/views/livewire/settings-backup.blade.php b/resources/views/livewire/settings-backup.blade.php index 93c2269d65..ea4fd146c4 100644 --- a/resources/views/livewire/settings-backup.blade.php +++ b/resources/views/livewire/settings-backup.blade.php @@ -34,7 +34,7 @@ ['value' => true, 'label' => 'Enabled'], ['value' => false, 'label' => 'Disabled'], ]" - helper="Runs this backup once before every manual or automatic update, in addition to the schedule." /> + helper="Runs this backup once before every manual or automatic update, in addition to the schedule. It does not run when the backup schedule is disabled." />