HUB
Sign inSign up

cplieger/pg-autodump

By cplieger

•Updated 3 days ago

Keep a checked dump of every PostgreSQL database in the folder your backup tool already collects

Image
Security
Databases & storage
0

10K+

cplieger/pg-autodump repository overview

⁠pg-autodump

pg-autodump writes a checked backup file of each PostgreSQL database you list into a folder your backup tool already collects. It leaves encryption and off-site copies to that tool, such as Kopia, Restic, Borg or rsync.

⁠What it does

pg-autodump keeps a fresh, readable dump of every database you list for your backup tool.

  • Dumps each database with PostgreSQL's pg_dump, compressed, every 24 hours or whenever you ask.
  • Replaces a dump only after pg_restore can read the new file's table of contents, so a failed run keeps the last good file.
  • Keeps the 7 newest dumps of each database, and deletes old ones only once a new one is in place.
  • Tells you when a backup fails, through Docker health, Prometheus metrics and alert rules for Prometheus or Loki.

⁠Who it is for

pg-autodump is built for self-hosters who run PostgreSQL behind apps such as Authentik, Paperless or Immich and already back up a folder. It connects over the network as a read-only role. It dumps only the databases you list, without the server's roles or other server-wide settings. It sends no notifications itself, so alerts come from Prometheus, Loki or a tool watching Docker health.

You need a PostgreSQL server, version 9.2 to 18, that the container can reach, and a role that can read every table.

Consider pgBackRest⁠ if you want full, differential and incremental backups of a whole server in S3, Azure, GCS or SFTP storage.

pg-autodump is free software under the Apache-2.0 license.

⁠Pull

docker pull cplieger/pg-autodump:latest

Also published to ghcr.io/cplieger/pg-autodump with identical images and tags. Release versions are tagged vX.Y.Z alongside latest.

⁠Quick start

# Example compose for pg-autodump. See the README for all configuration options and hardening.
services:
  pg-autodump:
    image: ghcr.io/cplieger/pg-autodump:latest
    container_name: pg-autodump
    restart: unless-stopped
    # Run "mkdir secrets dumps". Once secrets/.pgpass exists, run "sudo chown 1000:1000 secrets/.pgpass dumps",
    # or every dump fails. If .env sets PUID and PGID, use those numbers.
    user: "${PUID:-1000}:${PGID:-1000}"
    stop_grace_period: 320s  # SHUTDOWN_TIMEOUT (default 315s) plus 5s, so a running dump finishes or cleans up on stop

    environment:
      # First create a login role with pg_read_all_data and CONNECT on each database.
      # The README quick start has the SQL.
      DB_SPECS: "mydb-host:5432:myapp:dbdumper_ro"  # host:port:database:role, space-separated, never localhost

    ports:
      # Anyone who reaches this port can start a dump. Keep it on 127.0.0.1,
      # or set AUTH_TOKEN before you publish it to a network, for example for a scraper.
      - "127.0.0.1:9472:9472"

    volumes:
      # Put one "host:port:database:role:password" line per database in secrets/.pgpass,
      # then run "chmod 600 secrets/.pgpass", or the PostgreSQL tools ignore it.
      - "./secrets/.pgpass:/secrets/.pgpass:ro"
      - "./dumps:/dumps"  # point your backup tool at this folder

⁠Documentation

⁠License

Apache-2.0. See LICENSE⁠.

The image carries the license text of every bundled component under /usr/share/licenses/. The Alpine packages in the image ship no license file upstream, so their license texts are kept under licenses/ in this repository and copied in.

Third-party attributions are in THIRD_PARTY_NOTICES.md⁠.

Tag summary

Content type

Image

Digest

sha256:bab3b64d1…

Size

12.7 MB

Last updated

3 days ago

docker pull cplieger/pg-autodump