Sync file ownership, and permissions

Would it be possible to preserve file ownership, group, and permissions (at least on the platforms that support it)?

2 Likes

Permissions are synchronized. Owner and group would require running as root; this is neither recommended nor supported right now. There would be a bunch of corner cases to solve in that case as well…

1 Like

I vote for this feature too, I need to sync /home folder with multiple linux computers (users, uid and groups are already synced via ldap) but can’t find any app that can do this.

I understand that this feature will be available only on one system type (Linux), and I must run syncthing as root for this feature, but I ready to do this, because no other ways exists. When we have many nodes - syncing each node via rsync or other scripts are not comfortable.

So if you add syncing file onwership, group - this will be unique feature in syncthing and allow to use them in corporative systems.

For create universal ownership syncing we also can use full “user & group” names instead of uid and gud, via this - Linux file with owner “user1” and uid=1021 will can be succesfully synced with Windows file via user name “user1”.

For owners that not exists on target system we can set syncthing process ownership or setup default user in settings.

I can see the attraction. It also seems like mapping user identities from one system to another is somewhat of a rat’s nest to get right, though. I’m a tiny bit afraid of there being dark corners that are hard to predict from the start and that’ll come back to bite us in the ass. (Although that simile doesn’t make any sense…)

Thanks for the reply, I understand that this feature can give unexpected results in some situations. But in other situations this feature is only one way to do correct sync process, so this will be killer feature of your app. You can provide this feature in “for improved users only” section and mark it as very experemental in many next releases with ton of warnings :smile: and test it long time with user feedback. This feature will be disabled by default and only users that need this feature will enable, and most of them will report bugs to you if got some unexpected results.

Here is my quick example:

Advanced options [collapsed]

- [v] Sync file ownerships
For use this feature you must run Syncthing with root priveleges. For this feature working it must be enable on each client in group. This option is very experimental and not recommended to use in production. Before enable it, you must read full description of potential issues here. Please report any bugs about this feature here.

- Ownership synching type
[o] Sync by user name and group name (not available for Android)
[  ] Sync by user id and group id (uid and gid in Linux, Mac OS, not available for Android, Windows)

- Ownership synching type
[o] Sync by user name and group name (not available for Android)
[ ] Sync by user id and group id (uid and gid in Linux, Mac OS, not available for Android, Windows)

- Default User and Group 
If remote user or group will be unavailable on current system, ownership will be resetted to this values:
[o] user and group of syncthing process
[ ] custom user ______ and group _______

[Reset ownership] This button will reset ownership of all files in this Repository to current user and group.

Yep, that’d probably be the way to do it.

Hello! Is there any progress in this way? Maybe some plans for future versions? I can help you with beta-testing this feature.

As far as I know, there isn’t currently anyone working on this. It’s up for grabs! :wink:

1 Like

This is SUPER important for us since we have a webhosting server for our users and when they log in they are chrooted based on their userID into their own user directory. example below for accountId 12345,12346,12347

/opt/customer_home|
                  |12345/
                  |     |---www/
                  |     |      |--- file1.txt
                  |     |      |--- file2.txt
                  |     |
                  |     |---reports/
                  |     |---recordings/
                  |
                  |12346/
                  |     |---www/
                  |     |---reports/
                  |     |---recordings/
                  | 
                  |12347/
                  |     |---www/
                  |     |---reports/
                  |     |---recordings/

So as you can imagine the ownerID is critical for us and must be preserved during the sync. Unfortunately this is a absolute blocker for us which is very disappointing.

You can remap user ids using the existing Linux tools (http://www.kernelcrash.com/blog/nfs-uidgid-mapping/2007/09/10/ as an example), I think there are fuse wrappers for that too…

Also, as @calmh said, it’s up for grabs for anyone who finds this SUPER important :wink:

1 Like

AudriusButkevicius, thanks for idea, but this will work only if we have different uid of file owners. But when we syncing folder via Syncthing - we lost all of file owner uid and gid info, so there nothing to restore or remap after this :frowning:

johntdyer, I have the same problem too. Did you find any other solutions for two-way sync folders on many systems without losting uid and gid info?

We are using Unison right now which does work but its clunky in many respects. I was hoping for a more elegant solution w/ Syncthing or Btsync but w/o the ability to sync permissions they are both a non-starter for me… shame :frowning:

I work around this (in a very limited way) by running Syncthing/Pulse in a Docker container. I have the same username on multiple machines, but there’s no guarantee that the UID/GID will be the same for each. An ansible playbook sets the correct UID/GID inside the Docker image when it is built for my username on that host machine (that sounded confusing…sorry!). Syncthing then runs with that UID/GID. This way the files sync with the same username and are accessible on all the machines without having permissions problems.

Scott

Thanks for reply, but Unison sync only 2 folders via one sync process. I have about 10 computers and want to sync /home folder for all users between all computers. UID and GID are same on all systems (synced via ldap).

Run separate Syncthing process for each user is not so good variant, because there are too many users and this is not so good for memory and cpu usage.

So at now I can’t find any working solution how to do this sync :frowning:

I use unison too, but it use to many fsmonitor processes for working with more than 10000 of files. We use it to sync documents between officeses in different citys. We need to sync the ownerchip too and all clients use the same uids.

Does syncthing protocol provide transfer uid and gid? Or is it not designated?

It doesn’t. Not by design though but because it’s a lot of work to make it work right. Moving uids and gids sometimes makes no sense (when you want to preserve string based users especially when in windows, etc).

To reduce the workload you can limit features of this process in first release. Describe this feature as “Testing, not stable, alpha version” status and do only hard numeric uid=uid and gid=gid syncing, only for Linux systems (without thinking how to implement sync with windows, with same username but different uid, etc).

This will give wanted feature for this topic subscribers and other users that really need this feature (plain numeric uid and gid sync), and not broke functional for all other users (because they will not enable this feature without the direct need).

And on next versions in future you can gradually extend this feature to support windows, syncing via username instead of uid, etc.

Please try to do this via some quick and easy (with limited features) way, because at now there are no linux solution in all world for solve two-way syncing with uid/gid, but many people searching and waiting it.

I personally use Windows and usually as a single user, hence this would be of no use to me at the moment. But regardless, all pull requests are welcome.