0

I have searched the internet but could not find an answer to my problem with lsyncd.

I am working on a WordPress project and basically I need to exclude a few files from updating/copying over to the slave server. I am using a master/slave setup.

So I this it up on two test servers, both RedHat 7.3 with lsyncd version 2.2.2. I tried to exclude a file from syncing over from 1st server to the 2nd server but it doesn't work. Am not sure why as from what I saw from other posts was to give the full path to the file in question?

Here is my config of my lsyncd.conf file and specifically line 12 where is I try to exclude the file.

1

2 settings {

3 logfile = "/var/log/lsyncd/lsyncd.log",

4 statusFile = "/var/log/lsyncd/lsyncd-status.log",

5 statusInterval = 20

6 }

7 sync

8 {

9 default.rsync, delay=0,

10 source="/usr/share/nginx/",

11 target="10.1.108.87:/usr/share/nginx/",

12 excludeFrom="/usr/share/nginx/html/zexclude/excludefile",

13 rsync= {

14 owner = true,

15 perms = true,

16 group = true,

17 compress = true,

18 acls = true,

19 verbose = true,

20 rsh = "/usr/bin/ssh -p 22 -o StrictHostKeyChecking=no"}

21 }

2 Answers2

0

Two things come to mind: Can your lsyncd process read the exclude file? You should be able to see this in the status log. Also, have no blank lines in the exclude file as that gets interpreted as 'exclude all'.

Simon Greenwood
  • 1,343
  • 9
  • 12
  • Hi Simon, The file is not empty as I put a line of text in it. Also the file gets copied to my slave server which I do not want happening. So I would say that lsyncd is reading the file since it copies it over. Thanks – pbroderi31 Nov 27 '17 at 17:59
  • I am looking to exclude the file from the lsync process so it doesnt get copied. The excludeFrom option doesn't seem to work. Any ideas - Thank you again, – pbroderi31 Nov 27 '17 at 18:00
  • What is the contents of the exclude file? – Simon Greenwood Nov 27 '17 at 20:31
  • I just added a line of plain text like this "test to see that can exclude this file from lsyncd" – pbroderi31 Nov 28 '17 at 13:18
  • However though I will be looking to exclude a WordPress configuration file ultimately. Thank you again Simon. – pbroderi31 Nov 28 '17 at 13:20
  • So, I think what I need to do is to place the folders/files that I do not want sync'd/copied over inside of a file whose path is placed in the lsync.config file. I am going to try that. – pbroderi31 Nov 28 '17 at 14:54
  • You will probably need the full path to these folders to exclude them, I think that might be the issue. – Simon Greenwood Nov 28 '17 at 15:24
  • So this is what I did. I created a file called zexcludsionfile and within that I defined name of file that I wanted to omit with this entry: /usr/share/nginx/html/zexcludefile and I tested and it did not work for me. Any ideas? Thank you. – pbroderi31 Nov 28 '17 at 15:44
  • Are you adding the files with their full path such as /usr/share/nginx/html/filename.txt ? – Simon Greenwood Nov 28 '17 at 15:49
  • I did not use a .txt. extension on the file. I will try that. Thank you. – pbroderi31 Nov 28 '17 at 17:05
  • I mean make sure that you have the full path to the file in your exclude file. lsyncd (and rsync) don't know about individual files or relative paths. – Simon Greenwood Nov 28 '17 at 17:25
  • I added the .txt extension tot he file and ran the lsync and it did not work. – pbroderi31 Nov 28 '17 at 19:23
  • What exactly are you putting in the file, something like `filename.txt` or `/path/to/filename.txt` as it should always be the latter. – Simon Greenwood Nov 29 '17 at 07:27
  • This is my entry in my lsyncd.conf file: excludeFrom="/usr/share/nginx/html/zexclusionfile.txt", Then in my /usr/share/nginx/html folder (this is a wordpress project) I place the file I want to exclude which is zexcludefile.txt. The zexclusionfile.txt has this entry: /usr/share/nginx/html/zexcludefile.txt – pbroderi31 Nov 29 '17 at 13:22
  • However lsyncd still copied over/synch's over the file I am looking to exclude. Do I possibly have it wrote wrong in the files? Thank you. – pbroderi31 Nov 29 '17 at 13:24
  • Try testing the actual rsync command, which should be something like `rsync -arv --exclude-from /usr/share/nginx/html/zexcludefile.txt directory/ remotehost:directory/` Thinking about this though, the exclude function is a regular expression and I suspect that you can't exclude a file that's in the same directory as the excludeFrom file as excludeFrom is basically greedy. – Simon Greenwood Nov 29 '17 at 14:14
  • So what I did was within /etc folder I created a file called lsyncd.exclude. I placed this entry inside of the file lsyncd.exclude as follows: /usr/share/nginx/html/zfile1.php. So basically trying to exclude that file zfile1.php so this way I am not working within the same directory. When I restart lsyncd service the file copies over. Exactly what I don't want to happen. – pbroderi31 Nov 29 '17 at 19:54
  • Have you tested with the rsync command above? – Simon Greenwood Nov 30 '17 at 07:21
  • Hi Simon,I managed to get it t work - I placed an entry like this in my lsyncd.conf file and was able to exclude the files that I didn't want copied over, '`exclude={ 'xxx-config*', },`' So it was a exclude rather than a excludeFrom statement that worked. Thank you again for all your input. – pbroderi31 Nov 30 '17 at 13:16
  • Excellent. Don't forget to answer your question :) I know I've had problems with that in the past and the lsyncd documentation isn't great. – Simon Greenwood Nov 30 '17 at 13:43
0

I resolved this by placing the following entry in the lsyncd.conf file 'exclude={ 'xxx-config*', },

So I used exclude rather than excludeFrom and it corrected my problem.