Charmed PostgreSQL K8s

Channel Revision Published Runs on
latest/stable 20 20 Sep 2022
Ubuntu 20.04
14/stable 193 13 Mar 2024
Ubuntu 22.04
14/candidate 193 31 Jan 2024
Ubuntu 22.04
14/beta 211 13 Mar 2024
Ubuntu 22.04
14/edge 237 16 Apr 2024
Ubuntu 22.04
juju deploy postgresql-k8s --channel 14/stable
Show information

Platform:

How to migrate a cluster

This is a guide on how to restore a backup that was made from a different cluster, (i.e. cluster migration via restore).

To perform a basic restore (from a local backup), see How to restore a local backup

Note: All commands are written for juju >= v.3.0

If you are using an earlier version, be aware that:

  • juju run replaces juju run-action --wait in juju v.2.9
  • juju integrate replaces juju relate and juju add-relation in juju v.2.9

For more information, check the Juju 3.0 Release Notes.

Prerequisites

Restoring a backup from a previous cluster to a current cluster requires:

  • A single unit Charmed PostgreSQL deployed and running
  • Access to S3 storage
  • Configured settings for S3 storage
  • Backups from the previous cluster in your S3 storage
  • Passwords from your previous cluster

Manage cluster passwords

When you restore a backup from an old cluster, it will restore the password from the previous cluster to your current cluster. Set the password of your current cluster to the previous cluster’s password:

juju run postgresql-k8s/leader set-password username=operator password=<previous cluster password>
juju run postgresql-k8s/leader set-password username=replication password=<previous cluster password> 
juju run postgresql-k8s/leader set-password username=rewind password=<previous cluster password>

List backups

To view the available backups to restore, use the command list-backups:

juju run postgresql-k8s/leader list-backups

This shows a list of the available backups (it is up to you to identify which backup-id corresponds to the previous-cluster):

backups: 
      |backup-id           | backup-type  | backup-status
      ----------------------------------------------------
      YYYY-MM-DDTHH:MM:SSZ  | physical     | finished
      

Restore backup

To restore your current cluster to the state of the previous cluster, run the restore command and pass the correct backup-id to the command:

juju run postgresql-k8s/leader restore backup-id=YYYY-MM-DDTHH:MM:SSZ 

Your restore will then be in progress. Once it is complete, your current cluster will represent the state of the previous cluster.