How does Synchting handle symbolic links?

It looks like it depends on file system, operating system etc. Here is what I find in the docs:

  • Symbolic links (synced, except on Windows, but never followed)

Is there a workaround to follow the symbolic links?

I see this post, but it’s inconclusive

The symlink links to outside the Synchting folder. I want when the source data is updated, the actual data is synced in Synchting folder of the other peer (not just a link that points to nowhere).

Can someone clarify the situation as of 2024.

Yes. For example, FAT-based filesystems don’t support symbolic or hard links.

The scenario you describe above is unsupported in any combination of operating system and filesystem. If it was an option in Syncthing, there would be the question of what happens in the default “Send & Receive” mode when one side has a symbolic link while the other side doesn’t (just one of many issues).

What exactly is it that you’re trying to accomplish on the destination device?

Synchting syncs a folder in peer A to a folder in peer B. How do you sync a specific file in peer A, for example /etc/foo, to a file in peer B, for example, ~/Sync/foo?

In general, I want to sync assorted files and folders in peer A (various folders, specific dot files or files in /etc/ and so on) to the Synchting folder in peer B. I thought of creating symbolic links from those files and folders to the Synchting folder in peer A. I was hoping that Synchting will follow the links and syncs them somewhere in peer B. For example, /etc/foo is linked to ~\Sync\foo.ln in peer A which is then synced to ~\Sync\foo (actual file not a symbolic link) in peer B. The sync will be one way. A two way sync could also be implemented, but is more complicated.

Syncthing works relative to a designated starting path, so device B doesn’t care that its ~/Sync/ is receiving files from /etc/ on device A.

Then for filtering out all but specific files from a directory/folder, see: https://docs.syncthing.net/users/ignoring.html

If /etc/ and ~/Sync/ are in the same filesystem, one option is to use hardlinks instead of symlinks.

But if ~/Sync/ is on a different filesystem, one option is bind mounts (i.e. mount --bind).

(Note that it’s spelled “Syncthing” and not “Synchting”. :smirk:)

1 Like

A trick I use is to link through a shell-script.

Could you kindly explain this shell script? I don’t quite understand what it’s meant to do or how that gets around the Syncthing limitations

As-is, the shell script shared via the link above requires a very user-specific environment, so it’s not likely to work out of the box on a random Un*x system.

I hesitate to call it a limitation in Syncthing because there are all kinds of limitations outside of Syncthing regarding links.

If the goal is to sync assorted files/directories that are spread across available storage on device A, and have them deposited into a single destination directory on device B, the simplest solution is to reverse the direction of the symlinks.

For example, if device A has the following files…

/home/user/Documents/notes.txt
/home/user/Music/song.mp3
/home/user/Pictures/pic.jpg

… with the goal of ending up with the following on device B…

/home/user/Sync/notes.txt
/home/user/Sync/song.mp3
/home/user/Sync/pic.jpg

… on device A, set up a /home/user/Sync directory like this…

/home/user/Sync/notes.txt
/home/user/Sync/song.mp3
/home/user/Sync/pic.jpg

(Note how on device A it looks just like it does on device B. Syncthing syncs a single folder on both ends.)

… then add symlinks as needed:

/home/user/Documents/notes.txt ➛ /home/user/Sync/notes.txt
/home/user/Music/song.mp3 ➛ /home/user/Sync/song.mp3
/home/user/Pictures/pic.jpg ➛ /home/user/Sync/pic.jpg

Well here’s my use case, so there’s a complete understanding:

I have a tablet (Device A) that I want to use as a photo frame, but it doesn’t have enough storage to hold all my photos. On my PC (Device B) I have 2 hard drives with photos, all sorted by date, event, family, etc.

I want to have a folder on Device B that syncs to Device A so that, every week or so, I can add links to the photos I want shown on the photo frame. It’s not reasonable to add links the way you mentioned in this case, only to move them back to their original location and so on.

In my case I think I will just create copies of the photos into the shared directory, but if you have a suggestion for a more cohesive solution, even if unrelated to SyncThing, I’d be interested to learn about it.