You are not logged in.
Hi.
I'm using rsync to sync a working copy of some files to a folder on a remote server. Whenever I sync files, rsync changes the owner:group of the files on the remote server to my_local_uer:my_local_group.
I've looked online and it seems the simplest way to keep the original ownership on the remote server is to run chown after the sync. I want to allow multiple users to sync to the server, but I don't want to give them rights to change ownership. And I don't want to run a cron job to do the same.
What really bothers me is that you typically have to run chown as root to change ownership. Yet rsync is allowed to change ownership from a remote machine? How does this make sense?
Is there any way to sync files from a local machine to a remote server while leaving ownership and permissions on the remote server untouched?
Last edited by Pacopag (2013-05-30 18:47:17)
Offline
What command line parameters are you using for rsynce? What filesystems are on the client and server? If they both run Linux, do they each have the same users and groups with matching user IDs and group IDs?
Offline
Rsync command is (redacted)
rsync -rlzuogv --delete --stats --progress -e "ssh -i /path/to/private/key" /source/folder user@hostname:/destination/folderLocal is arch, remote is debian. I'm pretty sure that both filesystems are ext4. Different users and groups on each system. I just don't want rsync to touch the ownership and perms on the remote server. And again, how is it even allowed to do so?
Offline
is the user existent on both systems?
Usually the numeric ids dont count until the name is equal. If you would want that, you could use --numeric-ids (or similar)
Last edited by weltio (2013-05-30 16:41:52)
Offline
Wait. Sorry, My orginal post is wrong. Rsync isn't changing ownership to my_local_uer:my_local_group. It's changing ownership to that of the user on the remote system I'm using to connect (i.e. "user" in my rsync line).
So, no, the user is not existent on both systems.
What's more is that the user is chrooted to the directory I'm syncing to, and chown doesn't even exist in that chroot. So how can the ownership get changed at all?
Last edited by Pacopag (2013-05-30 16:46:58)
Offline
I tried using unison instead of rsync, but it behaves the same way; It changes the ownership of the file on the remote server to that of the user on the remote server that synced.
I also tried gftp with "Preserve permissions" unchecked, and it seems to work; it doesn't change the ownership of files on the remote server. Not as convenient as rsync, though. Gftp takes forever because of the large number of files. Rsync works in 1 second flat, except the ownership change breaks everything.
Last edited by Pacopag (2013-05-30 17:21:09)
Offline
Whenever I sync files, rsync changes the owner:group of the files on the remote server to my_local_uer:my_local_group.
Rsync is changing ownership to that of the user on the remote system I'm using to connect (i.e. "user" in my rsync line).
At this point I'm way confused about what you actually want. O_O
So, you have two Linux computers. Computer A has a user named user_a and computer B has a user named user_b. You login to A as user_a and use rsync to copy files to B as user_b. The files on A are still owned by user_a. The files copied to B are owned by user_b.
Is that what you are currently experiencing? Are you expecting a different outcome?
Offline
To preserve ownership you would need root privileges on the remote server. You are using a particular user on the remote server and the files you are copying to the server are created by that user (which makes it the owner). Preserving ownership requires a subsequent chown.
Did you really check the owner of the files after using gftp? Or did you only look at whatever it is that gftp's GUI shows? If you use the same user for (s)ftp as for ssh, I wouldn't expect different results.
But maybe you should take a step back and explain what it is you want to be able to do with the files on the remote server.
Offline
drcouzelis got it right. That is what is happening. What I want is to just update the data in the files on the remote server without changing the ownership of the files there.
Raynman: Why is it creating NEW files with new ownership. I though rsync was fast because it just fixes up the deltas. Why isn't it just modifying the EXISTING files.
Yes, I checked the ownership after using gftp from command line, and they are ok. gftp using ssh2 protocol does not change the ownership of the existing files on the server, even if I choose "Overwrite". The problem with gftp is that it seems to take forever.
Offline
All that really matters is the group. If I can get the group to stay the same, even if the owner changes. that would be great. Even gives a simple way to see which user last rsynced which files.
Reading on how rsync works, the problem is here. Seems to be fundamental to how rsync does its job.
"After the temp-file has been completed, its ownership and permissions and modification time are set. It is then renamed to replace the basis file."
http://rsync.samba.org/how-rsync-works.html
Is there a way to ensure that all newly created files within a directory (and its subdirectories) are owned by a particular group? That might solve it.
Last edited by Pacopag (2013-05-30 18:33:53)
Offline
Is there a way to ensure that all newly created files within a directory (and its subdirectories) are owned by a particular group? That might solve it.
Have a look at http://en.wikipedia.org/wiki/Setgid#set … irectories
Offline
Ok. It seems like this worked
sudo chgrp groupname folderWhere "groupname" is the name of the group I want to keep on the server files and "folder" is the top-most folder containing the files I'm syncing. This even causes the owner to be preserved on the server.
Thanks to all for help, and letting me talk through it.
Edit: Just missed your post Raynman. Setgid would likely work too (maybe that's what chgrp does anyway?)
Last edited by Pacopag (2013-05-30 18:46:44)
Offline
...
mhm cant i delete my own posts?
Last edited by weltio (2013-05-30 19:09:32)
Offline
...
mhm cant i delete my own posts?
Offline