Is there a way to ignore symlinks on Android?

I want to sync a folder between a Linux machine and my Android phone. The folder has a bunch of symlinks, and on Android, I want to sync the folder to the external SD card.

The problem is that, on Android, the symlinks fail to sync, since the SD card is formatted in a FAT filesystem that does not support them. This just makes the folder “Out of sync” on Android.

Syncthing does sync everything else just fine though, but then still displays “Out of sync” on the folder. Is there a way to set a wildcard ignore pattern or something to ignore all symlinks, without having to update the ignore pattern to also match new symlinks each time I create one?

You can’t ignore symlinks specifically, so the only way would be to just add them one by one to the ignore patterns. However, Syncthing should still sync all other files regardless of the symlink-related errors. If that’s not the case, please post screenshots showing your Syncthing Web GUI on all affected devices. Log files are always welcome too.

Oh whoops, true, everything else does seem to be synced; I had an irrelevant issue there for a second, sorry. I edited the post to reflect this.

Still though; I’d imagine there should be a way to use a special string in ignore patterns or something to exclude all symlinks specifically? I like seeing green checkboxes, not red “Out of sync” :v

Yeah, unfortunately there’s nothing like that for now. The only semi-automatic solution that I can think of would be to run some kind of a script on the Linux side to find all symlinks and add them to the ignore patterns automatically.

Welp, fair. I guess I’d rather live with a red sign than that though; because then I’d either run into problems of syncing those symlinks to other capable machines (the folder is synced from that Linux host to hosts, not just Android), or deal with even crazier automation methods on Android.

Feature request? :smiley:

It could be, although this may be tricky to implement, as ignore patterns don’t really accept any advanced filetype-related patterns other than basic wildcards and ranges. As of right now, it’s not even possible to distinguish between files and directories :wink:.

I think you could still automate it by running the script on Linux and add the patterns to a separate file, e.g. .stignore-android, and then on the Android side, just add #include .stignore-android to the ignore patterns there. You can even update the patterns on Linux later on, and Syncthing on Android will pick them up automatically.

1 Like

Oh yeah, that does seem like a really neat way to go about it now. I think I’ll try just that. Thanks!

Yup, that does work perfectly, except for the part where I have to run the script myself when making any links. Documenting for if someone else finds this thread later on:

The script is a one-liner on Linux machine side: find * -type l > symlinks

Then the ignore pattern on Android: #include symlinks

Then a rescan and a restart (both just in case) later, nice green checkbox!

How about just setting the script to run every hour or so (or even just once per day)? Then you’d just set it once and forget about it (until something breaks later on, which does happen :wink:).

Can android never deal with symlinks? If that’s the case it would be a valuable feature request to just ignore symlinks on android (as identified by GOOS, like windows) automatically.

I don’t add or remove files that often in there, and would rather not add more automation to my system like that unnecessarily, but I guess that would technically speaking solve that part lol

Oh yes, just checked with Termux, and Android does indeed disallow spawning symlinks in shared internal storage as well. That does sound like a reasonable request.

I’d imagine there can be some fringe use case outside of Android’s intended functioning where a user forces Syncthing to sync a folder outside of normal user storage, which would then allow symlinks, but that doesn’t sound like worth accounting for.

Should I create an issue on GitHub for this?

The OS itself can, but the filesystem used on /sdcard is universally FAT, so no symlink support there.

It seems to be quite complicated though (see, and obviously requires root access.

Isn’t it too late to disable it abruptly though? There are probably some people that sync their /data partition for backup purposes, and there are symlinks there already.

Oh yeah. I’d imagine, for consistency, it would be reasonable to apply the same approach as on Windows: symlinks sort-of-exist and can technically be used, but are generally unsupported and not intended to be used by the OS developers. (after all, Windows does support symlinks to my knowledge and experience)

But indeed then there’s the question of if someone already syncs symlinks to/from Android in such a way…

It can deal with symlinks just fine, it just depends on where and what type of storage it is.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.