09.09.2023, 09:08
I just learned the hard way that my backup script doesn't make a backup off everything.
I'm missing the startup script, the user libraries and the common functions.
This is the script that is use to make the daily backup.
Is there a way to backup everything at once?
I'm missing the startup script, the user libraries and the common functions.
This is the script that is use to make the daily backup.
Is there a way to backup everything at once?
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 = 'Targetpath' .. 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 = "IPadres",
user = "Username",
password = "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*')