Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I seem to come up against this issue occasionally:

serverA assets:
owned by user: apache
(no 'ftp' user present)

serverB assets:
owned by user: ftp
(apache user present, but not used)

I connect to serverA as root, then rsync over ssh to serverB as root. After which, all the assets on serverB are owned by either root or apache, depending on whether or not I tell rsync to preserve the ownership that the files have on serverA.

Anyone have any tricks for changing ownership of rsync'ed files on serverB to an alternate user, one that is not the owner on serverA and is not the user issuing the rsync command? The resulting files on serverB would be owned by the 'ftp' user.

In the past, I've always just followed the command with a recursive chown, but I'd like to find a way to do this in rsync, or get it down to a single command.

share|improve this question
add comment

1 Answer 1

Try setting RSYNC_RSH to "ssh -o 'User apache'"
and/or using --rsync-path='su apache -c rsync'
or patch the rsync source to support setting abitrary users.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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