Back Up and Restore PostgreSQL Snapshots
Use the existing PostgreSQL snapshot from your source Virtual Appliance to perform a backup and restore operation on the destination Virtual Appliance. This process will delete the existing Persistent Volume Claims (PVCs) on the destination Virtual Appliance and replace them with the data from the source Virtual Appliance.
Back Up a PostgreSQL Snapshot
- Log in to the source Virtual Appliance and run this command:
- Create a new snapshot.
appdcli run pg_backup create-snapshot repo3Sample Output:create-snapshot started. Status='backup-20251017062950'To view the details of the backup file, run this command:
kubectl get pg-backup -n postgresSample Output:NAME CLUSTER REPO DESTINATION STATUS TYPE COMPLETED AGE appd-postgres-backup-nh8b-x4m6z appd-postgres repo1 Succeeded full 5d13h 5d13h backup-20251017062950 appd-postgres repo3 Succeeded incr 3m58s 4m8sNote: Do not delete the PVCs in the source Virtual Appliance. - Verify whether the PostgreSQL pods are running in the source Virtual Appliance.
kubectl get pods -npostgresSample Output:NAME READY STATUS RESTARTS AGE appd-postgres-backup-vnml-db8nj 0/1 Completed 0 11m appd-postgres-instance-8689-0 4/4 Running 0 5d13h appd-postgres-instance-lk4k-0 4/4 Running 0 5d13h appd-postgres-instance-m6c2-0 4/4 Running 0 5d13h appd-postgres-pgbouncer-b98d7d6b-4f5gp 2/2 Running 0 5d13h appd-postgres-pgbouncer-b98d7d6b-bxcmg 2/2 Running 0 5d13h appd-postgres-pgbouncer-b98d7d6b-wprx4 2/2 Running 0 5d13h appd-postgres-repo-host-0 2/2 Running 0 5d13hA default folder is created at /mnt/nfs_share on the NFS server.
- Create a new snapshot.
- Log in to the NFS server and view the backup files.
/mnt/nfs_share# ls -ltrSample Output:
drwxrwxrwx 4 root root 4096 Oct 11 16:26 postgres-appd-postgres-repo3-pvc-576f9c74-c24b-4e2d-9768-8185127ea2d7To view the contents in the backup file, run this command:ls -ltr <Backup-of-PostgreSQL-Folder-VA>Sample Output:drwxr-x--- 3 26 tape 4096 Oct 11 17:19 archive drwxr-x--- 3 26 tape 4096 Oct 11 17:19 backup
Restore a PostgreSQL Snapshot
- Log in to the destination Virtual Appliance and run this command:
appdcli run pg_backup create-snapshot repo3Sample Output:create-snapshot started. Status='backup-20251017062951' - Log in to you NFS server and copy the backup file from your source Virtual Appliance:
- Remove the backup file contents on your destination Virtual Appliance.
rm -rf <Backup-of-PostgreSQL-Folder-Destination-VA>/* - Copy the source Virtual Appliance backup file contents to destination Virtual Appliance.
cp -r <Backup-of-PostgreSQL-Folder-Source-VA>/* <Backup-of-PostgreSQL-Folder-Destination-VA> - Update the access and owner permissions for the backup file of the destination Virtual Appliance.
You can verify the file contents of the copied backup file on the NFS server and Kubernetes Cluster.chmod g+rw <Backup-of-PostgreSQL-Folder-Destination-VA> -R chown 26:26 <Backup-of-PostgreSQL-Folder-Destination-VA> -Rkubectl exec -it appd-postgres-repo-host-0 -npostgres -c pgbackrest -- ls -ltr pgbackrest/repo3/backup/dbSample Output:total 8 drwxrwx--- 3 postgres postgres 4096 Oct 11 17:19 archive drwxrwx--- 3 postgres postgres 4096 Oct 11 17:19 backup
- Remove the backup file contents on your destination Virtual Appliance.
- Log in to the destination Virtual Appliance console.
- Pause the
percona pgcluster.kubectl patch perconapgcluster appd-postgres -n postgres --type='merge' -p '{"spec":{"pause":true}}' - Delete PVCs in the PostgreSQL.
kubectl delete pvc -n postgres -l postgres-operator.crunchydata.com/data=postgres - Restore the PostgreSQL snapshot.
appdcli run pg_backup restore-snapshot repo3 - Resume the
percona pgcluster.kubectl patch perconapgcluster appd-postgres -n postgres --type='merge' -p '{"spec":{"pause":false}}' - Verify the pods to check the PostgreSQL instance.
kubectl get pods -npostgresSample Output:
NAME READY STATUS RESTARTS AGE appd-postgres-backup-nh8b-t6qmc 0/1 Completed 0 19m appd-postgres-instance-8689-0 4/4 Running 0 90s appd-postgres-instance-lk4k-0 4/4 Running 0 90s appd-postgres-instance-m6c2-0 4/4 Running 0 96s appd-postgres-pgbouncer-b98d7d6b-4f5gp 2/2 Running 0 96s appd-postgres-pgbouncer-b98d7d6b-bxcmg 2/2 Running 0 96s appd-postgres-pgbouncer-b98d7d6b-wprx4 2/2 Running 0 96s appd-postgres-repo-host-0 2/2 Running 0 2m3s
Note: After restoring PostgreSQL on the destination Virtual Appliance, the Controller UI will display the data from that Virtual Appliance. Log in to the Controller UI to verify that it displays the correct data. To redirect traffic to the destination Virtual Appliance from the source Virtual Appliance, perform the cutover steps. - Pause the