un-ignore subfolders & files of ignored folder

I wanted to update this Ancient Dead Creature, as the solution to the title statement of the original post doesn’t seem obvious (to me at least), and I stumbled upon this from a google search.

I was backing up my VPS and wanted to get very granular with my set up. I just set this up on my machine.

In .stignore I placed the following

#include /home/user/folder1/rules.conf

Where the path is relative to the root of the sync share. Working with the whole VPS, I just entered the actual path.

It is good to think of building the ignore list file from the bottom up for this level of granularity. So start with an “ignore all” rule at the bottom.

*

Then, above that, tell syncthing to include the directory, home in this case, and all of its contents by leaving out the trailing slash.

!/home
*

Next tell syncthing to ignore the general contents of home.

/home/*
!/home
*

Now syncthing is ignoring everything but the actual home folder. To descend into a specific user directory we have to repeat the pattern.

/home/user/*
!/home/user
/home/*
!/home
*

If you want to add the entire user directory, just leave out that top line. To add a specific directory, and all of its contents, therefore, just add a line like so…

!/home/user/folder0
/home/user/*
!/home/user
/home/*
!/home
*

And finally to descend into a nested folder and sync only one file among many within it, just add the following lines at the top of the file

!/home/user/folder1/rules.conf
/home/user/folder1/*
!/home/user/folder1
!/home/user/folder0
/home/user/*
!/home/user
/home/*
!/home
*

So now the sync will get the file rules.conf in folder1, and folder0 and all of its contents, while maintaining file-system structure for user.

In this manner it is easy to add the specific appropriate folders and files in /etc, /var, and any other directory desired. Then set the folder to master, and on the receiving end(s) add in some basic file versioning.

If there’s an easier way to do this, I don’t know, it sure would be nice if there was a more intuitive way to include granularity as an option via a GUI. With the web interface, that would make syncthing simply ideal for server backup functions.

7 Likes