You're going the wrong way about this. What you want to achieve is some sort of HA (high availability). I suggest you look into HAproxy. With its simple configuration, that's all you really need, there are plenty of tutorials out there.
You can have two servers as the backends, and they can even share the load between themselves. You sync the files that can be synced without locking (for example non-db stuff) with lsync.
In case you're not hosting WWW stuff with the servers, but need high availability, HAproxy can also load balance plain old TCP connections, it has various modes of operation.
- Place the two servers behind the load balancer
- Create a master-master replication between the two DB instances if possible (IE, if you're talking about MySQL), or a simple master-slave, where you can promote the slave whenever necessary. The DB is always in sync.
- Sync the non-db files realtime with Lsync. Since you mentioned Cloudflare, it probably is web-based.
I'm using HAproxy a lot, and it's a brilliant piece of software, simple to configure and very robust. This is the best way to go with it. Take a look at this simple tutorial at Digitalocean to see what it's all about.