Recovery from a backup¶
Recreate the cluster from a backup object¶
If we have a backup section and working backups in our cluster, the easiest way recreate a failing cnpg cluster is using a backup object.
- Choose the desired backup
To see our backups in our namespace
kubectl get backup
- Delete the cluster
Then delete the cluster
kubectl delete cluster MYCLUSTER
- Change the cluster definition
Configure the desired backup name changing the bootstrap section
spec:
bootstrap:
recovery:
backup:
name: MYWORKINGBACKUP
- Change where the new backups will be stored
Change the destination of the new backups. The recovery from backup fails is cnpg find a non empty folder. I think it is a good practice to start this new cluster storing the data in a new empty folder.
spec:
backup:
barmanObjectStore:
serverName: ANOTHERFOLDER
- Apply the new cluster
Finally apply the new cluster definition
Recover from backup using plugin¶
To create a new cluster from a backup resource created via barman plugin:
- define an external cluster as plugin
- define a bootstrap for it
- change the servername in the plugin section to a newone. The destination bucket needs to be empty
...
spec:
plugins:
- name: barman-cloud.cloudnative-pg.io
isWALArchiver: true
parameters:
barmanObjectName: mystore
serverName: NEW-ONE
bootstrap:
recovery:
source: recovery
backup: NAME_OF_BACKUP
externalClusters:
- name: recovery
plugin:
name: barman-cloud.cloudnative-pg.io
...