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: lm-backup.tar.gz: No such file or directory
#1
Hi Erwin,

I use multiple SpaceLynk's and have tried your example script to backup and mail automaticlly.
But everytime at execution I get this error message and no Mail is send:

Code:
EMail Backup am 1. des Monats copy 24.06.2016 09:10:07
* string: /tmp/lm-backup.tar.gz: No such file or directory

Is the local backup file named different?

I tried it in SL with 1.1.1 and 1.2.0 Firmware's

Can you help me in this case?

thx forwards

Regards
Habib
Reply
#2
Hi Habib,

The new FW 1.2 for SL and 1.5 for HL requires a change in the mail script.

1) Make sure you have changed your g-mail account to enable HL to send e-mail on https://www.google.com/settings/security/lesssecureapps
2) Change user and password in the script
3) Change sender and receiver details in the script

Code:
--***************************************************************--
--** Email backup as attachment created by Erwin van der Zwart **--
--****** For HL from FW 1.5 and SL from FW 1.2 with NGINX *******--
--***************************************************************--
--********************* Start of parameters *********************--
--***************************************************************--

--Gmail (smtp) username !IMPORTANT!
user = 'YOUR EMAIL ADRESS'

--Gmail (smtp) password !IMPORTANT!
password = 'YOUR PASSWORD'

--Sender for e-mail
from = '<' .. user .. '>'
alias_from = 'YOUR ALIAS'

--Recipient for e-mail
to = '<receiver@domain.com>'
alias_to = 'receiver'

--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 inside FTP server
id = 'HL_192.168.0.10-' -- Give here your details of your HL
src = 'backup-'..id.. os.date('%Y.%m.%d.%H.%M.%S') .. '.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 .. ' ./')
-- post-backup cleanup
os.execute('cd /lib/genohm-scada/storage && rm -rf user userlib.luas blockly.luas initscript.lua helpers.js genohm-scada.config filter*')

--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("Mail Send")
--Delete created backup file from ftp folder inside HL
os.remove(dst)

BR,

Erwin van der Zwart
Reply
#3
Hi Erwin,

many thanks for the script. I had a little bit trouble with copy&paste from this forum page to my script page, but now it works after correction of all CR and LR signs.
Last thing is, the script has trouble with the @ and SPACE Sign in Alias variable. It's only cosmetic.

Thanks again

Regards
Habib
Reply
#4
HI Habib, 

Your welcome (:

The problem with copy paste is Chrome issue, use another browser to avoid this or paste the code into MS word and copy it again before pasting it into your controller.

Alias is used for name instead of email address and it should be possible to have a space, I use it with my name so there are multiple spaces in my alias and that works normal.  Never tested with @ ...

Best Regards,

Ewin van der Zwart
Reply
#5
Hi Erwin,

I tried copy&paste with Safari in OSX (an Webkit Browser like Chrome) and in my VM with Windows 7 and Firefox 47.0.
I've sent you an PM with screenshots for viewing the Mail Header in Outlook 2016 (Mac). It's only for understanding my fail.

Thx again

Regards
Habib
Reply
#6
(25.06.2016, 08:55)Erwin van der Zwart Wrote: Hi Habib,

The new FW 1.2 for SL and 1.5 for HL requires a change in the mail script.

1) Make sure you have changed your g-mail account to enable HL to send e-mail on https://www.google.com/settings/security/lesssecureapps
2) Change user and password in the script
3) Change sender and receiver details in the script

Code:
--***************************************************************--
--** Email backup as attachment created by Erwin van der Zwart **--
--****** For HL from FW 1.5 and SL from FW 1.2 with NGINX *******--
--***************************************************************--
--********************* Start of parameters *********************--
--***************************************************************--

--Gmail (smtp) username !IMPORTANT!
user = 'YOUR EMAIL ADRESS'

--Gmail (smtp) password !IMPORTANT!
password = 'YOUR PASSWORD'

--Sender for e-mail
from = '<' .. user .. '>'
alias_from = 'YOUR ALIAS'

--Recipient for e-mail
to = '<receiver@domain.com>'
alias_to = 'receiver'

--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 inside FTP server
id = 'HL_192.168.0.10-' -- Give here your details of your HL
src = 'backup-'..id.. os.date('%Y.%m.%d.%H.%M.%S') .. '.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 .. ' ./')
-- post-backup cleanup
os.execute('cd /lib/genohm-scada/storage && rm -rf user userlib.luas blockly.luas initscript.lua helpers.js genohm-scada.config filter*')

--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("Mail Send")
--Delete created backup file from ftp folder inside HL
os.remove(dst)

BR,

Erwin van der Zwart

Hi Erwin, 

I am trying to send backup by email with the scritp you mention, but google throws me an error (I send the capture). My HL is in the latest version, both soft and hard.
Maybe the solution is to change the mail provider? Any suggestions in the scritp to keep it?

Thank you very much in advance, I learn a lot here :-)

Regards,
Reply
#7
Hi
I use gmail and they block any compressed files. This is most likely this,
BR
------------------------------
Ctrl+F5
Reply
#8
Hi,

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. 

Code:
src = 'backup-'..id.. os.date('%Y.%m.%d.%H.%M.%S') .. '.bck'

BR
Jean-Marc
Reply
#9
(30.05.2018, 16:05)JMM Wrote: Hi,

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. 

Code:
src = 'backup-'..id.. os.date('%Y.%m.%d.%H.%M.%S') .. '.bck'

BR

Hi 

I tried the extension change or without it, but Mr. Google is a smart guy ...
Same mistake.
Any suggestions that work well to change the mail provider?

Best Regards !!
Reply
#10
Hi,

For me it works well with ".pdf" Wink 

BR
Jean-Marc
Reply
#11
Hi,

There are other options, you could use the mail server of your ISP, or any mailserver you might have onsite instead of using the gmail server.

BR,

Erwin
Reply


Forum Jump: