Reputation: 649
I have two servers: source-server and target-server. I want use lsyncd to sync files in a directory on source-server to another directory on target-server.
In my ssh daemon, on both servers, I have root logins disabled (PermitRootLogin no
) so I can't use the root user to run lsyncd over ssh.
I created a user 'syncer' on both servers that has a key-pair allowing password-less ssh logins from source-server to target-server. So this works:
[syncer@source-server]$ ssh syncer@target-server
My lsyncd.conf looks like this:
settings = {
logfile = "/var/log/lsyncd.log",
statusFile = "/var/log/lsyncd.stat",
statusInterval = 2
}
sync {
default.rsync,
source="/var/www/html/",
target="target.server.ip:/backup/",
rsync = {
rsh ="/usr/bin/ssh -l syncer -i /home/syncer/.ssh/id_rsa",
compress = true,
acls = true,
xattrs = true,
archive = true
}
}
And it works except the owner of replicated files on the target server is always 'syncer'. The permissions of the source are respected and replicated correctly on the target. I just can't figure out a way to preserve the owner (and group) of the replicated files. (i.e., if the file on source is owned by 'deknuth', I would like the synced file on target to also be owned by 'deknuth' not 'syncer').
TIA
Upvotes: 4
Views: 2858
Reputation: 649
To close this out, using the non-root user will always move a file with that non-root user being the owner on the destination -- regardless of who owned it on the source. This may be acceptable. If not, run lsyncd as root and allow root logins with a key pair.
Upvotes: 1