2

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.

2 Answers 2

0

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.

0

You can do this most simply by stipulating the ftp user in the rsync command line:

# rsync -av /serverA/source/path/ ftp@serverB:/serverB/destination/path/

You will be prompted for the ftp account password on serverB.

The files in the destination path /serverB/destination/path/ on serverB must be writable by the ftp user.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .