19.09.2017, 18:56
(This post was last modified: 19.09.2017, 18:56 by Erwin van der Zwart.)
Hi,
Try this:
BR,
Erwin
Try this:
Code:
require('socket.ftp')
-- Get hostname
hostname = io.readfile('/proc/sys/kernel/hostname'):trim()
-- ftp file
ftpfile = string.format('ftp://user:password@192.168.10.1/backup-' .. hostname .. '-' .. os.date('%Y.%m.%d') .. '.tar.gz')
--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 .. ' ./')
-- upload to ftp
result, err = socket.ftp.put(ftpfile, io.readfile(dst))
-- error while uploading
if err then
log('FTP upload error: %s', tostring(err))
else
log('file uploaded to external ftp')
end
--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*')
--Delete temp file from HL ftp
os.remove(dst)
BR,
Erwin