fix: make coolify-db backups unique dir

This commit is contained in:
Andras Bacsai 2023-08-15 15:39:15 +02:00
parent 61facbb871
commit 3d432d025a
3 changed files with 15 additions and 5 deletions

View File

@ -18,6 +18,7 @@
use Illuminate\Queue\Middleware\WithoutOverlapping;
use Illuminate\Queue\SerializesModels;
use Throwable;
use Illuminate\Support\Str;
class DatabaseBackupJob implements ShouldQueue
{
@ -68,11 +69,13 @@ public function handle(): void
return;
}
$this->container_name = $this->database->uuid;
$this->backup_dir = backup_dir() . "/" . $this->container_name;
if ($this->database->name === 'coolify-db') {
$this->container_name = "coolify-db";
$ip = Str::slug($this->server->ip);
$this->backup_dir = backup_dir() . "/coolify-db-$ip";
}
$this->backup_dir = backup_dir() . "/" . $this->container_name;
$this->backup_file = "/dumpall-" . Carbon::now()->timestamp . ".sql";
$this->backup_location = $this->backup_dir . $this->backup_file;
@ -95,6 +98,7 @@ public function handle(): void
private function backup_standalone_postgresql(): void
{
try {
ray($this->backup_dir);
$commands[] = "mkdir -p " . $this->backup_dir;
$commands[] = "docker exec $this->container_name pg_dumpall -U {$this->database->postgres_user} > $this->backup_location";

View File

@ -130,10 +130,16 @@ function set_transanctional_email_settings(InstanceSettings|null $settings = nul
function base_ip(): string
{
if (is_dev()) {
return "http://localhost";
return "localhost";
}
$settings = InstanceSettings::get();
return "http://$settings->public_ipv4";
if ($settings->public_ipv4) {
return "$settings->public_ipv4";
}
if ($settings->public_ipv6) {
return "$settings->public_ipv6";
}
return "localhost";
}
/**

View File

@ -1,3 +1,3 @@
<?php
return '4.0.0-beta.19';
return '4.0.0-beta.20';