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.

E-mail backup file
#21
Hi @all,

I've used the script from post #3. Unfortunately I getting the following message:

Code:
Backup 31.10.2021 11:11:08
* 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. r1sm14767364wmr.36 - gsmtp


Does anybody has a working guideline how to do it?

Many thanks!

Best Regards
Steffen
Reply
#22
https://forum.logicmachine.net/showthrea...4#pid10124
------------------------------
Ctrl+F5
Reply
#23
Many thanks. I changed the file name to .pdf and it is working fine now.
Reply
#24
(08.11.2016, 22:32)baggins Wrote:
(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. Smile

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*')

thanks i use it for a small month for now.
it did worked for me for 12 days without problems. after these days, i only get a backup of 0 Bytes.
all is working again, i think there where to big pictures and my export was 25MB.

But after this i didn't saw there is an issue.
My question, is it possible to get an error when the backup is just 0 bytes or below 100kb?
Reply
#25
Line 42 is incorrect. It leads to old backups not being removed. It should be this:
Code:
os.execute('cd /home/ftp && rm -rf backup-*')
Reply
#26
Thanks again, admin

because vacation and try to make more scripts these week, and my LM who create bad backups.
is it also possible to just make a backup from only the scripts on the LM and sent them with ftp?

i know the option to make backup by 'Backup scripts' but maybe it is also possible to do it automatic?
Reply
#27
Hi, the latest E-mail backup script fails for me (error is nil) and still responds email send. Is there some kind of file size limit if using gmail? I have 17 logicmachines in one location and a few works (the backup file size is about 150 kb), but all the bigger ones (about 800kb) fail to send the mail.
Reply
#28
Gmail is blocking backup attachments because there is a .js file inside which they consider harmful.
Reply
#29
(10.02.2022, 08:15)admin Wrote: Gmail is blocking backup attachments because there is a .js file inside which they consider harmful.

I know, but why some work? LMs have the latest stable firmware.
Reply
#30
Yesterday i was logged in to my Wiser/LM
i saw there all my backups still on my Wiser.
The script is working, i got my backup on my FTP server, but the backups are also still on my Wiser, it looks like, they don't delete the backup files.

my question is, is there something wrong with my clean up line?

Code:
--source: https://forum.logicmachine.net/showthread.php?tid=396&pid=2488#pid2488

--Take a backup and ftp to NAS
-- name of backup file
src = 'Project-Wiser_for_KNX-' .. 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 = '/Backup en Exports/Wiser/200 Meterkast/Backup/' .. src            --for backup Wiser Primair 200
--target = '/Backup en Exports/Wiser (201) sec/Backup sec/' .. src            --fro backup Wiser Secundair 201


-- 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 = "192.168.3.58",
  user = "FTP-User",
  password = "my_password",
  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*')
Reply
#31
Line 46 should be:
Code:
os.execute('cd /home/ftp && rm -rf Project-*')
Reply
#32
Thanks Admin, now i see what is was going i\on, i changed the name, from Backup to Project, and with this rule, you delete is, but he couldn find the file.
Reply
#33
Hello Admin,

Can this upload to ftp script be adjusted to save the file in an Azure blobstorage container?

Account: xxxxxxxxxx@engweufileexchange.blob.core.windows.net
Pass: xxxxxxxxx

Thank you in advance for your reply.
Reply
#34
Azure doesn't support FTP so this example won't work.
Reply
#35
(24.11.2022, 07:52)admin Wrote: Azure doesn't support FTP so this example won't work.

It is an SFTP. 

So is it possible to login to that account and save the backup?
Reply
#36
SFTP and FTP are completely different protocols. SFTP is file transfer over SSH.
Reply
#37
(24.11.2022, 09:38)admin Wrote: SFTP and FTP are completely different protocols. SFTP is file transfer over SSH.

Thank you Admin fro your quick reply.

So to conclude this is not possible then?

The only way is to have a FTP server localy and upload the backup file right?
Reply
#38
It should be possible via Azure REST API but there are no examples for this. But using an FTP server is much easier.
Reply
#39
Hello All,

I am trying to figure out how to send the backup file to more than one recipients using this script without success.

How would this part of the script look like if I want to send the mail to two, three ... recipients?

Code:
--Recipient for e-mail
to = 'example@hotmail.com'
alias_to = ''

--Subject for e-mail
subjectpart1 = 'MainSL Back-up file'
subjectpart2 = ''

image_description = 'Backup from MainSL'

--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-mail.outlook.com',
    port = 587,
    secure = 'starttls',
}

--Create attachment
src = 'MainSL_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 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
},

Any input on the solution would be apreciated.

Regards
Reply
#40
Use this:
Code:
to = { 'user1@example.com', 'user2@example.com', 'user3@example.com' }

for index, email in ipairs(to) do
  to[ index ] = '<' .. tostring(email) .. '>'
end

--Create e-mail header
settings.source = smtp.message{
headers = {
  from = '' .. alias_from .. ' ' .. from .. '',
  to = table.concat(to, ', '),
  subject = subject
},
Reply


Forum Jump: