|
|
|
|
@@ -36,6 +36,7 @@ class DatabaseBackupJob implements ShouldQueue, ShouldBeEncrypted
|
|
|
|
|
public StandalonePostgresql|StandaloneMongodb|StandaloneMysql|StandaloneMariadb|ServiceDatabase $database;
|
|
|
|
|
|
|
|
|
|
public ?string $container_name = null;
|
|
|
|
|
public ?string $directory_name = null;
|
|
|
|
|
public ?ScheduledDatabaseBackupExecution $backup_log = null;
|
|
|
|
|
public string $backup_status = 'failed';
|
|
|
|
|
public ?string $backup_location = null;
|
|
|
|
|
@@ -88,27 +89,33 @@ class DatabaseBackupJob implements ShouldQueue, ShouldBeEncrypted
|
|
|
|
|
if (data_get($this->backup, 'database_type') === 'App\Models\ServiceDatabase') {
|
|
|
|
|
$databaseType = $this->database->databaseType();
|
|
|
|
|
$serviceUuid = $this->database->service->uuid;
|
|
|
|
|
$serviceName = str($this->database->service->name)->slug();
|
|
|
|
|
if ($databaseType === 'standalone-postgresql') {
|
|
|
|
|
$this->container_name = "postgresql-$serviceUuid";
|
|
|
|
|
$this->directory_name = $serviceName . '-' . $this->container_name;
|
|
|
|
|
$commands[] = "docker exec $this->container_name env | grep POSTGRES_";
|
|
|
|
|
$envs = instant_remote_process($commands, $this->server);
|
|
|
|
|
$databasesToBackup = Str::of($envs)->after('POSTGRES_DB=')->before("\n")->value();
|
|
|
|
|
$this->database->postgres_user = Str::of($envs)->after('POSTGRES_USER=')->before("\n")->value();
|
|
|
|
|
} else if ($databaseType === 'standalone-mysql') {
|
|
|
|
|
$this->container_name = "mysql-$serviceUuid";
|
|
|
|
|
$this->directory_name = $serviceName . '-' . $this->container_name;
|
|
|
|
|
$commands[] = "docker exec $this->container_name env | grep MYSQL_";
|
|
|
|
|
$envs = instant_remote_process($commands, $this->server);
|
|
|
|
|
$databasesToBackup = Str::of($envs)->after('MYSQL_DATABASE=')->before("\n")->value();
|
|
|
|
|
$this->database->mysql_root_password = Str::of($envs)->after('MYSQL_ROOT_PASSWORD=')->before("\n")->value();
|
|
|
|
|
} else if ($databaseType === 'standalone-mariadb') {
|
|
|
|
|
$this->container_name = "mariadb-$serviceUuid";
|
|
|
|
|
$this->directory_name = $serviceName . '-' . $this->container_name;
|
|
|
|
|
$commands[] = "docker exec $this->container_name env | grep MARIADB_";
|
|
|
|
|
$envs = instant_remote_process($commands, $this->server);
|
|
|
|
|
$databasesToBackup = Str::of($envs)->after('MARIADB_DATABASE=')->before("\n")->value();
|
|
|
|
|
$this->database->mysql_root_password = Str::of($envs)->after('MARIADB_ROOT_PASSWORD=')->before("\n")->value();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$databaseName = str($this->database->name)->slug()->value();
|
|
|
|
|
$this->container_name = $this->database->uuid;
|
|
|
|
|
$this->directory_name = $databaseName . '-' . $this->container_name;
|
|
|
|
|
$databaseType = $this->database->type();
|
|
|
|
|
$databasesToBackup = data_get($this->backup, 'databases_to_backup');
|
|
|
|
|
}
|
|
|
|
|
@@ -147,11 +154,11 @@ class DatabaseBackupJob implements ShouldQueue, ShouldBeEncrypted
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$this->backup_dir = backup_dir() . "/databases/" . Str::of($this->team->name)->slug() . '-' . $this->team->id . '/' . $this->container_name;
|
|
|
|
|
$this->backup_dir = backup_dir() . "/databases/" . Str::of($this->team->name)->slug() . '-' . $this->team->id . '/' . $this->directory_name;
|
|
|
|
|
|
|
|
|
|
if ($this->database->name === 'coolify-db') {
|
|
|
|
|
$databasesToBackup = ['coolify'];
|
|
|
|
|
$this->container_name = "coolify-db";
|
|
|
|
|
$this->directory_name = $this->container_name = "coolify-db";
|
|
|
|
|
$ip = Str::slug($this->server->ip);
|
|
|
|
|
$this->backup_dir = backup_dir() . "/coolify" . "/coolify-db-$ip";
|
|
|
|
|
}
|
|
|
|
|
|