Skip to content

Upgrade using backup and restore

This method allows you to migrate from the version 1.x to version 2.x cluster by restoring (actually creating) a new version 2.x PostgreSQL cluster using a backup from the version 1.x cluster.


To make sure that all transactions are captured in the backup, you need to stop the old cluster. This brings downtime to the application.

Prepare the backup

  1. Create the backup on the version 1.x cluster, following the official guide for manual (on-demand) backups. This involves preparing the manifest in YAML and applying it in the ususal way:

    $ kubectl apply -f deploy/backup/backup.yaml
  2. Pause or delete the version 1.x cluster to ensure that you have the latest data.


    Before deleting the cluster, make sure that the spec.keepBackups Custom Resource option is set to true. When it’s set, local backups will be kept after the cluster deletion, so you can proceed with deleting your cluster as follows:

    $ kubectl delete perconapgcluster cluster1

Restore the backup as a version 2.x cluster

Restore from S3 / Google Cloud Storage for backups repository

  1. To restore from the S3 or Google Cloud Storage for backups (GCS) repository, you should first configure the spec.backups.pgbackrest.repos subsection in your version 2.x cluster Custom Resource to point to the backup storage system. Just follow the repository documentation instruction for S3 or GCS. For example, for GCS you can define the repository similar to the following:

          - name: repo1
              bucket: MY-BUCKET
              region: us-central1
  2. Create and configure any required Secrets or desired custom pgBackrest configuration as described in the backup documentation for te Operator version 2.x.

  3. Set the repository path in the subsection. By default it is /backrestrepo/<clusterName>-backrest-shared-repo:

            repo1: /backrestrepo/cluster1-backrest-shared-repo
  4. Set the spec.dataSource option to create the version 2.x cluster from the specific repository:

          repoName: repo1

    You can also provide other pgBackRest restore options, e.g. if you wish to restore to a specific point-in-time (PITR).

  5. Create the version 2.x cluster:

    $ kubectl apply -f cr.yaml

Get expert help

If you need assistance, visit the community forum for comprehensive and free database knowledge, or contact our Percona Database Experts for professional support and services. Join K8S Squad to benefit from early access to features and “ask me anything” sessions with the Experts.

Last update: 2023-12-08