mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 13:10:37 -04:00
fix(backups): back up the instance database on localhost and show why the pre-update backup failed
The pre-update backup now skips a disabled schedule.
This commit is contained in:
@@ -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.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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?!');
|
||||
|
||||
Reference in New Issue
Block a user