Use "One Shot" mode to perform upgrades only
mainIf you want to perform the database upgrade without starting the PostgreSQL server afterwards, use "One Shot" mode by setting the PGAUTO_ONESHOT environment variable to yes.
Kubernetes Integration
You can run pgautoupgrade as an initContainer in Kubernetes to perform the upgrade before your main database container starts. For Bitnami containers, ensure you set runAsUser: 0 so the container can restore original file permissions.
initContainers:
- env:
- name: PGAUTO_ONESHOT
value: "yes"
- name: POSTGRES_DB
value: XXX
- name: PGDATA
value: /bitnami/postgresql/data
- name: POSTGRES_PASSWORD
value: password
image: pgautoupgrade/pgautoupgrade:18-trixie
name: upgrade-postgres
securityContext:
runAsUser: 0
volumeMounts:
- mountPath: /bitnami/postgresql
name: YYY$ docker run --name pgauto -it \
--mount type=bind,source=/path/to/your/database/directory,target=/var/lib/postgresql/data \
-e POSTGRES_PASSWORD=password \
-e PGAUTO_ONESHOT=yes \
<NAME_OF_THE_PGAUTOUPGRADE_IMAGE>