Skip to content

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.

fix: restore falsely deleted coolify-db-backup

Andras Bacsaie4781dc129f0
diff --git a/app/Console/Commands/Init.php b/app/Console/Commands/Init.php
index ec4d75484b..72789435b4 100644
--- a/app/Console/Commands/Init.php
+++ b/app/Console/Commands/Init.php
@@ -7,6 +7,7 @@ use App\Jobs\CleanupHelperContainersJob;
use App\Models\Application;
use App\Models\ApplicationDeploymentQueue;
use App\Models\InstanceSettings;
+use App\Models\ScheduledDatabaseBackup;
use App\Models\Server;
use App\Models\Service;
use App\Models\ServiceApplication;
@@ -31,6 +32,9 @@ class Init extends Command
if ($cleanup) {
echo "Running cleanup\n";
$this->cleanup_stucked_resources();
+ // Required for falsely deleted coolify db
+ $this->restore_coolify_db_backup();
+
// $this->cleanup_ssh();
}
$this->cleanup_in_progress_application_deployments();
@@ -51,6 +55,30 @@ class Init extends Command
}
}
}
+ private function restore_coolify_db_backup() {
+ try {
+ $database = StandalonePostgresql::withTrashed()->find(0);
+ if ($database) {
+ echo "Restoring coolify db backup\n";
+ $database->restore();
+ $scheduledBackup = ScheduledDatabaseBackup::find(0);
+ if (!$scheduledBackup) {
+ ScheduledDatabaseBackup::create([
+ 'id' => 0,
+ 'enabled' => true,
+ 'save_s3' => false,
+ 'frequency' => '0 0 * * *',
+ 'database_id' => $database->id,
+ 'database_type' => 'App\Models\StandalonePostgresql',
+ 'team_id' => 0,
+ ]);
+ }
+
+ }
+ } catch(\Throwable $e) {
+ echo "Error in restoring coolify db backup: {$e->getMessage()}\n";
+ }
+ }
private function cleanup_stucked_helper_containers()
{
$servers = Server::all();
@@ -134,7 +162,7 @@ class Init extends Command
echo "Error in application: {$e->getMessage()}\n";
}
try {
- $postgresqls = StandalonePostgresql::all();
+ $postgresqls = StandalonePostgresql::all()->where('id', '!=', 0);
foreach ($postgresqls as $postgresql) {
if (!data_get($postgresql, 'environment')) {
echo 'Postgresql without environment: ' . $postgresql->name . ' soft deleting\n';
diff --git a/config/sentry.php b/config/sentry.php
index 7385f166d5..ff9cafff04 100644
--- a/config/sentry.php
+++ b/config/sentry.php
@@ -7,7 +7,7 @@ return [
// The release version of your application
// Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD'))
- 'release' => '4.0.0-beta.173',
+ 'release' => '4.0.0-beta.174',
// When left empty or `null` the Laravel environment will be used
'environment' => config('app.env'),
diff --git a/config/version.php b/config/version.php
index 29b58ddbe1..24294cc835 100644
--- a/config/version.php
+++ b/config/version.php
@@ -1,3 +1,3 @@
<?php
-return '4.0.0-beta.173';
+return '4.0.0-beta.174';
diff --git a/versions.json b/versions.json
index d75ac6fa74..fe4045b164 100644
--- a/versions.json
+++ b/versions.json
@@ -4,7 +4,7 @@
"version": "3.12.36"
},
"v4": {
- "version": "4.0.0-beta.173"
+ "version": "4.0.0-beta.174"
}
}
}