You are not logged in.

#1 2013-05-30 15:30:13

Pacopag
Member
Registered: 2011-05-29
Posts: 287

[SOLVED] Why does rsync change ownership on remote system?

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

#2 2013-05-30 15:36:50

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: [SOLVED] Why does rsync change ownership on remote system?

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

#3 2013-05-30 16:20:23

Pacopag
Member
Registered: 2011-05-29
Posts: 287

Re: [SOLVED] Why does rsync change ownership on remote system?

Rsync command is (redacted)

rsync -rlzuogv --delete --stats --progress -e "ssh -i /path/to/private/key" /source/folder user@hostname:/destination/folder

Local 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

#4 2013-05-30 16:37:57

weltio
Member
From: Germany
Registered: 2009-04-05
Posts: 89

Re: [SOLVED] Why does rsync change ownership on remote system?

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

#5 2013-05-30 16:45:46

Pacopag
Member
Registered: 2011-05-29
Posts: 287

Re: [SOLVED] Why does rsync change ownership on remote system?

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

#6 2013-05-30 17:10:14

Pacopag
Member
Registered: 2011-05-29
Posts: 287

Re: [SOLVED] Why does rsync change ownership on remote system?

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

#7 2013-05-30 17:26:53

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: [SOLVED] Why does rsync change ownership on remote system?

Pacopag wrote:

Whenever I sync files, rsync changes the owner:group of the files on the remote server to my_local_uer:my_local_group.

Pacopag wrote:

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

#8 2013-05-30 17:37:23

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: [SOLVED] Why does rsync change ownership on remote system?

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

#9 2013-05-30 17:54:39

Pacopag
Member
Registered: 2011-05-29
Posts: 287

Re: [SOLVED] Why does rsync change ownership on remote system?

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

#10 2013-05-30 18:24:52

Pacopag
Member
Registered: 2011-05-29
Posts: 287

Re: [SOLVED] Why does rsync change ownership on remote system?

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

#11 2013-05-30 18:45:28

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: [SOLVED] Why does rsync change ownership on remote system?

Pacopag wrote:

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

#12 2013-05-30 18:45:35

Pacopag
Member
Registered: 2011-05-29
Posts: 287

Re: [SOLVED] Why does rsync change ownership on remote system?

Ok.  It seems like this worked

sudo chgrp groupname folder

Where "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

#13 2013-05-30 19:07:54

weltio
Member
From: Germany
Registered: 2009-04-05
Posts: 89

Re: [SOLVED] Why does rsync change ownership on remote system?

...
mhm cant i delete my own posts?

Last edited by weltio (2013-05-30 19:09:32)

Offline

#14 2013-05-30 19:56:27

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [SOLVED] Why does rsync change ownership on remote system?

weltio wrote:

...
mhm cant i delete my own posts?


No. https://wiki.archlinux.org/index.php/Fo … way_Street


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB