How to run Rsync with preserving Ownership, Permission, Group?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
You need to run the command as root. If you do it with any other person, all files will be created with that account. Only root has the ability to change the ownership of a file.
What is the destination file system? Is it a network file share of some sort? Depending on the destination file system and possibly folder settings, there may be something that is overriding root's normal local capabilities.
For example, if you are using sshfs, the abilities will be limited to the abilities of the login used to mount the share.
Something curiously maps ownership in your target directory to the guest user...
Could you tell more about target directory, is it a mounted directory from network, if yes what protocol?
edit, yes as @IsaacKuo says... Sorry didn't read the posts on page 2
As already noted, if you use a regular user, such as guest, all files created will be owned by that user. Root is the only user which can change ownership of a file.
Your command explicitly uses the userid "guest" to log into backup.mydomain.co.id.
if I tried to rsync specific user it run correctly (the ownership preserved)
rsync -rtvuaz /home3/user1.backup root@backup.mydomain.co.id:/backup/VIP/10.100.100.50 --> this will preserved ownership for user1
but if I run:
rsync -rtvuaz /home3 root@backup.mydomain.co.id:/backup/VIP/10.100.100.50 --> all folders owned by root..
or
rsync -rtvuaz /home3/* root@backup.mydomain.co.id:/backup/VIP/10.100.100.50 --> all folders owned by root..
Do you know for sure which remote shell the rsync command is using? I personally do not use rsync in this fashion, so I can't be certain ... I think by default the way you state it an unencrypted connection is used. Probably not a good idea, since I'm guessing this data is being transferred over the internet (as you seem to be using a fully qualified domain name).
In any case, the remote shell you are using may not be properly configured to provide root with full access rights. The usual thing, I think, is to use "-e ssh" to specify ssh shell - for the sake of encryption and security. You'll have to configure ssh to allow root login, of course, and for security's sake you'll likely want to disallow password login (only allowing key based authentication).
Finally, it is still possible there is something funny about the destination file system or parent folder properties. You have not said anything about the destination file system or the parent folder properties yet.
Do you know for sure which remote shell the rsync command is using? I personally do not use rsync in this fashion, so I can't be certain ... I think by default the way you state it an unencrypted connection is used. Probably not a good idea, since I'm guessing this data is being transferred over the internet (as you seem to be using a fully qualified domain name).
In any case, the remote shell you are using may not be properly configured to provide root with full access rights. The usual thing, I think, is to use "-e ssh" to specify ssh shell - for the sake of encryption and security. You'll have to configure ssh to allow root login, of course, and for security's sake you'll likely want to disallow password login (only allowing key based authentication).
Finally, it is still possible there is something funny about the destination file system or parent folder properties. You have not said anything about the destination file system or the parent folder properties yet.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.