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.

improvement: show backup button on supported db service stacks

Andras Bacsaibb6cb8edc92c
diff --git a/app/Models/ServiceDatabase.php b/app/Models/ServiceDatabase.php
index 6b96738e81..518e3f9099 100644
--- a/app/Models/ServiceDatabase.php
+++ b/app/Models/ServiceDatabase.php
@@ -115,4 +115,12 @@ class ServiceDatabase extends BaseModel
{
return $this->morphMany(ScheduledDatabaseBackup::class, 'database');
}
+
+ public function isBackupSolutionAvailable()
+ {
+ return str($this->databaseType())->contains('mysql') ||
+ str($this->databaseType())->contains('postgres') ||
+ str($this->databaseType())->contains('mariadb') ||
+ str($this->databaseType())->contains('mongodb');
+ }
}
diff --git a/app/Models/StandaloneClickhouse.php b/app/Models/StandaloneClickhouse.php
index ee5c3becc4..e4341b1b9d 100644
--- a/app/Models/StandaloneClickhouse.php
+++ b/app/Models/StandaloneClickhouse.php
@@ -294,4 +294,9 @@ class StandaloneClickhouse extends BaseModel
return $parsedCollection->toArray();
}
}
+
+ public function isBackupSolutionAvailable()
+ {
+ return false;
+ }
}
diff --git a/app/Models/StandaloneDragonfly.php b/app/Models/StandaloneDragonfly.php
index 361abf1109..94ab2d7459 100644
--- a/app/Models/StandaloneDragonfly.php
+++ b/app/Models/StandaloneDragonfly.php
@@ -294,4 +294,9 @@ class StandaloneDragonfly extends BaseModel
return $parsedCollection->toArray();
}
}
+
+ public function isBackupSolutionAvailable()
+ {
+ return false;
+ }
}
diff --git a/app/Models/StandaloneKeydb.php b/app/Models/StandaloneKeydb.php
index e05879371a..335c8931c9 100644
--- a/app/Models/StandaloneKeydb.php
+++ b/app/Models/StandaloneKeydb.php
@@ -294,4 +294,9 @@ class StandaloneKeydb extends BaseModel
return $parsedCollection->toArray();
}
}
+
+ public function isBackupSolutionAvailable()
+ {
+ return false;
+ }
}
diff --git a/app/Models/StandaloneMariadb.php b/app/Models/StandaloneMariadb.php
index c1e6c85d73..c6c08dee5f 100644
--- a/app/Models/StandaloneMariadb.php
+++ b/app/Models/StandaloneMariadb.php
@@ -294,4 +294,9 @@ class StandaloneMariadb extends BaseModel
return $parsedCollection->toArray();
}
}
+
+ public function isBackupSolutionAvailable()
+ {
+ return true;
+ }
}
diff --git a/app/Models/StandaloneMongodb.php b/app/Models/StandaloneMongodb.php
index e5ed0a5f4a..99893b1d13 100644
--- a/app/Models/StandaloneMongodb.php
+++ b/app/Models/StandaloneMongodb.php
@@ -314,4 +314,9 @@ class StandaloneMongodb extends BaseModel
return $parsedCollection->toArray();
}
}
+
+ public function isBackupSolutionAvailable()
+ {
+ return true;
+ }
}
diff --git a/app/Models/StandaloneMysql.php b/app/Models/StandaloneMysql.php
index bd4a7abb7a..f2a5b5c14e 100644
--- a/app/Models/StandaloneMysql.php
+++ b/app/Models/StandaloneMysql.php
@@ -295,4 +295,9 @@ class StandaloneMysql extends BaseModel
return $parsedCollection->toArray();
}
}
+
+ public function isBackupSolutionAvailable()
+ {
+ return true;
+ }
}
diff --git a/app/Models/StandalonePostgresql.php b/app/Models/StandalonePostgresql.php
index db771c7cdf..1b18a5ca73 100644
--- a/app/Models/StandalonePostgresql.php
+++ b/app/Models/StandalonePostgresql.php
@@ -296,4 +296,9 @@ class StandalonePostgresql extends BaseModel
return $parsedCollection->toArray();
}
}
+
+ public function isBackupSolutionAvailable()
+ {
+ return true;
+ }
}
diff --git a/app/Models/StandaloneRedis.php b/app/Models/StandaloneRedis.php
index c524d4d03f..a5868e2438 100644
--- a/app/Models/StandaloneRedis.php
+++ b/app/Models/StandaloneRedis.php
@@ -290,4 +290,9 @@ class StandaloneRedis extends BaseModel
return $parsedCollection->toArray();
}
}
+
+ public function isBackupSolutionAvailable()
+ {
+ return false;
+ }
}
diff --git a/resources/views/livewire/project/service/configuration.blade.php b/resources/views/livewire/project/service/configuration.blade.php
index 55d8c6b395..d7d9d21d39 100644
--- a/resources/views/livewire/project/service/configuration.blade.php
+++ b/resources/views/livewire/project/service/configuration.blade.php
@@ -149,6 +149,12 @@
<div class="text-xs">{{ $database->status }}</div>
</div>
<div class="flex items-center px-4">
+ @if ($database->isBackupSolutionAvailable())
+ <a class="mx-4 text-xs font-bold hover:underline"
+ href="{{ route('project.service.index', [...$parameters, 'stack_service_uuid' => $database->uuid]) }}#backups">
+ Backups
+ </a>
+ @endif
<a class="mx-4 text-xs font-bold hover:underline"
href="{{ route('project.service.index', [...$parameters, 'stack_service_uuid' => $database->uuid]) }}">
Settings
diff --git a/resources/views/livewire/project/service/index.blade.php b/resources/views/livewire/project/service/index.blade.php
index ef148c88af..f8d5f8a437 100644
--- a/resources/views/livewire/project/service/index.blade.php
+++ b/resources/views/livewire/project/service/index.blade.php
@@ -10,9 +10,7 @@
<a class="menu-item" :class="activeTab === 'general' && 'menu-item-active'"
@click.prevent="activeTab = 'general'; window.location.hash = 'general'; if(window.location.search) window.location.search = ''"
href="#">General</a>
- @if (str($serviceDatabase?->databaseType())->contains('mysql') ||
- str($serviceDatabase?->databaseType())->contains('postgres') ||
- str($serviceDatabase?->databaseType())->contains('mariadb'))
+ @if ($serviceDatabase->isBackupSolutionAvailable())
<a :class="activeTab === 'backups' && 'menu-item-active'" class="menu-item"
@click.prevent="activeTab = 'backups'; window.location.hash = 'backups'" href="#">Backups</a>
@endif
@@ -28,22 +26,25 @@
</div>
@endisset
@isset($serviceDatabase)
- <x-slot:title>
- {{ data_get_str($service, 'name')->limit(10) }} > {{ data_get_str($serviceDatabase, 'name')->limit(10) }} | Coolify
- </x-slot>
+ <x-slot:title>
+ {{ data_get_str($service, 'name')->limit(10) }} >
+ {{ data_get_str($serviceDatabase, 'name')->limit(10) }} | Coolify
+ </x-slot>
<div x-cloak x-show="activeTab === 'general'" class="h-full">
<livewire:project.service.database :database="$serviceDatabase" />
</div>
- <div x-cloak x-show="activeTab === 'backups'">
- <div class="flex gap-2 ">
- <h2 class="pb-4">Scheduled Backups</h2>
- <x-modal-input buttonTitle="+ Add" title="New Scheduled Backup">
- <livewire:project.database.create-scheduled-backup :database="$serviceDatabase" :s3s="$s3s" />
- </x-modal-input>
- </div>
- <livewire:project.database.scheduled-backups :database="$serviceDatabase" />
- </div>
- @endisset
- </div>
+ @if ($serviceDatabase->isBackupSolutionAvailable())
+ <div x-cloak x-show="activeTab === 'backups'">
+ <div class="flex gap-2 ">
+ <h2 class="pb-4">Scheduled Backups</h2>
+ <x-modal-input buttonTitle="+ Add" title="New Scheduled Backup">
+ <livewire:project.database.create-scheduled-backup :database="$serviceDatabase" :s3s="$s3s" />
+ </x-modal-input>
+ </div>
+ <livewire:project.database.scheduled-backups :database="$serviceDatabase" />
+ @endif
+ </div>
+ @endisset
</div>
</div>
+</div>