Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

lsyncd rsync web servers.

Posted on 2013-05-24
11
2,261 Views
Last Modified: 2013-05-24
Hi guys,
Very new to Linux, so be gentle and spell things out for me ;)

System
2 x Centos servers (Master, Slave)

both host the same website sitting behind a loadbalancer (Least active connections).

I keep the servers in replicating the Master to the Slave.
Using Lsyncd.

Issue:-
all is working, however when files/directories transfer to the slave their owner and group change to root:root.
I can fix it by using chown, but would like it if they kept there owner:group (they are same on both machines) or inherited from their parent directory. Either would do.

here is a copy of /etc/lsyncd.lua
settings {
   logfile = "/var/log/lsyncd/lsyncd.log",
   statusFile = "/var/log/lsyncd/lsyncd-status.log",
   statusInterval = 2
}

sync {
	default.rsync,
	source="/home/mysite/public_html/",
	target="10.176.6.23:/home/mysite/public_html/",
	excludeFrom="/etc/lsyncd-excludes.txt",
	rsync = {
		compress = true,
		acls = true,
		verbose = true,
		rsh = "/usr/bin/ssh -p 22 -o StrictHostKeyChecking=no"
	}
}

Open in new window


Any assistance would be appreciated.

Cheers
Andrew
0
Comment
Question by:Andrew Davis
  • 7
  • 4
11 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 39194022
Include

rsyncOpts="-lptgoD"

inside this block:


rsync = {
            compress = true,
            acls = true,
            verbose = true,
            rsh = "/usr/bin/ssh -p 22 -o StrictHostKeyChecking=no"
            rsyncOpts="-lptgoD"
      }


See "man rsync" for the meaning of the single option letters.

In brief:

l = copy symlinks as symlinks
p = preserve permissions
t = preserve modification times
g = preserve group
o = preserve owner
D = preserve device files / preserve special files

This will have no effect on existing files, so best start over with empty target directories.
0
 
LVL 18

Author Comment

by:Andrew Davis
ID: 39194474
now i get the error:

Starting lsyncd: Error: error loading /etc/lsyncd.lua: /etc/lsyncd.lua:17: '}' expected (to close '{' at line 12) near 'rsyncOpts'

Double checked all the close brackets are there, an if i just delete the line rsyncOpts="-lptgoD"

I can then start the service again. Makes no sense. If it matters I am using nano to edit.

Cheers
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 39194500
Sorry, I made a mistake when posting the example - there is a comma missing past
rsh = "/usr/bin/ssh -p 22 -o StrictHostKeyChecking=no"

rsync = {
            compress = true,
            acls = true,
            verbose = true,
            rsh = "/usr/bin/ssh -p 22 -o StrictHostKeyChecking=no",
            rsyncOpts="-lptgoD"
      }
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 18

Author Comment

by:Andrew Davis
ID: 39194516
That makes sense ;)

Now i get

Starting lsyncd: Error: error preparing /etc/lsyncd.lua: Parameter "rsync.rsyncOpts" unknown. (if this is not a typo add it to checkgauge)

Duh :(
0
 
LVL 18

Author Comment

by:Andrew Davis
ID: 39194539
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 39194575
OK,

seems the've introduced a new set of parameters with lsyncd 2.1.

So try the single options as described in your link, like "owner", "perms" etc.

You could also try "archive=true" which should include all required flags (if it's at all comparable to the rsync option "--archive", that is).
0
 
LVL 18

Author Comment

by:Andrew Davis
ID: 39194586
tried

owner = true,
perms = true

This did the owner but not the group :(
Would be nice if they gave you a bit of a description as to what each setting is.
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 39194605
Strange.

Maybe they just forgot to mention "group" in their docs??

I'd try "group=true" and also "archive=true" and see what happens.
0
 
LVL 18

Author Comment

by:Andrew Davis
ID: 39194613
Thanks heaps for your assistance.

I tried the Archive = True (it wasnt mentioned either) and this worked.
I will give "group" a try out of curiosity. Hell what else am i going to do while waiting for SQL replications ;)

Cheers
Andrew
0
 
LVL 18

Author Comment

by:Andrew Davis
ID: 39194627
Yep Group works as well.

Any idea where i am likely to find a complete table with explanations?

Cheers
0
 
LVL 18

Author Closing Comment

by:Andrew Davis
ID: 39194630
Good fun was had by all.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question