Centos – rsync permission problems

centospermissionsrsyncusers

First, I know that it was discussed before but I cannot seem to find a reliable solution for this…

I have CentOS 5 with Plesk panel on my remote server where I have sites that need to be backed up. Then I have a local CentOS 6 server with no cpanel (just Webmin installed if it maters).

I am trying to back up my sites from remote server to local server using rsync.
It works ok with some new folders from server root but I cannot get into the www directory. I am getting permission errors.

Command is:

rsync -avz --progress adrian@site.com:/var/www/vhosts/site.com/httpdocs/ /_backups

Then it asks for password, I am entering it and after login it says:

rsync: link_stat "/var/www/vhosts/site.com/httpdocs/." failed: Permission denied (13)

Normally when I login by ssh to remote server I cannot login directly with "root" but I login with "adrian" and shows adrian@site in ssh window and then I type "su" and it asks for password again, then I see root@site in ssh window.
So I assume is because of this I cannot do rsync directly with root@site.com

Any ideas?

Would it work to create a user adrian_rsync that has its home directory inside the www folder? If so, how can I do that?

Or maybe is there a way to pass the "su" and its password to the rsync command?

Best Answer

There are several ways to do this:

  1. Use root account in rsync if root login is allowed and root has a password.
  2. Grant your user read permissions on the needed files/folder. This can be done by adding your user to a group which has read access. For example, if nobody group has rx access to this folder, you can add your user to nobody and it should work.
  3. SSH to the server and copy this folder as root and chown to your user. Then, you can rsync remotely the copied version (not convenient).
Related Topic