pgautoupgrade

Automatically upgrade your PostgreSQL database inside a Docker container. This image detects the existing version and uses pg_upgrade for a fast, in-place update.

The official PostgreSQL Docker image doesn't provide a way to handle version upgrades, often requiring complex manual steps. This Docker image solves that problem by automating the entire process. It automatically detects the version of your existing PostgreSQL data directory and performs a fast, in-place upgrade using pg_upgrade with the --link option, minimizing downtime and disk space usage. Always back up your data before proceeding, as this tool modifies your database files directly.

It offers several powerful features to fit different workflows:

  • Run in "one-shot" mode to perform the upgrade and then exit, which is ideal for use as a Kubernetes initContainer.
  • Choose between Alpine and Debian-based images to match your existing environment.
  • Includes special handling for upgrading from Bitnami PostgreSQL containers, mapping environment variables and file permissions correctly.
  • Skip the post-upgrade reindexing process by setting an environment variable, saving significant time on large databases.

Directory Structure

pgautoupgrade
postgres-data
.env
docker-compose.yml

docker-compose.yml

services:
  db:
    image: pgautoupgrade/pgautoupgrade:latest
    container_name: pgautoupgrade
    restart: unless-stopped
    environment:
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      POSTGRES_DB: ${POSTGRES_DB}
    volumes:
      - ./postgres-data:/var/lib/postgresql/data
    ports:
      - "5432:5432"

.env

POSTGRES_USER=postgres
POSTGRES_PASSWORD=your_super_secret_password
POSTGRES_DB=my_database
Categories:

Share:

Ad
Favicon

 

  
 

Similar to pgautoupgrade

Favicon

 

  
  
Favicon

 

  
  
Favicon