# How to initialize a new cluster from a S3 backup?

**URL:** <https://forums.percona.com/t/how-to-initialize-a-new-cluster-from-a-s3-backup/7987>\
**Category:** Percona Operator for MySQL\
**Created:** [September 1, 2020, 9:29am UTC](https://forums.percona.com/t/how-to-initialize-a-new-cluster-from-a-s3-backup/7987 "2020-09-01T09:29:39Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![rckrd](https://avatars.discourse-cdn.com/v4/letter/r/5fc32e/32.png) [@rckrd](https://forums.percona.com/u/rckrd)\
**Post date:** [September 1, 2020, 9:29am UTC](https://forums.percona.com/t/how-to-initialize-a-new-cluster-from-a-s3-backup/7987/1 "2020-09-01T09:29:39Z")

</div>

Hi,

How do I create a new cluster and restore it from a S3 backup? I can only find how to restore a cluster from a previously saved backup ([https://www.percona.com/doc/kubernetes-operator-for-pxc/backups.html#restore-the-cluster-from-a-previously-saved-backup](https://www.percona.com/doc/kubernetes-operator-for-pxc/backups.html#restore-the-cluster-from-a-previously-saved-backup)).

I can not find how to restore a new cluster from a S3 backup on a new k8s cluster. How can I restore if somehow a “[perconaxtradbclusterbackups.pxc.percona.com](http://perconaxtradbclusterbackups.pxc.percona.com)” resource object is lost?

I want to create a new pxc cluster and point it to a S3 backup to restore from. Is that possible?

Best regards,

Rickard

---

<div class="post-metadata">

**Author:** ![rckrd](https://avatars.discourse-cdn.com/v4/letter/r/5fc32e/32.png) [@rckrd](https://forums.percona.com/u/rckrd)\
**Post date:** [September 3, 2020, 5:14am UTC](https://forums.percona.com/t/how-to-initialize-a-new-cluster-from-a-s3-backup/7987/2 "2020-09-03T05:14:09Z")

</div>

After some more research I found a “restore-backup.sh” script in the repository. ([https://github.com/percona/percona-xtradb-cluster-operator/blob/master/deploy/backup/restore-backup.sh](https://github.com/percona/percona-xtradb-cluster-operator/blob/master/deploy/backup/restore-backup.sh)) . However, this script seem to be outdated. The restore fails when trying to restore a pxc cluster using a s3 url. The script is using a old version of the backup image: percona/percona-xtradb-cluster-operator:0.3.0-backup. The current is percona/percona-xtradb-cluster-operator:1.5.0-pxc8.0-backup.

The script fails on this line: [https://github.com/percona/percona-xtradb-cluster-operator/blob/master/deploy/backup/restore-backup.sh#L245](https://github.com/percona/percona-xtradb-cluster-operator/blob/master/deploy/backup/restore-backup.sh#L245)

`mc -C /tmp/mc cat dest/$backup_bucket/$backup_key`. “$backup\_bucket/$backup\_key” does not exist in the backups that current version of the operator creates.

Are there any plans to update this script to be compatible with the current version of the operator?

---

<div class="post-metadata">

**Author:** ![Ivan\_Pylypenko](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ivan_pylypenko/32/2452_2.png) [@Ivan\_Pylypenko](https://forums.percona.com/u/Ivan_Pylypenko)\
**Post date:** [September 8, 2020, 5:08am UTC](https://forums.percona.com/t/how-to-initialize-a-new-cluster-from-a-s3-backup/7987/3 "2020-09-08T05:08:07Z")

</div>

Hi Rickard,  
Yes, you can restore data on newly created cluster.   
All you need is a kubenetes pxc-backup object existing inside target namespace with backup path specified in status field like in [https://raw.githubusercontent.com/percona/percona-xtradb-cluster-operator/master/e2e-tests/big-data/conf/backup.yml](https://raw.githubusercontent.com/percona/percona-xtradb-cluster-operator/master/e2e-tests/big-data/conf/backup.yml).   
  
Than you need to create a pxc-restore object with reference to backup object like in&nbsp;[https://raw.githubusercontent.com/percona/percona-xtradb-cluster-operator/master/e2e-tests/big-data/conf/restore-backup.yml](https://raw.githubusercontent.com/percona/percona-xtradb-cluster-operator/master/e2e-tests/big-data/conf/restore-backup.yml)  
If everything is correct, pxc cluster will be restored from backup object.

---

<div class="post-metadata">

**Author:** ![rckrd](https://avatars.discourse-cdn.com/v4/letter/r/5fc32e/32.png) [@rckrd](https://forums.percona.com/u/rckrd)\
**Post date:** [September 9, 2020, 3:35am UTC](https://forums.percona.com/t/how-to-initialize-a-new-cluster-from-a-s3-backup/7987/4 "2020-09-09T03:35:05Z")

</div>

Thank you @IvanPylypenko! This is what I was looking for.&nbsp; &nbsp;  
Maybe this should be included in the manual?&nbsp;&nbsp;

---

<div class="post-metadata">

**Author:** ![Ivan\_Pylypenko](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ivan_pylypenko/32/2452_2.png) [@Ivan\_Pylypenko](https://forums.percona.com/u/Ivan_Pylypenko)\
**Post date:** [September 9, 2020, 9:07am UTC](https://forums.percona.com/t/how-to-initialize-a-new-cluster-from-a-s3-backup/7987/5 "2020-09-09T09:07:54Z")

</div>

@rckrd   
Could you please create a ticket for that on [https://jira.percona.com](https://jira.percona.com) ?

---

<div class="post-metadata">

**Author:** ![rckrd](https://avatars.discourse-cdn.com/v4/letter/r/5fc32e/32.png) [@rckrd](https://forums.percona.com/u/rckrd)\
**Post date:** [September 11, 2020, 4:16am UTC](https://forums.percona.com/t/how-to-initialize-a-new-cluster-from-a-s3-backup/7987/6 "2020-09-11T04:16:45Z")

</div>

I was unable to restore a backup from S3, a new backup job was created instead overwriting the values for the s3 url. I have created an issue here:&nbsp;[[K8SPXC-437] Initializing new cluster from S3 backup fails - Percona JIRA](https://jira.percona.com/browse/K8SPXC-437)

---

<div class="post-metadata">

**Author:** ![ajay](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ajay/32/5888_2.png) [@ajay](https://forums.percona.com/u/ajay)\
**Post date:** [March 24, 2022, 12:35pm UTC](https://forums.percona.com/t/how-to-initialize-a-new-cluster-from-a-s3-backup/7987/7 "2022-03-24T12:35:12Z")

</div>

Hi @Ivan_Pylypenko- followed those two links in solution and it restored and 3 pods of pxc are up but it was missing my databases that i have in backup. could you please help me here? thank you so much in advance.

---

<div class="post-metadata">

**Author:** ![Ivan\_Pylypenko](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ivan_pylypenko/32/2452_2.png) [@Ivan\_Pylypenko](https://forums.percona.com/u/Ivan_Pylypenko)\
**Post date:** [March 29, 2022, 8:13am UTC](https://forums.percona.com/t/how-to-initialize-a-new-cluster-from-a-s3-backup/7987/8 "2022-03-29T08:13:42Z")

</div>

Hi Ajay

We need some details about your setup.

1. Could you please provide logs from operator and the actual restore process?
2. Is your restore result reproducible? Like you’ve been trying to restore more than once from your backup and the target database does not come up.

---

<div class="post-metadata">

**Author:** ![ajay](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/ajay/32/5888_2.png) [@ajay](https://forums.percona.com/u/ajay)\
**Post date:** [March 29, 2022, 3:56pm UTC](https://forums.percona.com/t/how-to-initialize-a-new-cluster-from-a-s3-backup/7987/9 "2022-03-29T15:56:05Z")

</div>

Hi @Ivan_Pylypenko -below is my back.yaml file and i checked the logs for the backup job and it is taking the latest backup from s3 and creating a backup in cluster.  
`apiVersion: [pxc.percona.com/v1](http://pxc.percona.com/v1)  
kind: PerconaXtraDBClusterBackup  
metadata:

# finalizers:

# - delete-s3-backup

name: backup5  
spec:  
pxcCluster: pxc-db  
storageName: s3-us-east  
status:  
completed: “2022-03-14T-00:00:00Z”  
destination: s3://percona-backups-release-ops/backups/pxc-db-2022-03-14-00:00:00-full  
s3:  
bucket: s3://percona-backups-release-ops/backups  
credentialsSecret: pxc-db-s3-s3-us-east  
endpointUrl: [https://s3.amazonaws.com](https://s3.amazonaws.com)  
region: us-east-1  
state: Succeeded  
storageName: s3-us-east`

and upon apply this backup is creating with latest “backup5 pxc-db s3-us-east s3://percona-backups-release-ops/backups/pxc-db-2022-03-29-15:49:28-full Starting 3s”.

so, how can i point it to a specific date since it is creating the backup with latest ? please suggest me here. Thank you.  
[backuppodlogs.txt](https://forums.percona.com/uploads/short-url/t9QB4lAuAAmRHBMADzzM6MU4p56.txt) (73.0 KB)

---

<div class="post-metadata">

**Author:** ![no\_way](https://avatars.discourse-cdn.com/v4/letter/n/bb73d2/32.png) [@no\_way](https://forums.percona.com/u/no_way)\
**Post date:** [April 4, 2022, 2:36pm UTC](https://forums.percona.com/t/how-to-initialize-a-new-cluster-from-a-s3-backup/7987/10 "2022-04-04T14:36:47Z")

</div>

Hello,

I’ve same result, from new pxc cluster, when I create pxc-backup object with backup path specified in status and object in state “Succeeded” instead of a backup object with  
state “Succeeded” a new backup job is created.

backup object :

```auto
apiVersion: pxc.percona.com/v1
kind: PerconaXtraDBClusterBackup
metadata:
  name: backup1
spec:
  pxcCluster: pxc-restored
  storageName: s3-my
status:
  completed: "2022-04-04T08:58:28Z"
  destination: s3://s3-my/pxc-restored-2022-04-04-08:58:00-full
  s3:
    bucket: s3-my
    credentialsSecret: s3-my-cred
    endpointUrl: https://s3-my.net/
    region: s3my
  state: Succeeded
  storageName: s3-my

```
