this is the first time, that I have a problem with nextcloud, that I can’t address myself.
I want to mirror two instances of nextcloud on two different hardware servers in two different locations. Is this possible and in which way should I do this. Is federated cloud the right way or is there a different approach, that makes this easier to achieve?
I agree that this is super important! It does not exist for us basic users at this time.
Your current best bet is to use Rclone to mirror your webdav data directory to another machine via rsync. Borg Backup has been scripted by some to help automate this process.
Back in Nextcloud 12 it was announced that Global Scale architecture would be deployed to help scale up for large user case scenarios, but should be deployable on a minimum of two machines. This is designed for enterprise use, but it would address the kinds of questions you have for balancing between multiple servers. Not all of it has been implemented or documented so it is still more of a conceptual white paper.
The Global Site Selector (GSS) acts as a central instance that is accessed by the user during the first login, accessing it via the Web, WebDAV or REST. The GSS authenticates the user via the central user management like for example LDAP. It then looks up the node where the user is located in the lookup server and redirects the user to the right hostname. The following calls during the same session are done directly from client to the node.
The lookup server stores the physical location of a user. It can be queried using a valid user id to fetch the federated sharing id of a user. In some situations, it is important to limit queries to a certain IP space to avoid data leaks. It also keeps track of old federated sharing IDs. The lookup server stores additional data of the users like for example the required QoS metrics like storage/quota settings, speed class, reliability class and so on.
The Balancer runs on a dedicated machine, monitoring the various nodes and their storage, CPU, RAM and network utilization. It can mark nodes as online or offline and initiate the migration of user accounts to different nodes based on data in the Lookup Server like business or legal requirements, QoS settings or user location. If for example, a user would move from the US to Europe, the Balancer would initiate a migration from their data to an EU data center to improve the quality of service.
I’m still of the mind that a truly useful mirroring solution for NC will be at an API level, with the mirroring servers understanding the idea of a file being (in process of being uploaded/locked/edited/…) that is not yet available on the local copy of the NC install, or one that has been deleted and therefore should be moved locally to the deleted items folder, etc… There would need to be some checks around space per server etc., but an approach like this allows branch office installs for fastest local performance, as well as hybrid cloud/local hardware solution to keep bandwidth loads separated.
This approach also provides for an ideal DR/BC solution; an office goes down, the NC resource is still available elsewhere.
I want to mirror my nextcloud in a second location, because of a really small internetconnection there. It has only 2 mib/s, so it is really slow, for normal operation. Therefore the second nextcloud-server should be in the local net just to have all data in faster access. The time for mirroring is not so relevant, because this can happen over night.
A second argument is hardware problems. A second instance helps me, to have access even in case of a hardware outage. I have a backup of all cloud data, but the time to reinstall the cloud is also relevant and this time could be eliminated, when there is a second instance of the cloud, that can be used as fallover server.
There is a command line Nextcloud client that can be used to have the local server (slow connection) act as a client also. It’s far from ideal of course but I think it could be setup with a script to launch it during night hours only.
But that is just a work around. A more robust way of mirroring files would be good to have for sure.
I do not believe any of the issues we’ve discussed have changed at all in the last year. There are a lot of good suggestions above.
The sacrilege model would be to switch over to Filestash, which does not include built-in syncing on purpose and is super light weight. You would then mirror all of your storage between multiple locations via Syncthing.
Filed a request here tp see if the OCM-API has any future plans for development of Nextcloud Federation since it hasn’t been updated since 2017.
I’ve read about people using DRDB for replicating iSCSI targets. Seems to me you could replicate the block device(s) storing the web root and data folders, and cluster the SQL DB on non-replicated storage… Purely theoretical. I have no idea if that would work in practice.