mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-04 10:42:23 +00: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:
1 parent
d09480973e
commit
860e786481
3 files changed
+8
-4
No files matched your search
@@ -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?!');
|
||||
|
||||
@@ -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." />
|
||||
</div>
|
||||
</x-application.settings-section>
|
||||
|
||||
|
||||
Reference in new issue
Block a user