Sync Files Between Devices With Ignore List

OneDrive, iCloud, Dropbox all them lack ability to ignore folders like node_modules, but there is Resilio Sync which has IgnoreList feature which might solve that issue

In my case I'm syncing between desktop PC and macbook, so most of the time one of them is turned off, which makes things little bit harden

Sync can be run as a docker container described here

Which allows me to have something like:

When everyone online:

%0 server server laptop laptop server->laptop desktop desktop server->desktop laptop->desktop

And usually when just one device is online:

%0 server server laptop laptop server->laptop desktop desktop

But when desktop will be turned on it will catch up all changes.

Whenever you are adding directory to sync inside it there is .sync/IgnoreList note that it is not synced and should be edited on each machine

So if you wish to ignore node_modules from being synced you need to add it to all thre machines

And here is what I ended up with for deployment:

---
apiVersion: v1
kind: Namespace
metadata:
  name: sync
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: sync
  namespace: sync
  labels:
    app: sync
data:
  sync.conf: |
    {
      "device_name": "cub",
      "listening_port": 30555,
      "shared_folders": [
        {
          "secret": "xxxxxxxxxxxxxxxxxxx",
          "dir": "/mnt/sync/folders/data",
          "use_relay_server": true,
          "use_tracker": true,
          "search_lan": true,
          "use_sync_trash": true,
          "overwrite_changes": false,
          "selective_sync": false
        }
      ]
    }
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: sync
  namespace: sync
  labels:
    app: sync
spec:
  replicas: 1
  selector:
    matchLabels:
      app: sync
  template:
    metadata:
      labels:
        app: sync
    spec:
      containers:
        - name: sync
          image: resilio/sync:2.7.2
          ports:
            - containerPort: 30555
          volumeMounts:
            - name: sync
              mountPath: /mnt/sync/sync.conf
              subPath: sync.conf
            - name: data
              mountPath: /mnt/sync/folders/data
      volumes:
        - name: sync
          configMap:
            name: sync
        - name: data
          hostPath:
            path: /data/sync
            type: DirectoryOrCreate
---
apiVersion: v1
kind: Service
metadata:
  name: sync
  namespace: sync
  labels:
    app: sync
spec:
  type: NodePort
  selector:
    app: sync
  ports:
    - protocol: TCP
      port: 30555
      targetPort: 30555
      nodePort: 30555

Notes for deployment:

  • was forced to change everywhere 55555 to 30555 because of given constraints, make sure for this port to be the same everywhere because it is being used by torrent procol underneath
  • if you provide shared_folders it will automatically disable UI and ability to add/remove them
  • secret can be generated like so docker run -it --rm resilio/sync rslync --generate-secret
  • if you can use persistence volume instead of hostPath
  • be sure to have same nodePort in service as listening_port in config

So from now on my desktop mess is synced between machines

sync