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

Passwords are not re-generated when a cluster is restored. To make sure the new cluster uses the credentials from the previous cluster, apply the credentials you saved during the backup process before restoring.

Create a secret with the password values you saved when creating the backup:

juju add-secret <secret name> monitoring=<password1> operator=<password2> replication=<password3> rewind=<password4>

where <secret name> can be any name you’d like for the restored secrets.

Then, grant the secret to the PostgreSQL application that will initiate the restore:

juju grant-secret <secret name> postgresql
juju grant-secret <secret name> postgresql-k8s

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.