MySQL migration

Hi,
I have configured two separate VMs for nextcloud server, configuration as below
*VM1 for server with 20GB Disk space
*VM2 for MySQL Database with 400GB Disk space
*Both are using same lan network while server (VM1) using alias Vhost as cloud.copreus.com

database connectivity seem to be successful as the details can be seen in nextcloud conf.php

My issue is when files uploaded they stored in Nextcloud server (VM1) instead of Dedicated database (VM2)

need an assist on this, hope this describes current issue, further informations can be given…

the files are not stored in the database.
they are stored in the filesystem where nextcloud is running.
(unless you define s3 object storage as primary storage.)

in the database only “metadata” are stored. (user, password, contacts, app data, etc.)

Thanks for your advice!

Is there anyway i can move my data directory to above mentioned VM2, via Wormhole or something like that? because my plan to allow VM2 to talk with VM1 only, VM1 will do the serving session with outside world.

a) you export a folder from machine vm2 via nfs. and mount it to the nextcloud data folder on machine vm1. (https://www.google.com/search?client=firefox-b-d&q=linux+setup+nfs).
pro: “easy” setup. minimal changings to your setup.
con: if machine vm1 can’t mount this nfs share temporary nextcloud will write to the local folder on machine vm1. that will give you a little mess. so in a production setup you’ll have to take some extra measure to prevent nextcloud from writing file when the folder is not mounted.

b) you install nextcloud on machine vm2. and install on vm1 only a reverse proxy.
pro: nextcloud and the database are on the same machine. (better performance). only one port needs to be opened in the firewall in front of vm2. (better security)
con: may be not what you had in mind.

Thanks a lot, i got the clues !