Restore new pxc cluster from s3 backup with restore-backup.sh

Hello,

I’ve tried to restore s3 backup to new pxc cluster with percona-xtradb-cluster-operator/deploy/backup/restore-backup.sh but I have this error :

+ mc -C /tmp/mc cat dest/mysql-operator/cluster1-2022-04-04-08:58:00-full
+ xbstream --decompress -x -C /datadir
mc: <ERROR> Unable to read from `dest/mysql-operator/cluster1-2022-04-04-08:58:00-full`. Object does not exist.

After some research I’ve modified restore-backup.sh and now it restore backup from s3 to new pxc cluster but I’ve new error when start_pxc() it’s called :

Error from server (Conflict): error when applying patch:
{"metadata":{"creationTimestamp":"2022-04-04T09:25:57Z","resourceVersion":"1001431717","uid":"8c2494d9-60db-4462-a9b5-cc04fe874880"},"status":{"conditions":[{"lastTransitionTime":"2022-04-04T09:25:57Z","status":"True","type":"initializing"},{"lastTransitionTime":"2022-04-04T09:28:36Z","status":"True","type":"ready"}],"haproxy":{"ready":3,"status":"ready"},"pxc":{"image":"percona/percona-xtradb-cluster:8.0.23-14.1","ready":3,"status":"ready","version":"8.0.23-14.1"},"ready":6,"state":"ready"}}
to:
Resource: "pxc.percona.com/v1, Resource=perconaxtradbclusters", GroupVersionKind: "pxc.percona.com/v1, Kind=PerconaXtraDBCluster"
Name: "cluster1-restored", Namespace: "xtradb-from-scratch"
for: "/tmp/tmp.Q8F945epbH/cluster.yaml": Operation cannot be fulfilled on perconaxtradbclusters.pxc.percona.com "cluster1-restored": the object has been modified; please apply your changes to the latest version and try again
1 Like

Hello @no_way ,

this script percona-xtradb-cluster-operator/deploy/backup/restore-backup.sh was created long before our operator supported restore operation. It is heavily outdated.

We recommend to use the restore custom resource for restoration. See more details here: Providing Backups

In short you just need to create a restore manifest. An example of it you can find in percona-xtradb-cluster-operator/deploy/backup/restore.yaml

apiVersion: pxc.percona.com/v1
kind: PerconaXtraDBClusterRestore
metadata:
  name: restore1
spec:
  pxcCluster: cluster1
  backupName: backup1
#  pitr:
#    type: latest
#    date: "yyyy-mm-dd hh:mm:ss"
#    gtid: "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:nnn"
#    backupSource:
#      storageName: "STORAGE-NAME-HERE"
#      s3:
#        bucket: S3-BINLOG-BACKUP-BUCKET-NAME-HERE
#        credentialsSecret: my-cluster-name-backup-s3
#        endpointUrl: https://s3.us-west-2.amazonaws.com/
#        region: us-west-2
1 Like

Hello @Sergey_Pronin ,

Yes for PerconaXtraDBClusterRestore but my data are in s3 storage, how I can restore new cluster from s3 ?

thanks :slight_smile:

1 Like

If this backup was created by our Operator - you can still use PerconaXtraDBClusterRestore object.

You can read more about it here: Providing Backups
You will need to specify backupSource:

...
backupSource:
  destination: s3://S3-BUCKET-NAME/BACKUP-NAME
  s3:
    credentialsSecret: my-cluster-name-backup-s3
    region: us-west-2
    endpointUrl: https://URL-OF-THE-S3-COMPATIBLE-STORAGE
...

If this backup was created by some other tooling - PerconaXtraDBClusterRestore might work if you follow the process described in this blog post: Migrating Into Kubernetes Running the Percona Distribution for MySQL Operator - Percona Database Performance Blog

Otherwise, use regular restoration process by connecting to MySQL endpoint (expose the database with Operator and perform a regular restore).

1 Like