Skip to content

Instantly share code, notes, and snippets.

@Cyberistic
Created December 30, 2025 06:39
Show Gist options
  • Select an option

  • Save Cyberistic/b4d6697f34d65fcfe9fc3042e78c2463 to your computer and use it in GitHub Desktop.

Select an option

Save Cyberistic/b4d6697f34d65fcfe9fc3042e78c2463 to your computer and use it in GitHub Desktop.
pgbackweb-coolify

PGBackWeb for Coolify

Deploy PGBackWeb on Coolify and backup multiple PostgreSQL databases to S3-compatible storage buckets. Best for when db is defined in a monorepo docker-compose and coolify cannot auto-detect it.

Quick Start

  1. In Coolify, create a new ServiceDocker Compose
  2. Paste the docker-compose.yml content
  3. Deploy - Coolify handles the rest
  4. Under services, find pgbackweb and assign domain, make sure to add port 8085 (eg. pgbackweb.yourdomain.com:8085)

Services

Service Description Port
pgbackweb Backup management web UI 8085
postgres PostgreSQL database for PGBackWeb metadata 5432 (internal)

Adding Databases to Backup

PGBackWeb can backup any PostgreSQL database accessible from your network:

  1. Log into the PGBackWeb interface
  2. Go to DatabasesAdd Database
  3. Enter connection details for the database you want to backup
  4. Configure backup schedules and S3 destinations as needed

S3 Storage (Optional)

To store backups in S3-compatible storage:

  1. Go to Destinations in PGBackWeb
  2. Add your S3 bucket credentials
  3. Assign the destination to your backup jobs

Compatible with AWS S3, MinIO, Cloudflare R2, Backblaze B2, etc.

Cloudflare R2 Setup

  1. Create an R2 bucket

    • Log into Cloudflare Dashboard
    • Go to R2 Object StorageCreate bucket
    • Choose a bucket name (e.g., pgbackups)
    • Select your preferred location
  2. Create API tokens

    • Go to R2 Object StorageManage R2 API Tokens
    • Click Create API token
    • Select Object Read & Write permission
    • Scope to your specific bucket (recommended) or all buckets
    • Click Create API Token
    • Save the Access Key ID and Secret Access Key (shown only once)
  3. Get your R2 endpoint

    • Your endpoint URL format: https://<ACCOUNT_ID>.r2.cloudflarestorage.com
    • Find your Account ID in the Cloudflare dashboard URL or R2 overview page
  4. Configure in PGBackWeb

    • Go to DestinationsAdd Destination
    • Fill in the details:
    Field Value
    Name Cloudflare R2 (or your preference)
    Endpoint https://<ACCOUNT_ID>.r2.cloudflarestorage.com
    Region auto
    Bucket Your bucket name (e.g., pgbackups)
    Access Key Your R2 Access Key ID
    Secret Key Your R2 Secret Access Key
  5. Test the connection and save

IMPORTANT: Login email is case-sensitive. Emails are stored in lowercase but login is case-sensitive. If you registered with User@Example.com, you must login with user@example.com (all lowercase).

Resources

License

This deployment configuration is provided as-is. PGBackWeb is licensed under AGPL-3.0.

services:
pgbackweb:
image: eduardolat/pgbackweb:latest
restart: unless-stopped
environment:
# Coolify magic variable - generates FQDN and routes to port 8085
- SERVICE_FQDN_PGBACKWEB_8085
- PBW_ENCRYPTION_KEY=${SERVICE_PASSWORD_64_PGBACKWEB}
- PBW_POSTGRES_CONN_STRING=postgresql://pgbackweb:${SERVICE_PASSWORD_POSTGRES}@postgres:5432/pgbackweb?sslmode=disable
# Optional: Timezone (defaults to UTC)
- TZ=${TZ:-UTC}
depends_on:
postgres:
condition: service_healthy
volumes:
# Local backup storage (optional if only using S3 destinations)
- pgbackweb-backups:/backups
healthcheck:
test:
[
"CMD",
"wget",
"--no-verbose",
"--tries=1",
"-O",
"/dev/null",
"http://localhost:8085",
]
interval: 30s
timeout: 10s
retries: 3
start_period: 15s
postgres:
image: postgres:17-alpine
restart: unless-stopped
environment:
# Coolify magic variable for auto-generated password
- POSTGRES_USER=pgbackweb
- POSTGRES_PASSWORD=${SERVICE_PASSWORD_POSTGRES}
- POSTGRES_DB=pgbackweb
volumes:
- postgres-data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U pgbackweb -d pgbackweb"]
interval: 10s
timeout: 5s
retries: 5
volumes:
postgres-data:
pgbackweb-backups:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment