Posts: 115
Threads: 23
Joined: Sep 2021
Reputation:
2
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
Posts: 4646
Threads: 24
Joined: Aug 2017
Reputation:
207
------------------------------
Ctrl+F5
Posts: 115
Threads: 23
Joined: Sep 2021
Reputation:
2
Many thanks. I changed the file name to .pdf and it is working fine now.
Posts: 167
Threads: 20
Joined: Apr 2017
Reputation:
2
(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.
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?
Posts: 7764
Threads: 42
Joined: Jun 2015
Reputation:
447
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-*')
Posts: 167
Threads: 20
Joined: Apr 2017
Reputation:
2
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?
Posts: 14
Threads: 0
Joined: Apr 2020
Reputation:
2
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.
Posts: 7764
Threads: 42
Joined: Jun 2015
Reputation:
447
Gmail is blocking backup attachments because there is a .js file inside which they consider harmful.
Posts: 14
Threads: 0
Joined: Apr 2020
Reputation:
2
(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.
Posts: 167
Threads: 20
Joined: Apr 2017
Reputation:
2
22.03.2022, 14:30
(This post was last modified: 22.03.2022, 14:32 by Dré.)
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*')
Posts: 7764
Threads: 42
Joined: Jun 2015
Reputation:
447
Line 46 should be:
Code: os.execute('cd /home/ftp && rm -rf Project-*')
Posts: 167
Threads: 20
Joined: Apr 2017
Reputation:
2
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.
Posts: 133
Threads: 19
Joined: Apr 2018
Reputation:
0
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.
Posts: 7764
Threads: 42
Joined: Jun 2015
Reputation:
447
Azure doesn't support FTP so this example won't work.
Posts: 133
Threads: 19
Joined: Apr 2018
Reputation:
0
(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?
Posts: 7764
Threads: 42
Joined: Jun 2015
Reputation:
447
SFTP and FTP are completely different protocols. SFTP is file transfer over SSH.
Posts: 133
Threads: 19
Joined: Apr 2018
Reputation:
0
(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?
Posts: 7764
Threads: 42
Joined: Jun 2015
Reputation:
447
It should be possible via Azure REST API but there are no examples for this. But using an FTP server is much easier.
Posts: 133
Threads: 19
Joined: Apr 2018
Reputation:
0
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
Posts: 7764
Threads: 42
Joined: Jun 2015
Reputation:
447
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
},
|