Synchronisation between 1 online nextcloud server and 1 Raspberry nextcloud server

I work for a NGO dedicated to digital education in Africa. We equip schools with Raspberry in wich there are content for teachers.
We want to use Nextcloud to collect and distribute courses coming from teachers.

  • An online Nexcloud is dedicated to teachers who agree to give their courses to african teachers.
  • A Nextcloud in Raspberry PI contain a copy of the online one. It allows african teachers to access the courses in schools without internet.
    So we need to create a procedure that copy content from online Nextcloud to Raspberry Nextcloud.

What is the best way to do it :

  • using federation beetwin 2 servers (but raspberry server has no URL neither static IP adress)
  • write a procedure to copy the data directories and the database (for example with rsync)
  • use an android device as gateway : the app nextcloud first dowload the data when connected to online server, then upload the content when connected to Raspberry.
  • other

Thanks a lot.

how often you have to do this?

once per week? i would mount the online server via webdav to the raspys and copy the folder via webgui.

once per hour? i would use and extend my ansible playbook.

  • make the rasby to a
  - curl -s | /bin/bash
  - HOME=/root ansible-pull --clean --force -d /root/nextcloud -i 'nextcloud' -U nextcloud.yml -e "dhparam_numbits=1024" -e "ssl_certificate_type='`selfsigned'" -e "install_onlyoffice=false"

at first boot and

  • modifiy the playbook to restore your data instead of doing a first setup.

Thanks for your answer.
It will be once a month : someone go in the school and connect the Raspberry with its smartphone.
I’m going t see how to do it with Webdav.
But I think we will also need to export and import the MySQL database.

mount external storage as admin → nextcloud

and copy a complete folder on the file page.

the database is not needed since you copy the via nextcloud commands. it would be wrong to copy the database. all local settings of the raspis would be lost. (e.g. the external mount to the online repo as well.)

Greate. I didn’t instal External Storage App, I’ve just do it, now I understand. Thanks a lot Reiner !

It works very fine. I also mounted the nextcloud server on my PC. Incredible !

Another question : if I want to copy a directory already existing, it doesnt’t work.
Is it possible to copy a directory already existing and then it copy only new files ? It would be usefull to make an update of the directory.


Hi all. Here is the full solution.

To synchronise directories of two NC servers , for example to make NC2 get a copy of NC1 :
On NC1 you activate “external storage” and allow sharing of directories by users.
On NC2, ditectly on linux,

  • with davfs2 / mount.davfs , you mount the directory of NC1
  • with rsync you synchronise this directory with the files directory of the user of NC2 (/var/www/nextcloud/data/user/files/directory)
  • with command “occ files:scan” you rescan the files of this user so that they appear in NC

In this way it is very simple and works fine.