Is there a way to perform the following under Linux:
- There are two web servers, main and backup
- There are two database servers (postgres), main and backup
- Web Servers are in sync with each other, ie. configuration/content/applications are the same
- Backup database is continuously synced up with main database.
- If either of main servers goes down, it's being replaced with backup one on the fly.
- When main database server goes back up, all the data from backup server is uploaded to it.
To make it more complex, an important detail is that the two servers are actually VPS and they are hosted in different countries by diferent providers, so none of the obvious solutions for servers in the same subnet/rack etc are going to work here.
Essentially, I need the hot swapping working automatically with no or minimal user intervention, if possible. Recovery procedure is preferably automatic but can include some manual steps.