How to migrate a cluster

vmk8s

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

See How to restore a local backup to perform a basic restore from a local backup

Prerequisites


Apply cluster credentials

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/leader set-password username=operator password=<previous cluster password> 
juju run postgresql/leader set-password username=replication password=<previous cluster password> 
juju run postgresql/leader set-password username=rewind password=<previous cluster 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/leader list-backups
juju run postgresql-k8s/leader list-backups

Take note of the backup-id that corresponds to the previous cluster.

Restore backup

To restore your current cluster to the state of the previous cluster, the restore command with your backup-id:

juju run postgresql/leader restore backup-id=YYYY-MM-DDTHH:MM:SSZ
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 cluster will represent the state of the previous cluster.