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.

Email Backup file stops
#1
I use this script below on an LM5.

When i start the script the email is received. And everything is working fine. But after it runs the active goes of, and shows as red. So next month no backup is sent. 
Activating the script again an email is sent. 

Any idea why the script stops, or what to try?

   

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)
Reply


Messages In This Thread
Email Backup file stops - by Tokatubs - 07.04.2021, 10:13
RE: Email Backup file stops - by admin - 07.04.2021, 10:14
RE: Email Backup file stops - by Tokatubs - 07.04.2021, 10:15
RE: Email Backup file stops - by Krstfr2k - 11.06.2021, 11:57
RE: Email Backup file stops - by admin - 11.06.2021, 12:14

Forum Jump: