Posts: 136
Threads: 20
Joined: Jul 2015
Reputation:
0
21.09.2016, 16:47
(This post was last modified: 21.09.2016, 17:03 by JMM.)
HI,
Since the last update (20160714), which is the path of the file backup ?
With that :
[*]--Create attachment
[*]src = '/tmp/lm-backup.tar.gz'
Error log is:
* string: /tmp/lm-backup.tar.gz: No such file or directory
Thank you .
[*]Solved problem
[*]JMM.
Jean-Marc
Posts: 176
Threads: 42
Joined: Jul 2015
Reputation:
2
(21.09.2016, 16:47)HiI cant make this work. Will it work in latest firmware? Could somebody paste working code?Im using Reactor v2 Thanks in advanceJMM Wrote: HI,
Since the last update (20160714), which is the path of the file backup ?
With that :
[*]--Create attachment
[*]src = '/tmp/lm-backup.tar.gz'
Error log is:
* string: /tmp/lm-backup.tar.gz: No such file or directory
Thank you .
[*]Solved problem
[*]JMM.
Posts: 1764
Threads: 6
Joined: Jul 2015
Reputation:
117
19.10.2016, 09:39
(This post was last modified: 19.10.2016, 09:39 by Erwin van der Zwart.)
Hi,
This should work on latest FW:
Code: --***************************************************************--
--*** For FW spaceLYnk 1.2.1 and FW homeLYnk 1.5.1 or higher ****--
--***************************************************************--
--** Email backup as attachment created by Erwin van der Zwart **--
--***************************************************************--
--********************* Start of parameters *********************--
--***************************************************************--
--Gmail (smtp) username !IMPORTANT!
user = 'YOUR GMAIL ADDRESS'
--Gmail (smtp) password !IMPORTANT!
password = 'YOURPASSWORD'
--Sender for e-mail
from = '<me@whoismailingyou.com>'
alias_from = 'From me'
--Recipient for e-mail
to = '<someone@youwanttomail.com>'
alias_to = 'To you'
--Subject for e-mail
subjectpart1 = 'Back-up file'
subjectpart2 = 'automaticly send by homeLYnk'
--Message on bottom of email (will only be showed when client don't understand attachment)
epilogue = 'End of message'
--***********************************************************--
--******************** End of parameters ********************--
--***********************************************************--
--********** DON'T CHANGE ANYTHING UNDER THIS LINE **********--
--***********************************************************--
--Create table to include mail settings
local settings = {
from = from,
rcpt = to,
user = user,
password = password,
server = 'smtp.gmail.com',
port = 465,
secure = 'sslv23',
}
--Create attachment
src = 'backup-' .. os.date('%Y.%m.%d') .. '.tar.gz'
dst = '/home/ftp/' .. src
-- prepare files for backup
os.execute('sh /lib/genohm-scada/web/general/backup.sh')
-- create cleanup archive
os.execute('cd /lib/genohm-scada/storage && tar -c -z -f ' .. dst .. ' ./')
--Create subject
subject = subjectpart1 .. ": " .. src .. " " .. subjectpart2
--Load required modules to send email with attachment
local smtp = require("socket.smtp")
local mime = require("mime")
local ltn12 = require("ltn12")
--Create e-mail header
settings.source = smtp.message{
headers = {
from = '' .. alias_from .. ' ' .. from .. '',
to = '' .. alias_to .. ' ' .. to .. '',
subject = subject
},
--Load attachment inside body
body = {
preamble = "",
[1] = {
headers = {
["content-type"] = 'application/x-7z-compressed',
["content-disposition"] = 'attachment; filename="'..src..'"',
["content-description"] = '.. src ..',
["content-transfer-encoding"] = "BASE64",
},
body = ltn12.source.chain(
ltn12.source.file(io.open(dst, "rb")),
ltn12.filter.chain(
mime.encode("base64"),
mime.wrap()
)
)
},
epilogue = epilogue
}
}
--Send the email
r, e = smtp.send(settings)
--Create alert when sending gives an error with error message
if (e) then
log (e)
log (r)
alert("Could not send email: ", e, "\n")
end
log("Send Mail")
--Delete created backup file from tmp folder inside HL
os.execute('cd /lib/genohm-scada/storage && rm -rf user userlib.luas blockly.luas initscript.lua helpers.js genohm-scada.config filter*')
-- Disable script automaticly
script.disable(_SCRIPTNAME)
BR,
Erwin van der Zwart
Posts: 176
Threads: 42
Joined: Jul 2015
Reputation:
2
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.
Posts: 1764
Threads: 6
Joined: Jul 2015
Reputation:
117
Hi,
Have you enabled less secure apps inside your gmail account?
https://www.google.com/settings/security/lesssecureapps
BR,
Erwin
Posts: 176
Threads: 42
Joined: Jul 2015
Reputation:
2
I have done this and tested two different Gmail accounts. Ang oter idag?
Posts: 184
Threads: 39
Joined: Sep 2015
Reputation:
4
(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*')
Posts: 87
Threads: 13
Joined: Oct 2015
Reputation:
6
Hi
I still have the last stable firmware but after some tweaks I got it working.
I notice however that the backup does not make a backup of the scripts and mosaic configuration
How could I create a backup of these files that are easy to restore afterwards ?
Thanks
Nicky
Posts: 7768
Threads: 42
Joined: Jun 2015
Reputation:
447
Scripts are always included in the backup, Mosaic 1.0 configuration is stored separately. On the other hand, Mosaic 2.0 uses global storage for its configuration, so it's included in the backup automatically.
Posts: 184
Threads: 39
Joined: Sep 2015
Reputation:
4
(16.11.2016, 07:30)admin Wrote: Scripts are always included in the backup, Mosaic 1.0 configuration is stored separately. On the other hand, Mosaic 2.0 uses global storage for its configuration, so it's included in the backup automatically.
I also took a look in the .tar file and could not find the scripts either. I have also taken a manual backup and had the same result.
The only items in the backup are ./modbus, ./current.db, ./fonts, ./trends, ./icons, ./img, ./blocky.json, ./ekey.db, ./current.md5, ./blocky.luas, ./helper.js, ./backup.md5, ./filter.sh, ./id_rsa, ./user, ./initscript.lua, ./userlib.luas, ./custom.css, ./custom.js, ./backup.db, ./redis.rdb, ./genohm-scada.config
Posts: 7768
Threads: 42
Joined: Jun 2015
Reputation:
447
Scripts and most other things are stored in the main database.
Posts: 87
Threads: 13
Joined: Oct 2015
Reputation:
6
(16.11.2016, 09:11)admin Wrote: Scripts and most other things are stored in the main database.
Thanks for clearing that up
I would still prefer to backup the scripts in readable format just in case new firmware versions do not support the old backups.
Maybe to include in a future release?
Posts: 7768
Threads: 42
Joined: Jun 2015
Reputation:
447
You can always use Backup scripts in Scripting or Print script listing. We will always have compatibility for old backups. In worse case scenario we will provide a fixup patch for really old versions like we did in the past.
Posts: 136
Threads: 20
Joined: Jul 2015
Reputation:
0
27.07.2017, 15:40
(This post was last modified: 27.07.2017, 16:19 by JMM.)
Hi,
For some time it is impossible to send the backup by Gmail .
Error message: ( * string: 552-5.7.0 This message was blocked because its content presents a potential
552-5.7.0 security issue. Please visit
552-5.7.0 https://support.google.com/mail/?p=BlockedMessage to review our
552 5.7.0 message content and attachment content guidelines. 9sm17387246wmo.35 - gsmtp).
Jean-Marc.
Having renamed .tar.gz in .bck the sending is possible
Jean-Marc.
Jean-Marc
Posts: 68
Threads: 3
Joined: Jun 2016
Reputation:
0
Yes google is not allowing archive files in attachment... you just need to either change the extention to another like .txt, .bck, ... or remove it.
Posts: 237
Threads: 31
Joined: May 2018
Reputation:
2
Hi,
I´ve tried to send a backup file by email using this example "http://openrb.com/e-mail-backup-file-once-a-month-from-lm/" but i get this error: 555 5.5.2 Syntax error. x139-v6sm44009148wme.3 - gsmtp.
I,ve tried changing the extention to .bck but i get the same error.
Any idea?
Posts: 4651
Threads: 24
Joined: Aug 2017
Reputation:
207
As mentioned above google is blocking any archives. Apparently deleting the extension or changing it seems to work. You can also try another email provider.
------------------------------
Ctrl+F5
Posts: 237
Threads: 31
Joined: May 2018
Reputation:
2
16.10.2018, 07:37
(This post was last modified: 16.10.2018, 08:06 by DGrandes.)
I´ve tried changing the extension to bck and it doesn´t work, but with .pdf it work perfectly.
Thank you
I´ve a question.
The size of my logic machine backup take 22mb. And when i tried to send it by email, the logic machine restart and doesn´t send it.
With a smaller backup it work.
Why?
Posts: 7768
Threads: 42
Joined: Jun 2015
Reputation:
447
You are probably hitting memory limits. What is your device memory usage during normal operation?
Posts: 237
Threads: 31
Joined: May 2018
Reputation:
2
|