This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Best way for synchronize objects on LMs
#1
Hello,

What is the best way for synchronize projects over a few LMs?

I see that Import neighbours works sometimes but not in all cases e.g. I have LM LB and LM3 V2 and I cannot import objects between them (import objects from LM LB to LM3, 'Remote services' are on and the error is 401), or probably to use this function for all objects I must mark all of them as 'Export'. And also when there is a conflict not all objects will be imported.

I think Export should be added to interface same as Import, maybe with some conditions like what to do when there is some conflict.
Done is better than perfect
Reply
#2
Hi
Yes objects must  be exported.
You can make an LP file which would read all the objects and on another LM script which would read it from other LM and update its DB.

Here is example which will sync scheduler and scenes done for redundancy operation. You can modify.

Master LP
Code:
<?

require('apps')

result = {}
tables = {
  'scenes', 'scene_tags', 'scene_sequence',
  'schedulers', 'scheduler_events', 'scheduler_holidays'
}

for _, tname in ipairs(tables) do
  result[ tname ] = db:getall('SELECT * FROM ' .. tname) end

json.write(result)

Slave script

Code:
json = require('json')
http = require('socket.http')

function clearschedulers()
  local files = io.ls('/tmp')
  for _, file in ipairs(files) do
    if file:find('lm-scheduler-', 1, true) then
      os.remove('/tmp/' .. file)
    end
  end
end

function import(data)
 for tname, rows in pairs(data) do
   db:query('DELETE FROM ' .. tname)

   for _, row in ipairs(rows) do
     db:insert(tname, row)
   end
 end

 scene.reload()
 clearschedulers()
end

data = http.request('http://admin:admin@192.168.1.12/user/redundancy.lp')
if data then
  data = json.pdecode(data)

  if type(data) == 'table' then
    import(data)
  end
end
------------------------------
Ctrl+F5
Reply
#3
Thanks, nice way, I will check but please integrate in interface such function (simple export)Wink
Done is better than perfect
Reply


Forum Jump: