Back up PostgreSQL to S3
Dump a PostgreSQL database with pg_dump and upload the dump file to an S3 bucket. Restore it with pg_restore.
Install v1.0.0
Installs the template into your Argo namespace. The URL is pinned to this version.
kubectl apply -n argo -f https://catalog.dagweave.com/api/v1/items/pg-dump-to-s3/1.0.0/template.yaml
Or with the Argo CLI:
argo template create -n argo https://catalog.dagweave.com/api/v1/items/pg-dump-to-s3/1.0.0/template.yaml
Facts
- Category
- Databases
- Tags
- aws-cli databases postgres
- Entrypoint
backup- Template SHA-256
168ee8bf2e1dfdc729ff970ef0ac31bbc3ad30e19fbf082be67911328c709737- Source
- pg-dump-to-s3 at catalog commit 67458f7
- API
- item document, latest template.yaml
Images and provenance
Every image is pinned by digest, so a rebuilt tag can never change what this version runs.
| Repository | Tag | Digest |
|---|---|---|
cgr.dev/chainguard/postgres | latest-dev | sha256:dfc3fba4527ef4bf91eaf9ee518589447f4f2ca3bea47c914bc50e959b3721cb |
amazon/aws-cli | 2.39.3 | sha256:d557b3524475d70dd3104cf44d96568ee3188897b73a6ece2b37aa50e1af362f |
Parameters
| Name | Description | Default |
|---|---|---|
bucket required |
S3 bucket to put the dump in, without the s3:// prefix. Example acme-db-backups |
none |
database required |
Database to connect to. | none |
host required |
PostgreSQL server host. Example db.internal |
none |
key required |
Object key for the dump file. Example checkout/2026-10-18.dump |
none |
user required |
User to connect as. | none |
aws-access-key-id-key |
Key in that Secret that holds the access key id. | access-key-id |
aws-secret-access-key-key |
Key in that Secret that holds the secret access key. | secret-access-key |
aws-secret-name |
Name of the Kubernetes Secret that holds the AWS credentials. | aws-credentials |
password-secret-key |
Key in that Secret that holds the password. | password |
password-secret-name |
Name of the Kubernetes Secret that holds the user's password. | postgres-password |
port |
PostgreSQL server port. | 5432 |
region |
AWS region of the resource. | us-east-1 |
WorkflowTemplate
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
name: pg-dump-to-s3
labels:
dagweave.io/catalog-item: pg-dump-to-s3
annotations:
dagweave.io/catalog-version: "1.0.0"
dagweave.io/catalog-category: "Databases"
spec:
entrypoint: backup
templates:
- name: backup
inputs:
parameters:
- name: host
- name: port
default: "5432"
- name: database
- name: user
- name: bucket
- name: key
- name: password-secret-name
default: "postgres-password"
- name: password-secret-key
default: "password"
- name: region
default: "us-east-1"
- name: aws-secret-name
default: "aws-credentials"
- name: aws-access-key-id-key
default: "access-key-id"
- name: aws-secret-access-key-key
default: "secret-access-key"
retryStrategy:
limit: "2"
retryPolicy: OnError
backoff:
duration: 10s
factor: "2"
maxDuration: 2m
volumes:
- name: dump
emptyDir: {}
containerSet:
volumeMounts:
- name: dump
mountPath: /dump
containers:
- name: dump
# cgr.dev/chainguard/postgres:latest-dev
image: cgr.dev/chainguard/postgres@sha256:dfc3fba4527ef4bf91eaf9ee518589447f4f2ca3bea47c914bc50e959b3721cb
command: [sh, -c]
args:
- |
set -eu
pg_dump --format=custom --file=/dump/db.dump
ls -l /dump/db.dump
env:
- name: PGHOST
value: "{{inputs.parameters.host}}"
- name: PGPORT
value: "{{inputs.parameters.port}}"
- name: PGDATABASE
value: "{{inputs.parameters.database}}"
- name: PGUSER
value: "{{inputs.parameters.user}}"
- name: PGPASSWORD
valueFrom:
secretKeyRef:
name: "{{inputs.parameters.password-secret-name}}"
key: "{{inputs.parameters.password-secret-key}}"
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
memory: 512Mi
- name: main
dependencies: [dump]
# amazon/aws-cli:2.39.3
image: amazon/aws-cli@sha256:d557b3524475d70dd3104cf44d96568ee3188897b73a6ece2b37aa50e1af362f
command: [sh, -c]
args:
- |
set -eu
aws s3 cp /dump/db.dump "s3://${S3_BUCKET}/${S3_KEY}" --only-show-errors
env:
- name: S3_BUCKET
value: "{{inputs.parameters.bucket}}"
- name: S3_KEY
value: "{{inputs.parameters.key}}"
- name: AWS_DEFAULT_REGION
value: "{{inputs.parameters.region}}"
- name: AWS_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
name: "{{inputs.parameters.aws-secret-name}}"
key: "{{inputs.parameters.aws-access-key-id-key}}"
- name: AWS_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: "{{inputs.parameters.aws-secret-name}}"
key: "{{inputs.parameters.aws-secret-access-key-key}}"
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
memory: 512Mi
Version history
Read from the item's changelog. Each version has its own JSON document; the pinned catalogue vendors the manifest of the latest one, so that is the version that installs.
-
1.0.0 latest 2026-10-18
Initial release.
kubectl apply -n argo -f https://catalog.dagweave.com/api/v1/items/pg-dump-to-s3/1.0.0/template.yamlargo template create -n argo https://catalog.dagweave.com/api/v1/items/pg-dump-to-s3/1.0.0/template.yaml
Run it once
After installing, from the command line.
argo submit -n argo --from workflowtemplate/pg-dump-to-s3 \
-p bucket=acme-db-backups \
-p database=... \
-p host=db.internal \
-p key=checkout/2026-10-18.dump \
-p user=...
Workflow that references it
A Workflow with the required parameters filled from the examples.
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: pg-dump-to-s3-
spec:
workflowTemplateRef:
name: pg-dump-to-s3
arguments:
parameters:
- name: bucket
value: "acme-db-backups"
- name: database
value: "..."
- name: host
value: "db.internal"
- name: key
value: "checkout/2026-10-18.dump"
- name: user
value: "..."
As a step of a larger workflow
steps:
- - name: pg-dump-to-s3
templateRef:
name: pg-dump-to-s3
template: backup