Syncthing is decentralized file synchronization tool. Key difference between services like Dropbox is, that data never leaves your network, unless you explicitly configure it to do so.

pros:

  • free and open source
  • flexible
  • more control over your data

cons:

  • require setup and maintenance

There can be many usecases for syncthing. For example:

  • Synchronize media among devices. For example accessing phone photos. Or removing phone files from another device.
  • Copying files from camera’s SD and making it available for everyone
  • Mirroring dot files. If you have similar environment across few devices, you can keep them aligned by synchronizing configuration.
  • Backup with versioning
  • Version control for those who refuse to use git
  • Migrating data from one device to another
  • Keeping Obsidian/Logseq notes in sync
  • etc

I have not found helm chart for that, but deployment is not super complicated. Let’s start with pvc:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: syncthing-pv-claim
  labels:
    app: syncthing
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 50Gi

then deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: syncthing
  labels:
    app: syncthing
spec:
  replicas: 1
  selector:
    matchLabels:
      app: syncthing
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: syncthing
    spec:
      nodeSelector:
      containers:
      - image: syncthing/syncthing:1.28
        name: syncthing
        resources:
          limits:
            memory: "256Mi"
            cpu: "500m"
        ports:
        - containerPort: 8384
          name: syncthing
          protocol: TCP
        - containerPort: 22000
          protocol: TCP
          name: to-listen
        - containerPort: 22000
          protocol: UDP
          name: to-discover
        volumeMounts:
        - name: syncthing-persistent-storage
          mountPath: /var/syncthing
      volumes:
      - name: syncthing-persistent-storage
        persistentVolumeClaim:
          claimName: syncthing-pv-claim

and the service

apiVersion: v1
kind: Service
metadata:
  name: syncthing-service
  labels:
    app: syncthing
spec:
  ports:
    - name: http
      port: 32080
      targetPort: 8384
      protocol: TCP
    - protocol: TCP
      port: 32000
      targetPort: 22000
      name: to-listen
    - protocol: UDP
      port: 32000
      targetPort: 22000
      name: to-discover
  selector:
    app: syncthing
  type: NodePort

Now we can access the UI using http port.

We can split the configuration into two parts: Folders and Devices.

Folder can be shared across many devices. It can work in three modes:

  • send only
  • receive only
  • send and receive

It is quite important to choose correct option for your usecase. More advanced options are ignore patterns and file versioning.

To finish basic configuration, add another device to the setup. Easiest would be install it on your phone. If you are using android, I would recommend this build: https://f-droid.org/pl/packages/com.nutomic.syncthingandroid/ . Unfortunately, recently it was removed from Google Play. The problem was with permissions. Tools like syncthing makes most sense when they have wide filesystem access. You could easly create backups of the whole device – if you know what you are doing. But Google decided that users should not give that kind of permissions to any application. When creating a folder using android app, you have a restriction what to share. For example, you can share Camera folder, but not Dowloads. But there is a hack for that. That restriction is enforced only by the “Folder picker” – gui element of the android. You can open WebUI, and edit existing folder, and share everything from your phone, by changing “DCIM/Camera” to something like “/storage/emulatd/0/DCIM”.

I understand the general idea standing behind “protecting privacy”. I can imagine someone wiping their phone by an accident. But enforcing this for power users is annoying.

3 responses to “syncthing – replication for dummies”

  1. You suggested very limited resources. Meanwhile Syncthing works way faster when provided with more fuel. In my setup of 9 devices being synchronized and around 340k files Syncthing averages on 1,8 GB of RAM. I gave it a limit of 2,8 GB. Also more CPU speeds up synchronization of multiple files at once. Common scenario when device was offline and arrives with many modified files to synchronize, so 500m also looks constraining lengthening the process.

    1. yeah, that is true, i didnt study resource utilization. but on the other hand it did not crash with out of memory yet

  2. Google Play problems are not only related to software permissions. Their increasingly enforcing general policy of use disturbs more and more private developers. According to latest changes Google Play application will have to be provided with publicly known home address and actual telephone number to developers. Enthusiast and hobbist-developers don’t necessarily want to publish their address and phone to all users, so it really seems to be directed to eliminate them and provide more space for actual companies… and this is just one of the examples of recent policy changes making Google Play unwelcoming.

Leave a Reply

Your email address will not be published. Required fields are marked *

+ ,