Nextcloud global scaling

Hi, I want to setup a nextcloud installation on two server in two different networks, where data is syncronized from time to time (mainly over night). And I don’t know how to setup this, where data is syncronized over night, but server a tells server b instantly wich files are stored on him and if someone tries to open a file on server b wich is stored on server a, server b will downloaded it and store it from server a

This functionality does not exist yet natively. See this request for mirroring Nextcloud data between two federated instances.