SyncThing + NextCloud - how to?

I would like to use NextCloud as the “front-end” cloud solution for my devices and use SyncThing to actually sync data between 2 or 3 servers. This would be a “home” solution, not an office/enterprise solution. Just a way to move away from the popular cloud solutions.

I already use SyncThing on 3 different RPi3s which actually function as mediacenter at my home, my parents and my sisters home. Each runs SyncThing, if I store photos from a holiday on my RPi3, it is automatically synced to the other two. It works flawlessly and I have even set up a backup function on my phone Pictures folder (not the Camera folder) with the SyncThing app for Android.

But this is only “half” a solution to move away from Google Drive/Dropbox etc. I am unable to browse through my files, photos etc and download files. SyncThing is extremely good and blazing fast (P2P) at syncing, nothing else. The gap is filled by NextCloud of course. But I am uncertain how NextCloud and SyncThing can work in tandem.

What I am looking for, practically:
Basically if I want to download 1 file while not at home, I would expect to access the nextCloud webUI or app to access my files at home, browse through it, find the file and download it.
And if I want to upload something, I would want to use NextCloud webUi or app to do that. I would expect SyncThing to automatically kick in and sync that file across the 3 different RPi3s. --> so SyncThing needs to be triggered by folder changes made by NextCloud.

I assume a lot of folks already use a combination of SyncThing & NextCloud but I am a bit suprised by a lack of a clear and up to date documentation on how to do this.
Since it will run on RPi3s, I assume I need a lean and mean installation using MariaDB, PHP7 en NGINX instead of mySQL and Apache.

My RPI3s run on OSMC which is based on Debian (“Jessie upstream”).


So reading your requirements I’d say all you’d need to do is set the data directory to NC to the syncthing directory. When new files are added SyncThing will see them and replicated, similarly I believe NC runs a scan periodically to pick up files in the data dir (occ files:scan) so it could well be possible to replicate to the NC Pi too.

MariaDB and PHP7 are fine, NGINX isn’t officially supported but there are several topics about it on the forums here with example configs and such.

I only envisage permissions being a concern, since NC requires the web-user (www-data, etc) to own the files. That’s probably workable though with some thought.

1 Like

Thanks a lot for your quick feedback and recommendations!

I believe NC should only be installed on one of the RPi’s, since there would be 1 central NC server. Is this correct? SyncThing is logically installed on all of them, but this is not necessary for NC. This also means, all users will always upload/download files from 1 RPi. And NC’s library will be updated automatically when users do anything.

But what if a user does not use NC to add/remove a file to the directory? For example:
3 RPI3 servers: 01, 02, 03. NC is installed on 01. SyncThing on all three and they keep each other in sync.

What if I (user1) put a new file in the directory of server03 (either manually or via any other app than NC).
Now user2 opens NC on her phone, will she be able to see this file? Will NC (installed on server01) actually be triggered after or during the syncing process of SyncThing?

I am definitely going to test this myself. I wasn’t sure if sharing the main directory of NC and SyncThing was the only thing necessary to do.

And permissions as mentioned. I’m not sure without Googling if you need to do anything with file permissions for SyncThing, but if SyncThing is replicating files and maintaining permissions it’s all going to be owned by the webserver user by default on all Pis.

NC isn’t triggered by disk changes, though I’m sure the disk scan does run occasionally (it’s certainly not immediate). @tflidd has a giant brain and knows everything about NC from what I can see, so maybe he’ll also add to or override what I’ve said.

NC on 1 pi will be enough though.

It’s a bit tricky because you use two solutions that allow syncing. You can’t use the data directory of Nextcloud directly because Nextcloud expects to have exclusive access to it.

What you can do is to use the external storage feature where Nextcloud accepts changes by other programs. In this case you have to make sure that the sync-directory is equally writable by Nextcloud and Syncthing. When you mount external storages, you can define how often it is scanned for changes. I can’t tell you how fast the syncthing-process detects changes. I would try to mainly do my syncing through one solution.

I don’t use such a combination but there have been a few people with such solutions (also with btsync). The Nextcloud (and ownCloud) client improved a lot over the last versions so that’s perhaps the reason there are less people now.

1 Like

I have btsync dumping backups into a directory within data but also run a cronjob to fix permissions and run a occ files:scan - it’s not pretty but it’s worked.

How often will the occ files:scan run without input from a user? It does do that on a schedule doesn’t it?

For external storage you can say it should look for changes on each access. On Nextcloud’s own data-folder, it doesn’t trigger a scan. I think, a folder is rescanned when you change any file in the folder (add, delete or rename it).

1 Like

@zilexa external storage may be the way to go then :slight_smile:

Thanks @tflidd