Workaround for multiple .stignore?

Hi,

I have 3 devices: PC, Laptop and NAS.

The NAS is permanently online, so I always place the NAS between the PC & Laptop when syncing (the Laptop & PC never sync directly to one another).

I am using Linux, so everything worth backing up is under /home/username.

There are 3 categories of files & folders in my /home/username folder:

  • Profile Data (Desktop, Documents, Music, Pictures, Videos, Projects, etc.)
  • Local Config Data (.config, .local, some of my own folders as well, etc.)
  • Other system dotfiles & folders

There are too many folders to create and maintain a separate shared folder for each of them (across devices), and all the above folders are inside the same parent directory /home/username, which only supports 1 .stignore file.

For both the PC & Laptop, I am looking to set each of them up in the same way, as shown below:

Profile Data Local Config Sys Files
Selection Type Include specific Include specific Exclude specific
Size 10GB 5GB 20GB
Send to Device NAS + PC/Laptop NAS + PC/Laptop NAS only
Sync Type Send & Receive Send Only Send Only

Any ideas on how to achieve the above setup?

Are the devices listed under “Local Config” correct? The folder type is “Send Only”, but the desired setup implies “Send & Receive”.

PC and Laptop aren’t peered, so you’ve got a hub-and-spoke topology with the NAS at the center. PC and Laptop can send-only to the NAS if the two aren’t syncing their configs with each other. But if they are, then the sync path is PC → NAS → Laptop and Laptop → NAS → PC (requiring send-and-receive).

Many thanks for your insights @gadget.

I use the ‘Local Config’ as ‘Send Only’ because there are some slight variances across configurations between the PC & Laptop due to hardware/compatibility. ‘Send Only’ allows me to manually copy the relevant files when needed.

Linux, and I believe MacOS alike, place all user data and configuration in the /home/ folder. So if I sync the entire folder, then I can’t selectively choose on the receiving device what I want to download, so I’m forced to accept the entire /home/ folder, and all of the contents will also have the same ‘Folder Type’ i.e. Send & Receive - which is quite a dangerous way to expose the /home/ folder in my view.

If I could split the /home/ folder into categories (similar to the table in my main post), then that would not only be more efficient from a data transfer standpoint, but also more secure.

As far as I’m aware, Syncthing uses a 1:1 mapping between folder:stignore file, which means that I cannot create 3 folders inside Syncthing, point each of them to /home/ but provide a different .stignore pattern to each of the 3 folders.

If that was possible… it would solve all the challenges I’m currently facing.

There are no good workarounds here. For different sharing modes you need different folders. Different folders will currently share .stignore if they share the physical directory. We could probably fairly easily allow to customise the ignore file name, or use something like .stignore-$folderID by default with a fallback to the old name, though. (Other, better solutions like adding the ignores to the config itself are tricky since we support includes and stuff.)

1 Like

Ah… okay, so the config files on PC and Laptop are really “Send Only” to the NAS (and the NAS is optionally “Receive Only”).

Yes, all correct.

1 Like

That would be epic!!

Multiple .stignore-$folderID would also be very easy to manage and backup.

Personally, I wouldn’t worry about this at all. For me, the .stignore-$folderID would be the superior solution.

I love how Syncthing has the .stignore file in the physical directory, as well as the trash and previous file versions. This means that I can easily get a pulse-check on Syncthing directly from the file explorer.

Configuring multiple Syncthing folders is unavoidable because of the different sync folder types (e.g. “Send Only”, “Send & Receive”) desired, but since you’re using Linux, the rest of the wish list is doable.

First, create a basic directory tree similar to the following:

/mnt
└── username
    ├── Local_Config
    │   └── home
    ├── Profile_Data
    │   └── home
    └── Sys_Files

7 directories, 0 files

It doesn’t have to start under /mnt, and only requires enough storage capacity for the .stignore files (assuming Syncthing’s versioning feature isn’t being used).

Then configure three Syncthing folders using /mnt/username/Local_Config, /mnt/username/Profile_Data and /mnt/username/Sys_Files as the target paths along with the desired ignore patterns. The directory tree now ends up like this:

/mnt
└── username
    ├── Local_Config
    │   ├── .stfolder
    │   └── .stignore
    │   └── home
    ├── Profile_Data
    │   ├── .stfolder
    │   ├── .stignore
    │   └── home
    └── Sys_Files
        ├── .stfolder
        └── .stignore

9 directories, 3 files

Next, pause syncing or shut down Syncthing. Bind mount /home/username into the newly created directory tree:

mount -o bind /home/username /mnt/username/Local_Config/home
mount -o bind /home/username /mnt/username/Profile_Data/home

By shifting the position of /home/username virtually, it provides the opportunity for multiple unique .stignore files on the same base path.

(If setting up mounts in /etc/fstab isn’t desirable, there’s the “bindfs” FUSE module that runs in user space.)

2 Likes

You absolute legend!!

Workaround I asked for… and workaround you delivered! Actual footage of me right now :joy::

I have set it up as per your instructions and it works, thank you!!

@calmh another grateful squirrel is coming your way as well for the .stignore-$folderID. Is there anything that we can we do to help get an official implementation of your proposed solution as well?

Thanks again both, you’re awesome people :slight_smile:

1 Like

:laughing:

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