I want to share my experience deploying Syncthing in a “large” environment. First let me say that I consider large to be when manually deploying is unmanageable. In my case I have 104 Windows nodes, for me large enough to try to make the deployment as automatic as possible. I’m not fully there but it is near.
I maintain a series of classrooms/labs for education, with each classroom about 20 machines. All computers are joined to a domain. Workstation’s OS is Win 10 Enterprise. Our network is “slow”, only 100Mbs and we have a file server that works as central storage for the network. Central storage consists mainly of big files (3-9 GB) and it’s about 1TB large. We have to transfer big files quite usually and at the same time (for example at first hour students have to grab a copy of one or more VMs for that day practice) and it can take a long time to make the copy over the network.
I soon realized that it is better to have a local copy of the repository and our computers have a large second hard drive where I can store it, so I thought I could give Syncthing a try. Maybe other solutions (i.e. rsync or similar) could have worked too, but Syncthing has it’s advantages, so I went for it.
I setup Syncthing in our file server in master mode as I don’t want loose control over our repository content. This is an old Windows Server 2008 connected to an old SAN. Given it’s age, I don’t think it can handle too many connections with so many files so I setup one computer in each class that connects to this master (six in total). I used the teacher’s computer of each class for that. Luckily I don’t have to share all the repository, only a part of it (about 200-300 GB) because it takes about 45 minutes to the server to scan this files. Although it takes this long only the first time, when it have to create indexes. Periodic scanning (without changes) is done in 2-3 seconds or less. Which files are shared is selected through .stignore file.
I’m going to skip a big part of my efforts, as I spent a large amount of time trying to figure out how Syncthing works in a very detailed way. I made a lot of errors and tried many things.
Finally I decided that the best approach, as someone said in the forums, was to make small clusters, so I shared the teachers’s computers with all the computers in all classrooms and maintain the rest of computers shared only with their respective classrooms (and all teacher’s computers of course). This way I have small clusters but interconnected. It is yet to see if this is the best approach. I have not still enough runtime.
My best finding was to realize that Syncthing installations can share same configuration file (share in the sense that identical files are installed in multiple computers, not synced). My work process is approximately as follows:
- Download the last version of Syncthing and expand it. Rename the folder to Syncthing
- Download the nssm executable and copy to the Syncthing folder
- Install a Syncthing “model” and set configuration as we want in the computers, with the shared folder, web UI password, etc. Save configuration file for later.
- Then I can run my script to install Syncthing in all the computers. The script will:
- Use Robocopy.exe to copy the Syncthing folder via network to all computers (C:\Program Files\Syncthing).
- Use psexec from Microsoft Sysinternal utilities to execute a script in the remote computer that will install Syncthing as a service (through nssm) and start the service.
- Wait a few seconds, stop the service and copy back the created config file (C:\Program Files\Syncthing\config.xml) to a network folder. Destination name is personalised (config-%computername%.xml)
- Create the shared folder and set appropriate permissions so only admins can modify and normal users have read only permissions.
Then I have to collect all device IDs that are have been created. This step is yet the only to be automatised. I use the model configuration file that I created earlier. With that file and the collected device IDs (conveniently separated by classes) I create manually the different classrooms config files and one config file for teachers computers. One computer knows and shares the folder to the same classroom’s computers and all the teacher’s computers. Teacher’s computers knows and shares with ALL computers. To be more specific, I have to collect the
<device ID="XXX" > ... </device>part (3 lines). When generating the config files, I copy all the necessary 3-lines part so the computer knows other computers and generate a
<device ID="XXX"></device>line in the shared folder part so the shared folder is shared with that computer. This part can be a little tedious but in theory has to be done only once.
And finally I run another script that will:
- Copy the appropriate config file to every computer.
- Start the service (To start and stop services I use sc tool)
And that’s all. With this “large” installation the only problems that have arise are some inconsistencies when I have made certain modifications to the shared folder in different computers (being that computer at that moment the only switched on computer). Later when I have switched on all computers the incompatible changes seems to have been floating around the computers like a ghost (gosh! that was an “interesting” day until I realized was going on). So I recommend making changes to the shared folder in a consistent manner. Not too many changes at a time and sync all computers before making more changes.
I don´t claim that this is the best way to do it, but I think it can be useful to others that can be in a similar position.
Many thanks to Syncthing developers and I will answer questions or clarify some points if necessary.