Skip to content

Latest commit

 

History

History
90 lines (65 loc) · 2.21 KB

postgresql_migrate_from_11_12.md

File metadata and controls

90 lines (65 loc) · 2.21 KB

Migration from PostgreSQL 11 to 12

This document describes how to migrate from PostgreSQL 11 that was used for charts < 3.0.0 to PostgreSQL 12.

Note The procedure describes below causes downtime of your service.

Create a backup

  1. Create a persistent volume claim that will be used to store backup.
kubectl -n <your-namespace> create -f examples/backup-pvc.yaml
  1. Mount an extra volume to the postgresql deployment using the following values.
# values.yaml

# postgresql specific settings (https://hub.helm.sh/charts/bitnami/postgresql/8.6.13)
postgresql:
  master:
    extraVolumes:
      - name: backup
        persistentVolumeClaim:
          claimName: backup-rasa-x-postgresql-0
    extraVolumeMounts:
      - mountPath: /backup
        name: backup
  1. Upgrade the deployment.
helm -n <your-namespace> upgrade -f values.yaml --reuse-values <release-name> rasa-x/rasa-x
  1. Create a backup
kubectl -n tczekajlo-test exec <release-name>-postgresql-0 -- /bin/bash -c 'PGPASSWORD=${POSTGRES_PASSWORD} pg_dump -U postgres --format=c --file=/backup/dump_backup.bak rasa'

Restore backup

  1. Update the chart repository.
helm repo update
  1. Change PostgreSQL data directory and mount the backup volume.
# values.yaml
postgresql:
  image:
    # tag of PostgreSQL Image
    tag: "12.8.0"

  extraEnv:
    - name: PGDATA
      value: /bitnami/postgresql/data_12

  # Mount the volume with the backup
  master:
    extraVolumes:
      - name: backup
        persistentVolumeClaim:
          claimName: backup-rasa-x-postgresql-0
    extraVolumeMounts:
      - mountPath: /backup
        name: backup

Apply the values:

helm -n <your-namespace> upgrade -f values.yaml <release-name> --version <helm-chart-version> rasa-x/rasa-x

Helm chart version can be checked by executing the helm -n <namespace> list.

  1. Restore the backup
kubectl -n <your-namespace> exec rasa-x-postgresql-0 -- /bin/bash -c 'PGPASSWORD=${POSTGRES_PASSWORD} pg_restore --format=c -U postgres --dbname=rasa --exit-on-error --no-acl --no-owner --role=postgres /backup/dump_backup.bak'

The backup volume is not needed anymore and can be removed from the deployment.