My development environment usually consists of a host machine running Windows and a development Linux “headless” virtual machine. I create and edit
files in a Notepad++ text editor and then transfer them over to the Linux VM. Until recently I’ve been using a hypervisor-enabled “shared” folder. However, Windows file system emulators in Linux do not support symbolic links
and therefore breaks a lot of applications that rely on them. This prompted me to start looking for a new way to sync my files. That’s how I came across this new amazing
file syncing app called Syncthing. Why is it amazing?
It uses peer-to-peer architecture. User traffic is not uploaded to a centralised server and is transferred directly between peers.
It is open-source. It doesn’t use any proprietary syncing protocols like BTSync.
As the result of open-source nature it has big community support with clients, wrappers and extension available for any major platform.
It is secure. All transfers are TLS-encrypted.
It’s simple to use. Windows version installs like any other Windows app, Linux version, like any other Linux app, will take a little tinkering.
It’s written in Golang, an extremely popular language amongst professional programmers and surely these guys can’t be mistaken.
Windows installation is extremely easy. I use a package called SyncTrayzor which contains the application itself, serves as a tray utility wrapper and also implements “inotify” which allows for file on-change synchronisation (BGP ip next-hop tracking anyone?)
Ubuntu package installation is an easy 4-step process:
# Choose the latest release for your platform$ wget https://github.com/syncthing/syncthing-inotify/releases/download/v0.6.5/syncthing-inotify-linux-amd64-v0.6.5.tar.gz
# Unpack and copy inotify to the same directory as the main app$ tar xvf syncthing-inotify-linux-amd64-v0.6.5.tar.gz
$ which syncthing
$ mv syncthing-inotify /usr/bin/
# Create a file for main service$ echo"start on starting network-servicesstop on stopping network-servicesenv STNORESTART=yesrespawnenv HOME=/rootexec /usr/bin/syncthing" >> /etc/init/syncthing.conf
# Do the same for inotify$ echo"start on starting syncthingstop on stopping syncthingenv STNORESTART=yesrespawnenv HOME=/rootexec /usr/bin/syncthing-inotify" >> /etc/init/syncthing-inotify.conf
# start both services $ service syncthing start && service syncthing-inotify start
4. Update Syncthing configuration file
# Update the default Sync directory to match your dev environment# using the correct device IDs$ head -n 10 ~/.config/syncthing/config.xml
# Add peer device's ID to the same file$ cat ~/.config/syncthing/config.xml
# restart both syncthing services$ service syncthing restart && service syncthing-inotify restart
Finally, Windows service can be configured similarly via Syncthing Tray. End result is that files are replicated between the two folders with a delay of just a few seconds
$ touch /root/tdd_ansible/testfile
$ tail -n 3 /var/log/upstart/syncthing*
==> /var/log/upstart/syncthing-inotify.log <==[OK] 01:45:04 Watching ansible-blog: /root/tdd_ansible
[OK] 01:45:04 Syncthing is indexing change in ansible-blog: [.stfolder][OK] 01:46:16 Syncthing is indexing change in ansible-blog: [testfile]==> /var/log/upstart/syncthing.log <==[TLARX] 01:41:25 INFO: Established secure connection to DEVICE-ID at 192.168.X.Y:22000-192.168.X.Z:53007
[TLARX] 01:41:25 INFO: Device DEVICE-ID client is "syncthing v0.11.10"[TLARX] 01:41:25 INFO: Device DEVICE-ID name is "NETOP-DESKTOP"