08.11.2016, 22:32
(19.10.2016, 17:58)PassivPluss Wrote: I get the following log
*String send mail
*nil
*string revcd alert fatal error
Another way to run this script would be to upload to ftp server.
Hi PassivPluss,
This is an example (for LM4 firmware 20160714) of how to upload to a ftp server:
Code:
--Take a backup and ftp to NAS
-- name of backup file
src = 'backup-' .. os.date('%Y.%m.%d_%H-%M') .. '.tar.gz'
-- where to put backup file on LM
dst = '/home/ftp/' .. src
-- where to put the backup on NAS
target = '<ftpdir>' .. src
-- prepare files for backup
os.execute('sh /lib/genohm-scada/web/general/backup.sh')
-- create archive
os.execute('cd /lib/genohm-scada/storage && tar -c -z -f ' .. dst .. ' ./')
-- load the ftp support
local ftp = require("socket.ftp")
local ltn12 = require("ltn12")
-- ftp to NAS
f, e = ftp.put{
host = "<ip_address_of_ftp_server>",
user = "<ftp_user>",
password = "<ftp_user_pwd>",
type = "i",
argument = target,
source = ltn12.source.file(io.open(dst, "rb"))
}
if (e) then
log (e)
log (f)
alert("Could not ftp: ", e, "\n")
end
log("ftp_backup")
-- cleanup
os.execute('cd /home/ftp && rm -rf backup_*')
os.execute('cd /lib/genohm-scada/storage && rm -rf user userlib.luas blockly.luas initscript.lua helpers.js genohm-scada.config filter*')