1752483 Members
5592 Online
108788 Solutions
New Discussion юеВ

Re: Sudo with rsync

 
AnkushKalra
Advisor

Sudo with rsync

Hi,

I am using rsync with sudo on HPUX.

Rsync version:
rsync version 3.0.9 protocol version 30

HPUX Version:

#uname -a
HP-UX SrvName B.11.31 U ia64 0697013711 unlimited-user license

I have created one user "rsynccheck" with sudo rights and he is executing below command.

rsync command:

$rsync -zavru --rsync-path="sudo rsync" /Rsync/file_path /some/path

The command is working fine.My motive for executing above command was that it will preserve users and group of file at destination as it was in source.

The problem is that it is keeping the group at destination as source but changing owner of file to "rsynccheck".

I want to keep same owner and group at source and destination.Please help

Regards

6 REPLIES 6
Bill Hassell
Honored Contributor

Re: Sudo with rsync

From the man page for rsync:

      -o, --owner
           This option causes rsync to set the owner of the destination file
           to be the same as the source file, but only if the receiving
           rsync is being run as the super-user (see also the --super and
           --fake-super options).  Without this option, the owner of new
           and/or transferred files are set to the invoking user on the
           receiving side.

           The preservation of ownership will associate matching names by
           default, but may fall back to using the ID number in some
           circumstances (see also the --numeric-ids option for a full
           discussion).

There is no easy way to make the source and destination systems use the same owner. Ownership is a number in the passwd file and unless the passwd files on both machines have been intelligently synchronized, the owner that you see at the destination may not be the same.

To check this, run this command on both source and destination systems:

grep ^rsynccheck /etc/passwd

The 3rd field (after the second : character) is the number that represents the owner. HP-UX translates this number with commands like ls -l into usernames from the passwd file. To see how HP-UX sees ownership, use the command: ls -ln



Bill Hassell, sysadmin
AnkushKalra
Advisor

Re: Sudo with rsync

Hi,

Thanks for the reply.

I am first testing this on my local server,then i will test this between Two Servers(both HPUX).So the destination path also exists on same server.

I have run below command from "rsynccheck" user

rsync -zavruo rsynccheck --rsync-path='sudo rsync' /some/destination/path

but after executing above command also  only i can see group of source folder same as destination folder..User on destination is stiill "rsynccheck"(User which is executing the command) and is different from source.Please suggest.

 

 

 

Bill Hassell
Honored Contributor

Re: Sudo with rsync

rsync -zavruo rsynccheck --rsync-path='sudo rsync' /some/destination/path

It is not clear what you are doing. Is the rsyncchecek parameter a file or directory? This command will fail if you are not cd'd into a path where just the unqualified path is given. 

For the remote system, it should be:

userName@remoteHost:/some/destination/path

It is not clear at all what you are expecting. The userName at the destnation will *only* match the source when the passwd file uses the same UID (user ID number). And similarly, the GID (group ID number) must match. The GID numbers are found in /etc/group. If either /etc/passwd or /etc/group do not match, then you'll have to run as super user as mentioned in the man page.

It would really help if you pasted the ll command for the source and destination files. 
Don't use: ll rsynccheck
Show the fullpath like this: ll -d $PWD/rsynccheck
on both machines..



Bill Hassell, sysadmin
AnkushKalra
Advisor

Re: Sudo with rsync

Hi,

.Both source("rsynccheck" folder)and destination path(/some/destination/path)

existes on same server."rsyncchecek" is a file which i am trying to copy using rsync.Also i am executing above command using "rsyncchecek" user.

 

Hope this clears your confusion.

 

AnkushKalra
Advisor

Re: Sudo with rsync

Hi,

 

There is a typo error in my above Post.User is "rsynccheck" and also folder name is also "rsynccheck"

I am executing this command to copy one file from source to destination on same server.

 

Thanks for the support provided till now!!!

Bill Hassell
Honored Contributor

Re: Sudo with rsync

It would really help if you copy/paste the ll command results for the source and destination files. 
Don't use: ll rsynccheck
Show the fullpath like this: ll -d $PWD/rsynccheck
at both locations..



Bill Hassell, sysadmin