Useful .stignore Patterns

Hi, I’am new with Syncthing an I need help with settings .stignore

I have 3 devices, phone 1, phone 2 and PC. I have one folder (for example folder name A and subfolders X, Y, Z). Phone 1 sync folder A with phone 2 (between these devices, sync all data in folder A both sides) and this folder I want sync with PC too, but in PC have folder A many others files and folders. I don’t want sync these other data from PC to phone 1 and 2, but I want still sync changes in folder A from phone 1 or 2 to PC (ofcourse changes only for data from phone 1 or 2 not for other data in folder A in PC)

example:

phone 1 -> A/X

        /Y

        /Z

phone 2 -> A/X

        /Y

        /Z

PC -> A/X

   /Y

   /Z

   /P

   /Q

   /R

   /1.jpg

   /123.apk

   ...

add file or folder C/audio.mp3 in phone 1 or 2 to A -> changes will be sync in phone 1 and 2 and PC.

phone 1 -> A/X

        /Y

        /Z

        /C/audio.mp3

phone 2 -> A/X

        /Y

        /Z

        /C/audio.mp3

PC -> A/X

   /Y

   /Z

   /C/audio.mp3

   /P

   /Q

   /R

   /1.jpg

   /123.apk

   ...

Other data from PC /P, /Q, /R, /1.jpg, /123.apk … not sync to phone 1 and 2

And my next question, is it possibe to sync from PC in A only new added data to phone 1 and 2?

example: “old” data from PC /P, /Q, /R, /1.jpg, /123.apk … not sync to phone 1 and 2. But when I add new data (folder or file) sync olny this data to phone 1 and 2?

I hope you understand me and apologise for bad english :slight_smile: Thank you for help

You should just ignore folders you don’t want synced from the PC to the phones on the PC.

Can someone please explain this to a noob? So I have to put those lines in .stignore (in every node & every folder I sync with that node) .stignore. But where do I put .stglobalignore? In the root folder of syncthing? On debian its my home folder/.config/syncthing.

This would be relative to the folder root so you’d have to do it per folder.

Huh, sorry I am confused now. The folder root is where .stignore already needs to be: in the root of the folder(s) added to syncthing for syncing.

Why create two files in each root folder (.stingore and .stglobalignore)? That does not make sense right?

I just need to exclude (globally for all devices, nodes and folders) all those Windows .thumbs and desktop.ini and Android .thumbnails folders.

EDIT: I understand now: stglobalignore and stignore should be in the root folder that is added to syncthing. stglobalignore will be synced to other devices as described below this overview: https://gist.github.com/jult/e2eaedad6b9e29d95977fea0ddffae7d

Please do not use relative ignores escaping the folder root, that might not work in future releases.

hi , I have a similar use case . The background being that I use the Macosx environment (macosx Catalina)for syncing my original photo’s and videos to my PC laptop as a photo dump . I use the native picture management app called “photos.app”. this generates quite a lot of files not required to be synced .

I have tried using the fancy filters in the .stignore file however had problems with the expression <!> used to ignore the ignore pattern. ST was still syncing files other than the ones used . I think the reason is that the include feature works with the include and not otherwise . so I went about a simple way

I used the the following to include the desired format (each expression per line) !.png !.mp4 !.mov !.jpg !.jpeg !.avi !*.gif

and then I used a generic expression like this <.1> <.2> (…extend to the full series) <.a> <.b> (…extend to the full series)

this helped me get the right mix . the following expression is not likely to work .

!.png !.mp4 !.mov !.jpg !.jpeg !.avi !*.gif *

this ends up ignoring everything . I don’t know if that a bug or a feature or a limitation etc.

Because I use Syncthing and Resilio in parallel, for the Ignore lists I use as follow:

Including in Syncthing Ignorelist:

// Resilio .sync .syncID .syncIgnore .syncArchive *.bts !sync *.syncPart *.syncTemp *.syncOld

Including in Resilio Ignorelist:

// Syncthing .stfolder .stignore .stversion .syncthing* .syncthing.* .syncthing.. ~syncthing~..tmp *.Identifier

In this way is possible to have a folder in both peer lists, if needed in special cases.

how could i add the Synology Dsikstation folder “#recycle” to the ignore list? the fildername starts with an “#”

Thank you in advance

If it’s at the top of your folder, /#recycle is an option. (?i)#recycle is another which matches everywhere, case insensitively.

1 Like

I want to discuss a possible case. If I want to sync a folder but not the subfolders, I have to ignore ALL subfolders. For that / in the stignore should be work.

Is possible, that sub-folders under root level will still be created on the other remote peers (folders) and they are all empty and nothing inside them, so maybe I have just a bunch of empty sub-folders?

Further, is possible, if someone accidently delete or modify the empty folders on the remote peer sides, which were not allowed to be synced, then on the server side the original folders content lots important files, will also be deleted real quick? Maybe, because Syncthing considered that folder is no longer exist and removed it?

Maybe helps, if I had some files or folders don’t wanna to be synced, simply prefix a ~ to these folders, and they will disappear like a charm on other peers. No need to add rules into the stignore. Just prefix a ~ to ignore. Is possible to use this method on almost any folder / files?

I’d try /*/** which should match everything one level down or more.

Yep.

No. Syncthing will try, complain that the folder is not empty, and suggest that maybe you have an ignore setup like described here.

I’m not sure how you mean this to work exactly.

This should be useful!

One that should be included: “.thumbnails”, used by Android, if you share just the “DCIM” directory on an Android phone you’ll get one of those included too, so best not to sync that

Is it ok to create a mini repository of ignore rules for each (os|applications) Either at GitHub or syncthing docs

There are many ignore rules in the form putting them in one place may help

1 Like

If I understand correctly, you would still need to edit each and every .stignore file of every synced (root) folder on each of your devices individually, to add #include .stglobalignores.

Once you have done that, you can do maintenance for adding/removing excludes in each .stglobalignores in every synced (root) folder on 1 device (for example your NAS/homeserver), it will get synced to each node.

Am I correct?

Perhaps it is a lot easier to use the WebUI, add all ignore patterns in one folder and just copy paste it to other folders whenever you need it. However I guess you would have to do this for each node individually again… never mind.

A centrally stored .stglobalignores would be better. Otherwise I used scripts by copying an adapted .stignore from a defined directory into the respective peer. Sure, if I change the peer list in the GUI, I may have to adjust the script as well. But it’s not that time-consuming once things have been laid out.

So I am correct, about how it is now?

Yes, is also my knowledge.

Yes. I use ignores in this way in some instances and it works well.

But only to one related peer. If e.g. 5 devices connected to the related peer, on all devices you will find automatically the .stglobalignores in this related peer. Finally you need to repeat that for each different peer.