0

I am using Rsync to deploy to a remote server, which is working. However the file and directory ownership always replaces old files with root:root

I need the ownership of all files and folders transferred to the destination folder on the remote server to be changed to www-data:www-data.

I need to access the server as root via ssh, as I don't have the password for www-data. At the moment I have to transfer all the files, and then run the chown command in Terminal afterwards, but I'd like to automate this.

At the moment I am trying the following, but it doesn't work or transfer any files.

'rsync -rlDvz -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --progress --exclude exclude --exclude .htaccess --exclude site/accounts source root@ip:dest && chown -R user:group dest'

Thanks

0

Try rsync -aAX

This should transfer both ownership/group and extended attribute (eg: selinux)

0

Rsync has the --usermap and --groupmap in version 3.1.0 and above

https://rsync.samba.org/ftp/rsync/src/rsync-3.1.0-NEWS

So if you have 3.1 or above version, you can use either --usermap=www-data:www-data or --chown=www-data:www-data in rsync command like below

rsync --chown=user:group -rlDvz -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --progress source user@ip:dest

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.