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.

FTPS example
#14
I would like to point out that the script is used in many web servers, both Schneider and LM, and has always worked and still works every day.
when I try to upload the backup to ftp, the upload happens, but the backup has size 0 and if I try to open it it gives me an error. Furthermore, it is logged in the error log
os.remove call blocked. What is going on?
Code:
require('socket.ftp')

-- Get hostname
hostname = io.readfile('/proc/sys/kernel/hostname'):trim()

-- ftp file
ftpfile = string.format('ftp://user:pass@ip/backup/' .. os.date('%Y.%m.%w') .. '-' .. hostname .. '.tar.gz;type=i')

--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 file from HL ftp
os.remove(dst)
Reply


Messages In This Thread
FTPS example - by npinguin - 19.09.2017, 16:23
RE: Sftp example - by Erwin van der Zwart - 19.09.2017, 18:56
RE: Sftp example - by npinguin - 20.09.2017, 18:30
RE: Sftp example - by admin - 21.09.2017, 14:24
RE: Sftp example - by npinguin - 21.09.2017, 15:45
RE: Sftp example - by admin - 22.09.2017, 10:31
RE: Sftp example - by npinguin - 22.09.2017, 14:11
RE: FTPS example - by admin - 22.09.2017, 15:26
RE: FTPS example - by admin - 25.09.2017, 11:29
RE: FTPS example - by npinguin - 25.09.2017, 18:02
RE: FTPS example - by admin - 26.09.2017, 06:10
RE: FTPS example - by DGrandes - 22.02.2023, 14:37
RE: FTPS example - by admin - 23.02.2023, 06:39
RE: FTPS example - by Kilogica - 13.03.2024, 09:08
RE: FTPS example - by Daniel - 13.03.2024, 09:39
RE: FTPS example - by admin - 13.03.2024, 10:10
RE: FTPS example - by Kilogica - 13.03.2024, 11:27
RE: FTPS example - by Daniel - 13.03.2024, 11:29
RE: FTPS example - by Kilogica - 13.03.2024, 11:47
RE: FTPS example - by Daniel - 13.03.2024, 12:11
RE: FTPS example - by Kilogica - 13.03.2024, 13:51
RE: FTPS example - by ferrim - 20.03.2024, 08:28
RE: FTPS example - by admin - 20.03.2024, 08:34
RE: FTPS example - by ferrim - 20.03.2024, 08:53
RE: FTPS example - by ferrim - 22.03.2024, 08:42
RE: FTPS example - by admin - 22.03.2024, 08:54
RE: FTPS example - by ferrim - 22.03.2024, 09:21

Forum Jump: