Skip to content

PostgreSQL backup tool with Point-In-Time-Recovery and restore verification

feat: add PostgreSQL 12 support

Roman Bykovsky3a5ac4b4796e
diff --git a/Dockerfile b/Dockerfile
index 16995e7b..3da290e4 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -77,7 +77,7 @@ ENV APP_VERSION=$APP_VERSION
# Set production mode for Docker containers
ENV ENV_MODE=production
-# Install PostgreSQL server and client tools (versions 13-17)
+# Install PostgreSQL server and client tools (versions 12-18)
RUN apt-get update && apt-get install -y --no-install-recommends \
wget ca-certificates gnupg lsb-release sudo gosu && \
wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
@@ -85,7 +85,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
> /etc/apt/sources.list.d/pgdg.list && \
apt-get update && \
apt-get install -y --no-install-recommends \
- postgresql-17 postgresql-18 postgresql-client-13 postgresql-client-14 postgresql-client-15 \
+ postgresql-17 postgresql-18 postgresql-client-12 postgresql-client-13 postgresql-client-14 postgresql-client-15 \
postgresql-client-16 postgresql-client-17 postgresql-client-18 && \
rm -rf /var/lib/apt/lists/*
diff --git a/README.md b/README.md
index 9ffe76c1..d078c4d7 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@
[![Docker Pulls](https://img.shields.io/docker/pulls/rostislavdugin/postgresus?color=brightgreen)](https://hub.docker.com/r/rostislavdugin/postgresus)
[![Platform](https://img.shields.io/badge/platform-linux%20%7C%20macos%20%7C%20windows-lightgrey)](https://github.com/RostislavDugin/postgresus)
- [![PostgreSQL](https://img.shields.io/badge/PostgreSQL-13%20%7C%2014%20%7C%2015%20%7C%2016%20%7C%2017%20%7C%2018-336791?logo=postgresql&logoColor=white)](https://www.postgresql.org/)
+ [![PostgreSQL](https://img.shields.io/badge/PostgreSQL-12%20%7C%2013%20%7C%2014%20%7C%2015%20%7C%2016%20%7C%2017%20%7C%2018-336791?logo=postgresql&logoColor=white)](https://www.postgresql.org/)
[![Self Hosted](https://img.shields.io/badge/self--hosted-yes-brightgreen)](https://github.com/RostislavDugin/postgresus)
[![Open Source](https://img.shields.io/badge/open%20source-❤️-red)](https://github.com/RostislavDugin/postgresus)
@@ -54,7 +54,7 @@
### 🐘 **PostgreSQL Support**
-- **Multiple versions**: PostgreSQL 13, 14, 15, 16, 17 and 18
+- **Multiple versions**: PostgreSQL 12, 13, 14, 15, 16, 17 and 18
- **SSL support**: Secure connections available
- **Easy restoration**: One-click restore from any backup
diff --git a/backend/internal/features/backups/backups/usecases/postgresql/create_backup_uc.go b/backend/internal/features/backups/backups/usecases/postgresql/create_backup_uc.go
index 4bcfd55a..cb1e1f71 100644
--- a/backend/internal/features/backups/backups/usecases/postgresql/create_backup_uc.go
+++ b/backend/internal/features/backups/backups/usecases/postgresql/create_backup_uc.go
@@ -70,10 +70,10 @@ func (uc *CreatePostgresqlBackupUsecase) Execute(
"--verbose", // Add verbose output to help with debugging
}
- // Use zstd compression level 5 for PostgreSQL 15+ (better compression and speed)
- // Fall back to gzip compression level 5 for older versions
- if pg.Version == tools.PostgresqlVersion13 || pg.Version == tools.PostgresqlVersion14 ||
- pg.Version == tools.PostgresqlVersion15 {
+ // Use zstd compression level 5 for PostgreSQL 16+ (better compression and speed)
+ // Fall back to gzip compression level 5 for older versions (12-15)
+ if pg.Version == tools.PostgresqlVersion12 || pg.Version == tools.PostgresqlVersion13 ||
+ pg.Version == tools.PostgresqlVersion14 || pg.Version == tools.PostgresqlVersion15 {
args = append(args, "-Z", "5")
uc.logger.Info("Using gzip compression level 5 (zstd not available)", "version", pg.Version)
} else {
diff --git a/backend/internal/util/tools/enums.go b/backend/internal/util/tools/enums.go
index c7cdf66c..0600f391 100644
--- a/backend/internal/util/tools/enums.go
+++ b/backend/internal/util/tools/enums.go
@@ -15,6 +15,7 @@ const (
type PostgresqlVersion string
const (
+ PostgresqlVersion12 PostgresqlVersion = "12"
PostgresqlVersion13 PostgresqlVersion = "13"
PostgresqlVersion14 PostgresqlVersion = "14"
PostgresqlVersion15 PostgresqlVersion = "15"
@@ -32,6 +33,8 @@ const (
func GetPostgresqlVersionEnum(version string) PostgresqlVersion {
switch version {
+ case "12":
+ return PostgresqlVersion12
case "13":
return PostgresqlVersion13
case "14":
diff --git a/backend/internal/util/tools/postgresql.go b/backend/internal/util/tools/postgresql.go
index 80c6c660..63915b93 100644
--- a/backend/internal/util/tools/postgresql.go
+++ b/backend/internal/util/tools/postgresql.go
@@ -30,7 +30,7 @@ func GetPostgresqlExecutable(
return filepath.Join(basePath, executableName)
}
-// VerifyPostgresesInstallation verifies that PostgreSQL versions 13-17 are installed
+// VerifyPostgresesInstallation verifies that PostgreSQL versions 12-18 are installed
// in the current environment. Each version should be installed with the required
// client tools (pg_dump, psql) available.
// In development: ./tools/postgresql/postgresql-{VERSION}/bin
@@ -41,6 +41,7 @@ func VerifyPostgresesInstallation(
postgresesInstallDir string,
) {
versions := []PostgresqlVersion{
+ PostgresqlVersion12,
PostgresqlVersion13,
PostgresqlVersion14,
PostgresqlVersion15,
diff --git a/backend/tools/download_linux.sh b/backend/tools/download_linux.sh
index c1eb263a..f94fcfa9 100644
--- a/backend/tools/download_linux.sh
+++ b/backend/tools/download_linux.sh
@@ -5,7 +5,7 @@ set -e # Exit on any error
# Ensure non-interactive mode for apt
export DEBIAN_FRONTEND=noninteractive
-echo "Installing PostgreSQL client tools versions 13-18 for Linux (Debian/Ubuntu)..."
+echo "Installing PostgreSQL client tools versions 12-18 for Linux (Debian/Ubuntu)..."
echo
# Check if running on supported system
@@ -47,7 +47,7 @@ echo "Updating package list..."
$SUDO apt-get update -qq -y
# Install client tools for each version
-versions="13 14 15 16 17 18"
+versions="12 13 14 15 16 17 18"
for version in $versions; do
echo "Installing PostgreSQL $version client tools..."
diff --git a/backend/tools/download_macos.sh b/backend/tools/download_macos.sh
old mode 100644
new mode 100755
index 13937b13..9ff11fe1
--- a/backend/tools/download_macos.sh
+++ b/backend/tools/download_macos.sh
@@ -2,7 +2,7 @@
set -e # Exit on any error
-echo "Installing PostgreSQL client tools versions 13-18 for MacOS..."
+echo "Installing PostgreSQL client tools versions 12-18 for MacOS..."
echo
# Check if Homebrew is installed
@@ -31,6 +31,7 @@ brew install wget openssl readline zlib
# PostgreSQL source URLs
declare -A PG_URLS=(
+ ["12"]="https://ftp.postgresql.org/pub/source/v12.20/postgresql-12.20.tar.gz"
["13"]="https://ftp.postgresql.org/pub/source/v13.16/postgresql-13.16.tar.gz"
["14"]="https://ftp.postgresql.org/pub/source/v14.13/postgresql-14.13.tar.gz"
["15"]="https://ftp.postgresql.org/pub/source/v15.8/postgresql-15.8.tar.gz"
@@ -107,7 +108,7 @@ build_postgresql_client() {
}
# Build each version
-versions="13 14 15 16 17 18"
+versions="12 13 14 15 16 17 18"
for version in $versions; do
url=${PG_URLS[$version]}
diff --git a/backend/tools/download_windows.bat b/backend/tools/download_windows.bat
index acb98257..8702e4fc 100644
--- a/backend/tools/download_windows.bat
+++ b/backend/tools/download_windows.bat
@@ -1,7 +1,7 @@
@echo off
setlocal enabledelayedexpansion
-echo Downloading and installing PostgreSQL versions 13-18 for Windows...
+echo Downloading and installing PostgreSQL versions 12-18 for Windows...
echo.
:: Create downloads and postgresql directories if they don't exist
@@ -17,6 +17,7 @@ cd downloads
set "BASE_URL=https://get.enterprisedb.com/postgresql"
:: Define versions and their corresponding download URLs
+set "PG12_URL=%BASE_URL%/postgresql-12.20-1-windows-x64.exe"
set "PG13_URL=%BASE_URL%/postgresql-13.16-1-windows-x64.exe"
set "PG14_URL=%BASE_URL%/postgresql-14.13-1-windows-x64.exe"
set "PG15_URL=%BASE_URL%/postgresql-15.8-1-windows-x64.exe"
@@ -25,7 +26,7 @@ set "PG17_URL=%BASE_URL%/postgresql-17.0-1-windows-x64.exe"
set "PG18_URL=%BASE_URL%/postgresql-18.0-1-windows-x64.exe"
:: Array of versions
-set "versions=13 14 15 16 17 18"
+set "versions=12 13 14 15 16 17 18"
:: Download and install each version
for %%v in (%versions%) do (
diff --git a/backend/tools/readme.md b/backend/tools/readme.md
index 94ab9789..1e932a7d 100644
--- a/backend/tools/readme.md
+++ b/backend/tools/readme.md
@@ -1,6 +1,6 @@
This directory is needed only for development and CI\CD.
-We have to download and install all the PostgreSQL versions from 13 to 18 locally.
+We have to download and install all the PostgreSQL versions from 12 to 18 locally.
This is needed so we can call pg_dump, pg_dumpall, etc. on each version of the PostgreSQL database.
You do not need to install PostgreSQL fully with all the components.
@@ -8,6 +8,7 @@ We only need the client tools (pg_dump, pg_dumpall, psql, etc.) for each version
We have to install the following:
+- PostgreSQL 12
- PostgreSQL 13
- PostgreSQL 14
- PostgreSQL 15
@@ -72,6 +73,7 @@ The final directory structure should match:
For example:
+- `./tools/postgresql/postgresql-12/bin/pg_dump`
- `./tools/postgresql/postgresql-13/bin/pg_dump`
- `./tools/postgresql/postgresql-14/bin/pg_dump`
- `./tools/postgresql/postgresql-15/bin/pg_dump`
diff --git a/frontend/src/entity/databases/model/postgresql/PostgresqlVersion.ts b/frontend/src/entity/databases/model/postgresql/PostgresqlVersion.ts
index 5331a98f..5a549de6 100644
--- a/frontend/src/entity/databases/model/postgresql/PostgresqlVersion.ts
+++ b/frontend/src/entity/databases/model/postgresql/PostgresqlVersion.ts
@@ -1,4 +1,5 @@
export enum PostgresqlVersion {
+ PostgresqlVersion12 = '12',
PostgresqlVersion13 = '13',
PostgresqlVersion14 = '14',
PostgresqlVersion15 = '15',
diff --git a/frontend/src/features/databases/ui/edit/EditDatabaseSpecificDataComponent.tsx b/frontend/src/features/databases/ui/edit/EditDatabaseSpecificDataComponent.tsx
index 52e836ba..a94d74a9 100644
--- a/frontend/src/features/databases/ui/edit/EditDatabaseSpecificDataComponent.tsx
+++ b/frontend/src/features/databases/ui/edit/EditDatabaseSpecificDataComponent.tsx
@@ -128,6 +128,7 @@ export const EditDatabaseSpecificDataComponent = ({
className="max-w-[200px] grow"
placeholder="Select PG version"
options={[
+ { label: '12', value: PostgresqlVersion.PostgresqlVersion12 },
{ label: '13', value: PostgresqlVersion.PostgresqlVersion13 },
{ label: '14', value: PostgresqlVersion.PostgresqlVersion14 },
{ label: '15', value: PostgresqlVersion.PostgresqlVersion15 },
diff --git a/frontend/src/features/databases/ui/show/ShowDatabaseSpecificDataComponent.tsx b/frontend/src/features/databases/ui/show/ShowDatabaseSpecificDataComponent.tsx
index 0a9d0e8f..abc89263 100644
--- a/frontend/src/features/databases/ui/show/ShowDatabaseSpecificDataComponent.tsx
+++ b/frontend/src/features/databases/ui/show/ShowDatabaseSpecificDataComponent.tsx
@@ -5,6 +5,7 @@ interface Props {
}
const postgresqlVersionLabels = {
+ [PostgresqlVersion.PostgresqlVersion12]: '12',
[PostgresqlVersion.PostgresqlVersion13]: '13',
[PostgresqlVersion.PostgresqlVersion14]: '14',
[PostgresqlVersion.PostgresqlVersion15]: '15',