# Restore backup using xtrabackup

**URL:** <https://forums.percona.com/t/restore-backup-using-xtrabackup/37082>\
**Category:** Percona XtraDB Cluster 5.x\
**Created:** [March 6, 2025, 6:41pm UTC](https://forums.percona.com/t/restore-backup-using-xtrabackup/37082 "2025-03-06T18:41:51Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ALFR3D022](https://avatars.discourse-cdn.com/v4/letter/a/f08c70/32.png) [@ALFR3D022](https://forums.percona.com/u/ALFR3D022)\
**Post date:** [March 6, 2025, 6:41pm UTC](https://forums.percona.com/t/restore-backup-using-xtrabackup/37082/1 "2025-03-06T18:41:51Z")

</div>

I need to restore a backup made by xtrabackup, but I am using xtradbcluster to replicate the main database in the secondary database in an almost synchronous way. I was able to restore it to the main database using resync, but it did not replicate to the second database.

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [March 6, 2025, 9:12pm UTC](https://forums.percona.com/t/restore-backup-using-xtrabackup/37082/2 "2025-03-06T21:12:14Z")

</div>

> [@ALFR3D022](#):
>
> I was able to restore it to the main database using resync

What is “resync”?

> [@ALFR3D022](#):
>
> but I am using xtradbcluster to replicate the main database in the secondary database in an almost synchronous way

I’m confused. Can you provide a diagram of your topology?

---

<div class="post-metadata">

**Author:** ![ALFR3D022](https://avatars.discourse-cdn.com/v4/letter/a/f08c70/32.png) [@ALFR3D022](https://forums.percona.com/u/ALFR3D022)\
**Post date:** [March 6, 2025, 10:41pm UTC](https://forums.percona.com/t/restore-backup-using-xtrabackup/37082/3 "2025-03-06T22:41:57Z")

</div>

Sorry, I ended up writing it wrong, it would be “rsync”, it was the only method that worked. I saw about it in this documentation [Restore full, incremental, compressed backups - Percona XtraBackup](https://docs.percona.com/percona-xtrabackup/8.0/restore-a-backup.html).

Yes, I will make the diagram:

 ![image](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/3X/d/4/d4abf2ffa02815a9b218bd2f69dcce75e397a8fc.png)

I restored the backup from node 1, but it did not replicate the data to node 2.

 ![image](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/3X/c/5/c54dbd6d59bba04588d0faf5561679a8fc632a7b.png)

---

<div class="post-metadata">

**Author:** ![satya.bodapati](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/satya.bodapati/32/1322_2.png) [@satya.bodapati](https://forums.percona.com/u/satya.bodapati)\
**Post date:** [March 7, 2025, 1:57pm UTC](https://forums.percona.com/t/restore-backup-using-xtrabackup/37082/4 "2025-03-07T13:57:12Z")

</div>

Do I understand it correctly that you have 2 nodes PXC setup. Node A and Node B. You stopped B gracefully(I hope) and restored the backup from Node A on Node B. Then you start server on node B and expect PXC to work as before?

Please clarify if you use async replication or PXC cluster between nodes?

---

<div class="post-metadata">

**Author:** ![ALFR3D022](https://avatars.discourse-cdn.com/v4/letter/a/f08c70/32.png) [@ALFR3D022](https://forums.percona.com/u/ALFR3D022)\
**Post date:** [March 7, 2025, 2:18pm UTC](https://forums.percona.com/t/restore-backup-using-xtrabackup/37082/5 "2025-03-07T14:18:33Z")

</div>

OK, I stopped both nodes, restored the backup on node 1, and started node 1 and node 2. However, the backup did not replicate to node 2. Should I have done something else?

I am using PXC Cluster.

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [March 7, 2025, 9:57pm UTC](https://forums.percona.com/t/restore-backup-using-xtrabackup/37082/6 "2025-03-07T21:57:06Z")

</div>

> [@ALFR3D022](#):
>
> OK, I stopped both nodes, restored the backup on node 1, and started node 1

Correct. You should have started node1 in bootstrap mode (systemctl start mysql@bootstrap). This creates the cluster. You must always bootstrap the first node when starting the cluster.

> [@ALFR3D022](#):
>
> However, the backup did not replicate to node 2.

Did you configure node2 wsrep\_cluster\_address to include node1? If you do not configure node2 to connect to node1, then yea, nothing will happen.

---

<div class="post-metadata">

**Author:** ![ALFR3D022](https://avatars.discourse-cdn.com/v4/letter/a/f08c70/32.png) [@ALFR3D022](https://forums.percona.com/u/ALFR3D022)\
**Post date:** [March 7, 2025, 10:09pm UTC](https://forums.percona.com/t/restore-backup-using-xtrabackup/37082/7 "2025-03-07T22:09:17Z")

</div>

I configured it this way:

Node 1:  
#Template my.cnf for PXC  
#Edit to your requirements.  
[client]  
socket=/var/run/mysqld/mysqld.sock

[mysqld]  
server-id=1  
datadir=/var/lib/mysql  
socket=/var/run/mysqld/mysqld.sock  
log-error=/var/log/mysql/error.log  
pid-file=/var/run/mysqld/mysqld.pid  
port=3306

#Binary log expiration period is 604800 seconds, which equals 7 days  
binlog\_expire\_logs\_seconds=604800

######## wsrep ###############  
#Path to Galera library  
wsrep\_provider=/usr/lib/galera4/libgalera\_smm.so

#Cluster connection URL contains IPs of nodes  
#If no IP is found, this implies that a new cluster needs to be created,  
#in order to do that you need to bootstrap this node

wsrep\_cluster\_address=gcomm://10.48.77.227, 10.48.77.226

#In order for Galera to work correctly binlog format should be ROW  
binlog\_format=ROW

#Slave thread to use  
wsrep\_slave\_threads=8  
wsrep\_log\_conflicts

#This changes how InnoDB autoincrement locks are managed and is a requirement for Galera  
innodb\_autoinc\_lock\_mode=2

#Node IP address  
wsrep\_node\_address=10.48.77.227

#Cluster name  
wsrep\_cluster\_name=pxc-cluster

#If wsrep\_node\_name is not specified, then system hostname will be used  
wsrep\_node\_name=percona-cluster-node

#pxc\_strict\_mode allowed values: DISABLED,PERMISSIVE,ENFORCING,MASTER  
pxc\_strict\_mode=ENFORCING

#SST method  
wsrep\_sst\_method=xtrabackup-v2

* * *

Node 2  
#Template my.cnf for PXC  
#Edit to your requirements.

[client]  
socket=/var/run/mysqld/mysqld.sock

[mysqld]  
server-id=1  
datadir=/var/lib/mysql  
socket=/var/run/mysqld/mysqld.sock  
log-error=/var/log/mysql/error.log  
pid-file=/var/run/mysqld/mysqld.pid  
port=3307

#Binary log expiration period is 604800 seconds, which equals 7 days  
binlog\_expire\_logs\_seconds=604800  
######## wsrep ###############

#Path to Galera library  
wsrep\_provider=/usr/lib/galera4/libgalera\_smm.so

#Cluster connection URL contains IPs of nodes  
#If no IP is found, this implies that a new cluster needs to be created,  
#in order to do that you need to bootstrap this node  
wsrep\_cluster\_address=gcomm://10.48.77.227, 10.48.77.226

#In order for Galera to work correctly binlog format should be ROW  
binlog\_format=ROW

#Slave thread to use  
wsrep\_slave\_threads=8  
wsrep\_log\_conflicts

#This changes how InnoDB autoincrement locks are managed and is a requirement for Galera  
innodb\_autoinc\_lock\_mode=2

#Node IP address  
wsrep\_node\_address=10.48.77.226

#Cluster name  
wsrep\_cluster\_name=pxc-cluster

#If wsrep\_node\_name is not specified, then system hostname will be used  
wsrep\_node\_name=application-cluster-node

#pxc\_strict\_mode allowed values: DISABLED,PERMISSIVE,ENFORCING,MASTER  
pxc\_strict\_mode=ENFORCING

#SST method  
wsrep\_sst\_method=xtrabackup-v2

* * *

Is there something wrong that I need to fix?

It is replicating normally when I create a database and insert values. However, it does not replicate the backup.

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [March 8, 2025, 1:11am UTC](https://forums.percona.com/t/restore-backup-using-xtrabackup/37082/8 "2025-03-08T01:11:10Z")

</div>

Did you bootstrap node1? What does this show on node1 and node2? `SHOW GLOBAL STATUS LIKE 'wsrep_cluster_size'`

---

<div class="post-metadata">

**Author:** ![ALFR3D022](https://avatars.discourse-cdn.com/v4/letter/a/f08c70/32.png) [@ALFR3D022](https://forums.percona.com/u/ALFR3D022)\
**Post date:** [March 8, 2025, 1:20am UTC](https://forums.percona.com/t/restore-backup-using-xtrabackup/37082/9 "2025-03-08T01:20:43Z")

</div>

I started node 1 with ‘systemctl start mysql@bootstrap.service’ and node 2 with ‘systemctl start mysql’

It has the same value in both nodes ‘wsrep\_cluster\_size = 2’

![image](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/3X/a/f/afd4c22235a5ca5000e1e9f776d0ab60a56c5f09.png)

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [March 8, 2025, 5:31am UTC](https://forums.percona.com/t/restore-backup-using-xtrabackup/37082/10 "2025-03-08T05:31:22Z")

</div>

I would shut down node2. Erase everything in the datadir of node2. Then start node2 mysql normally. This should force an SST of the entire data set on node1 to copy to node2.

---

<div class="post-metadata">

**Author:** ![ALFR3D022](https://avatars.discourse-cdn.com/v4/letter/a/f08c70/32.png) [@ALFR3D022](https://forums.percona.com/u/ALFR3D022)\
**Post date:** [March 9, 2025, 1:13am UTC](https://forums.percona.com/t/restore-backup-using-xtrabackup/37082/11 "2025-03-09T01:13:10Z")

</div>

It worked! I deleted everything that was inside /var/lib/mysql/ and tried to start it again, it gave an error because it didn’t have the certificates from node 1, I copied them and tried to start node 2 again, it started and synchronized the data.

Thank you very much!
