2

I'm setting up rsync to transfer files from ServerA to ServerB, and need to preserve timestamps and permissions. They key here is the files are owned by a different account than the one performing the file transfer.

rsync transfers files using the example below:

rsync -a /colorschemes/ acoder@bu.my.box.net:/colorschemes/ --delete

The -a flag yields the following types of errors:

rsync: failed to set times on "/colorschemes/946/ex": Operation not permitted (1)
rsync: failed to set permissions on "/colorschemes/946/ex/blue.pdf": Operation not permitted (1)

On the remote system, the acoder account has a similar error when attempting to manually set permissions on a file:

[acoder@bu ~]$ chown apache:codingteam /colorschemes/946
chown: changing ownership of ‘/colorschemes/946’: Operation not permitted

This works OK, though:

[acoder@bu ~]$ sudo chown apache:codingteam /colorschemes/946

Is there a way to make the remote rsync use sudo?

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
a coder
  • 3,253

1 Answers1

7

For using sudo with rsync in remote machine you can call it with --rsync-path="sudo rsync" but be aware of the require TTY, you skip it by removing Defaults requiretty from sudoers file.

If you want to change the permission for anything you don't own, you have to use sudo if you were not root

or there is a different way like setting a setuid on chmod, chown then any one can run the chmod, chown as a root, but that will be horrible.