Dynamic exclusion list in lsyncd

Hi!
Our cloud platform is powered by opennebula. So we have two instances of the frontend in “cold swap”. We use lsyncd daemon trying to keep instances in datastores synced, but there are some points: we don’t want to sync VM’s images that have an extension .bak cause of the other script moves all the .bak to other storage on schedule. The sync script logic looks like find all the .bak in /var/lib/one/datastores/ then create exclude.lst and then start lsyncd. Seems OK until we take a look at the datastores:

oneadmin@nola:~/cluster$ dir /var/lib/one/datastores/1/
006e099c57061d87d4b8f78ec7199221
008a10fa0764c9ac8d6fb9206c9b69bd
069299977f2fea243a837efed271182f
0a73a9adf74d92b4f175abcb578cabac
0b1cc002e370e1acd880cf781df0a6fb
0b470b182ac6d554774a3615ce87e292
0c0d98d1e0aabc23ef548ddb564c578d
0c3fad9c92a8efc7e13a73d8ae85caa3

…and so on.

We solved it with this monstrous function:

function create_exclude {
oneimage list -x |
xmlstarlet sel -t -m “IMAGE_POOL/IMAGE” -v “ID” -o “;” -v “NAME” -o “;” -v “SOURCE” -o “:” |
sed s/:/’\n’/g |
awk -F";" ‘/.bak;/var/lib/ {print $3}’ |
cut -d / -f8 > /var/lib/one/cluster/exclude.lst
}

The result is the list which contains VM IDs with .bak images inside so we can exclude the whole VM folder from syncing. That’s not kinda what we wanted, as the original image stays not synced. But it could be solved by restart the lsyncd script at the moment when other script moves all the .bak to other storage.

Now we get to the topic of the question.

It works until a new .bak will created. No way to add new string in exclude.lst “on the go” but to stop lsync and restart script which re-creates exclude.lst. But there is also no possibility to check the moment of creation a new .bak except another script that will monitor it in some period.

I believe that less complicated solution exists. It depends on opennebula of course, particularly in the way of the /datastores/ folder stores VMs.