Stephen Hoffman wrote:

Probably been asked a hundred times before, but I'm having trouble with
rsync.

I want to sync two webserver directories on two different machines, but
the permissions are driving me up a wall.  I've googled, and rtfm to no
avail.

I run the following command:
rsync -avre ssh /path/to/local/dir [EMAIL PROTECTED]:/path/to/remote/dir

this goes through the process of syncing just fine, the issue is that the
webserver on local machine runs as apache so user:group are apache:apache,
the user:group on the remote machine are user:nobody.  What is happening
is when I rsync the two then all the uid's:gid's on the remote machine
become apache:apache and thus apache can't access the directories.

I've added the -o and -g, but unless I'm reading wrong they do what is
already happening and transferring the owner and group to the new machine.

I'm working around this by ssh'ing in and chown'ing everything at the end
of the script, but I would think that this should be a native capability
of rsync and wouldn't need to be scripted.

TIA,
Steve


The native capability of rsync is to allow you to keep the same UID/GID when you rsync the files. Optionally, you can leave them the same as they are on the remote machine for files that are already in place (by not specifying anything). What's not natively supported by rsync, that you want, is to change the UID/GID on the fly to something totally different on the other machine. The crux of the problem is that you're trying to sync files between two Apache processes that are running as different users. You are already using the best work around that I would suggest, which is chown'ing them after the transfer. As a real solution, you could coordinate the UID / GID of Apache on the two servers, so that they are the same (presuming that is under your control). That would alleviate the problem more directly - albeit with more *actual* work to be done in making those changes.

Another work around that just came to mind, is to create an apache user and group on the destination machine, and give them the same UID / GID as the nobody : <whatever> - then rsync might inadvertently "do the right thing". Please test, I am not certain if that'll actually do what it sounds like it should. :)

Aaron J.
--
TriLUG mailing list        : http://www.trilug.org/mailman/listinfo/trilug
TriLUG Organizational FAQ  : http://trilug.org/faq/
TriLUG Member Services FAQ : http://members.trilug.org/services_faq/
TriLUG PGP Keyring         : http://trilug.org/~chrish/trilug.asc

Reply via email to