In my environment we have 500 users so I want to deploy two servers; one server (such as the main server) will host the web server and database, and another server as a backup, in case the main server goes down.
I’ve been searching, but can’t find any information regarding implementing a backup server.
Hello and welcome to the NC-community-forum where everyone tries to help everybody else…
a bit of searching the forum for similar problems/tasks ahead of opening just another thread would have been nice and helpful. Like you might have found this existing thread (linked to several other threads) for the same question: Mirroring of two nextcloud server
That’s regarded being a professional demand and no more homeuser-setup. So first and foremost you should apply for a quote from NC GmbH for professional support.
But you’re free to ask your questions here on the forum as well, of course. But most probably you won’t find much ppl with a setup like yours.
You could probably synchronize the web server config, the application folder, and configuration files (config.php) via rsync from one server to the other, but that’s where it stops beeing simple. For true high availability, which is the only thing that makes sense in this context imho, you also need to scale out the database (Keyword Galera Cluster) and use a distributed file system like CEPH, GlusterFS or maybe S3 for data storage.
The following links describe broadly how such a cluster could be structured:
I wouldn’t have thought this would be too difficult, provided you were only using the one as a backup. In basic terms, you would need to place the database on a third device. So, 3 servers in all.
Main server connects to database and syncs files one way to the backup server, for example the last 8 hours of files.
This could be scripted and completed with an occ files:scan --all.
If needed, the Primary could be taken off line and the backup server could come online, connecting to the same database on the third server.
Obviously, there are a few other considersations in DNS,etc. but in theory this should work okay.
I would probably dockerize this as well, it would reduce the amount of changes you would need to make between the servers by replicating the docker on the backup machine and changing some of the settings unique to the backup server. unRaid would make it really easy.