# Restoring master from slave

**URL:** <https://forums.percona.com/t/restoring-master-from-slave/7156>\
**Category:** Percona XtraBackup\
**Created:** [August 13, 2019, 12:33am UTC](https://forums.percona.com/t/restoring-master-from-slave/7156 "2019-08-13T00:33:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yonjah](https://avatars.discourse-cdn.com/v4/letter/y/cdc98d/32.png) [@yonjah](https://forums.percona.com/u/yonjah)\
**Post date:** [August 13, 2019, 12:33am UTC](https://forums.percona.com/t/restoring-master-from-slave/7156/1 "2019-08-13T00:33:54Z")

</div>

Hi.  
I’m in the process of setting up a disaster recovery procedure and I want to verify the process.

I’ve read [url][https://www.percona.com/forums/questions-discussions/percona-xtrabackup/42885-restore-master-from-slave-backup[/url]](https://www.percona.com/forums/questions-discussions/percona-xtrabackup/42885-restore-master-from-slave-backup%5B/url%5D)  
which contains some very useful information but since promoting the current Slave is not an option I’ll want to clone the slave to a new server and promote it to be the master. The existing slave should be changed to replicate data from the new master.

Here is how my setup should look like -  
Server A - Master  
Server B - Slave of Server A  
Server C - empty

If server A crash and burnes. Since it is completely offline the current state of Server B is the latest state.  
recovery steps are -

1. Stop slave on Server B
2. Use xtrabackup to clone data from Server B to C.
3. Change master on server B to point to the current binlog file and position of server C.
4. Start Slave on Server B

So After Restore -  
Server A - Decommissioned  
Server B - Slave of Server C  
Server C - Master

Does this process makes sense ?  
Is there any step I’m missing when getting the backup from the slave or changing the master?

- I do scheduled backups of the master data and binlog to allow point in time restore, but in case of a real disaster I assume the slave will hold the most up to date data

---

<div class="post-metadata">

**Author:** ![yonjah](https://avatars.discourse-cdn.com/v4/letter/y/cdc98d/32.png) [@yonjah](https://forums.percona.com/u/yonjah)\
**Post date:** [August 29, 2019, 7:40pm UTC](https://forums.percona.com/t/restoring-master-from-slave/7156/2 "2019-08-29T19:40:05Z")

</div>

So after doing a bit of testing with mock data and servers the process described seem to be working OK.

The only thing anyone trying to do the same need to notice is after deploying a backup done with xtrabackup the deployed server (New Master)  
starts with a blank binary log, so to get the slave syncing with the new master all that is needed is to reset the slave and point it to the new master -  
reset slave all;  
change master to MASTER\_HOST=“SERVER\_C\_IP”, MASTER\_USER=“repl\_user”, MASTER\_PASSWORD=“repl\_user\_password”;  
start slave;

After running the above on the slave it will start syncing from the newly created clone.
