Useful .stignore Patterns


(Brian) #62

Where do you put your .stglobalignore file?


(Audrius Butkevicius) #63

There is no global ignore. Read the docs about includes.


(Brian) #64

I was asking about the file the OP proposed in the original post which started this thread. What are you talking about?


#65

Syncthing recognizes .stignore file in the base directory of a share, and parses it’s contents according to documentation:

https://docs.syncthing.net/users/ignoring.html#patterns:

A pattern beginning with #include results in loading patterns from the named file. It is an error for a file to not exist or be included more than once. Note that while this can be used to include patterns from a file in a subdirectory, the patterns themselves are still relative to the folder root. Example: #include more-patterns.txt.

Meaning: if you write in .stignore the line: #include .stglobalignores, it’ll search for a .stglobalignores file in the same place that .stignore resides, and then parse .stglobalignore’s contents as a continuation of .stingnore.

(The point of using extra file in addition to the base .stignore, it that .stignore itself is device specific, that is - it won’t sync to other devices. So people use #include some_file_with_patterns_to_sync to add ingore patterns they like to be synced across several devices.)


(Brian) #66

Thank you. Your answer makes me understand people are putting .stglobalignores files in the same directories as the base .stignore file. That way, it will propagate changes to all devices. ~That~ type of redundancy is good and necessary.

However, the reason I asked was because that seems redundant in a different way when I share multiple directories on a machine. It would seem that each device needs only one .stgobalignores file if the file for each sync set is the same anyhow. Having identical include files a in the sync root directory for 5 or 10 or however many sync root directories is redundant and a configuration nightmare.

You wrote that syncthing will look for the include files “in the same place that .stignore resides.” Is that mandated by syncthing or is that only because in your example, you named no alternate location?

Is it possible to put a single include file on each device - maybe at the user home level - and have each sync root .stignore file reference it, like “#include /home/user/.stglobalignores” ?

If this can be done, why are people creating a new include file for each sync root? Maybe the documentation could be expanded to address this issue.

If this can’t be done, it would be nice to have so I only have to maintain one include file.


#67

Every share (folder) is independent of other shares, so yes you would need .stignore in every folder

Because of my example. In general included files may reside elsewhere, but you need to point to them relatively to the root of this particular share’s folder.

Documentation specifies that included files should reside in the folder itself, or it subfolders:

Note that while this can be used to include patterns from a file in a subdirectory, the patterns themselves are still relative to the folder root.

So regarding placing it in /home/user/whatever , completely outside the shared folder - I’m not sure about it, but you should give it a try, it may just work.

If the above works, I guess a single ignore template file may be used for many shares. Just sometimes people want to exclude different things from different folder pairs.

If using single location won’t work due to some implementation limitation or access rights, it’s not that big of a deal, you can always copy-paste ignores upon folder creation.


(Simon) #68

You can specify any path as includes, even outside of the folder root, it just needs to be relative to the folder root. I have a Syncthing folder where I share stuff like keypassx database, configs, … There I put a “.stignore-common”, which I include into every .stignore on any machine. So just one file to maintain to ignore stuff like “*~”, “.DS_Store”, … Then sometimes I add a .stignore-folder to the folder root to ignore stuff that is specific to this folder but not Syncthing instance. Works like a charm.


(Wolf) #69

Update with great feedback from the above posts

//---Mac-specific---//
//Mac Comments, Finder Windows Size, Tags, ...
(?d).DS_Store
.DocumentRevisions-V100
//Mac Folder Icons, which will not sync to Windows
(?d)Icon*
.Spotlight-V100
.TemporaryItems
.Trashes
.fseventsd
//Mac Flag to enable translation of Folder Names
(?d).localized
//Mac Temporary iCloud files while synching
.iCloud
//Mac OS Metadata on Windows or Linux filesystems
(?d)._*

//---Windows-Specific---//
(?d)desktop.ini
(?d)Thumbs.db
(?d)$RECYCLE.BIN

//---Linux-specific---//
.Trash-*

//---QNAP-specific---//
(?d).@__thumb
(?d).AppleDB

//---Synology-specific---//
(?d)@eaDir

//---Application-specific---//
//-Syncthing
(?d).stignore
(?d).stfolder
//-vi(m)
(?d)*.*.sw[a-p] # Thankys to Tom Hale!
//-Dropbox
.dropbox
.dropbox.attr
//-Microsoft Office temporary files/lock files
(?d)~*
//-KDE
.directory


//---OTHER---//
Microsoft-Benutzerdaten
Notizbuch von Wolf.url
Outlook-Dateien
RDC Connections
.parallels-vm-directory
Default.rdp

moving a directory => out of sync
Question about .stignore
(Alex) #70

Thanks for this. For Adobe Lightroom I started getting lots of sync errors concerning the preveiews.db files, so I suggest the following (not perfect and surely can be improved):

// Adobe Lightroom previews.db *Previews.lrdata root-pixels.db


(ncantor) #71

// Adobe Lightroom previews.db *Previews.lrdata root-pixels.db

should be:

//–Adobe Lightroom previews.db --//

*Previews.lrdata root-pixels.db


(Razvan Rosca) #72

Here’s a list with all the above recommendations, without comments.

(?d).DS_Store
.DocumentRevisions-V100
(?d)Icon*
.Spotlight-V100
.TemporaryItems
.Trashes
.fseventsd
(?d).localized
.iCloud
(?d)._*
(?d)desktop.ini
(?d)Thumbs.db
(?d)$RECYCLE.BIN
.Trash-*
(?d).@__thumb
(?d).AppleDB
(?d)@eaDir
(?d).stignore
(?d).stfolder
(?d)*.*.sw[a-p]
.dropbox
.dropbox.attr
(?d)~*
.directory
.cache
*Previews.lrdata root-pixels.db

(Frederic) #73

Hi there! Is it possible to ignore linux hidden files/folders with maybe:

.*

I mean all file/folder starting with “.”

I was thinking to sync all documents from /home/myaccount/ but do not sync all account config files which are usually hidden (.firefox etc…)


(Razvan Rosca) #74

I mean all file/folder starting with “.”

Not a good idea because not all “dotted” files/folders are unnecessary. Take for example .htaccess, which is normal in a web development environment and basically mandatory for anything Apache related. Loosing a .htacess file would be huge. There are many other examples as well.


Folder markers are now directories (v0.14.38)
(Jakob Borg) #75

5 posts were split to a new topic: Ignore patterns that start with “#”


(Bruno) #76

Hi,

There are too many types of files to ignore according the various OS used. I’ve a mix a win, linux, qnap, syn… So I prefer to forbid everything and only accept the kind of file I want to share (like for firewall rules).

// allow OneOnlyFile.TxT

(?i)!OneOnlyFile.TxT

// exclude any.JpG from forbid

(?i)!*.jpg

// forbid all rest (included subdirectories : Not Tested) yet

**

#77

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


(Audrius Butkevicius) #78

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


(Zilexa) #79

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.


(Audrius Butkevicius) #80

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


(Zilexa) #81

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