An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
Add coolify database and handle exceptions
Andras Bacsai5e36c37838ae
diff --git a/app/Livewire/Settings/Backup.php b/app/Livewire/Settings/Backup.phpindex 67a4577741..121b73af85 100644--- a/app/Livewire/Settings/Backup.php+++ b/app/Livewire/Settings/Backup.php@@ -41,35 +41,39 @@ class Backup extends Component}public function add_coolify_database(){- $server = Server::find(0);- $out = instant_remote_process(['docker inspect coolify-db'], $server);- $envs = format_docker_envs_to_json($out);- $postgres_password = $envs['POSTGRES_PASSWORD'];- $postgres_user = $envs['POSTGRES_USER'];- $postgres_db = $envs['POSTGRES_DB'];- $this->database = StandalonePostgresql::create([- 'id' => 0,- 'name' => 'coolify-db',- 'description' => 'Coolify database',- 'postgres_user' => $postgres_user,- 'postgres_password' => $postgres_password,- 'postgres_db' => $postgres_db,- 'status' => 'running',- 'destination_type' => 'App\Models\StandaloneDocker',- 'destination_id' => 0,- ]);- $this->backup = ScheduledDatabaseBackup::create([- 'id' => 0,- 'enabled' => true,- 'save_s3' => false,- 'frequency' => '0 0 * * *',- 'database_id' => $this->database->id,- 'database_type' => 'App\Models\StandalonePostgresql',- 'team_id' => currentTeam()->id,- ]);- $this->database->refresh();- $this->backup->refresh();- $this->s3s = S3Storage::whereTeamId(0)->get();+ try {+ $server = Server::findOrFail(0);+ $out = instant_remote_process(['docker inspect coolify-db'], $server);+ $envs = format_docker_envs_to_json($out);+ $postgres_password = $envs['POSTGRES_PASSWORD'];+ $postgres_user = $envs['POSTGRES_USER'];+ $postgres_db = $envs['POSTGRES_DB'];+ $this->database = StandalonePostgresql::create([+ 'id' => 0,+ 'name' => 'coolify-db',+ 'description' => 'Coolify database',+ 'postgres_user' => $postgres_user,+ 'postgres_password' => $postgres_password,+ 'postgres_db' => $postgres_db,+ 'status' => 'running',+ 'destination_type' => 'App\Models\StandaloneDocker',+ 'destination_id' => 0,+ ]);+ $this->backup = ScheduledDatabaseBackup::create([+ 'id' => 0,+ 'enabled' => true,+ 'save_s3' => false,+ 'frequency' => '0 0 * * *',+ 'database_id' => $this->database->id,+ 'database_type' => 'App\Models\StandalonePostgresql',+ 'team_id' => currentTeam()->id,+ ]);+ $this->database->refresh();+ $this->backup->refresh();+ $this->s3s = S3Storage::whereTeamId(0)->get();+ } catch (\Exception $e) {+ return handleError($e, $this);+ }}public function backup_now()