Backup code cleanup and fixes daily backup not executed (#7397)

This commit is contained in:
Matteo Biscosi 2023-04-14 16:15:10 +00:00
parent d51e8e86cf
commit 4cacf75c9e
5 changed files with 195 additions and 235 deletions

View file

@ -1,7 +1,6 @@
--
-- (C) 2013-23 - ntop.org
--
local dirs = ntop.getDirs()
package.path = dirs.installdir .. "/scripts/lua/modules/?.lua;" .. package.path
package.path = dirs.installdir .. "/scripts/lua/modules/system_config/?.lua;" .. package.path
@ -16,22 +15,17 @@ local backup_config = require("backup_config")
local download = _GET["download"]
local epoch = _GET["epoch"]
local resp = backup_config.export_backup(epoch)
local succ, rsp = backup_config.export_backup(epoch)
if ( resp == -1 ) then
rest_utils.answer( rest_utils.consts.err.bad_content)
end
if download and not isEmptyString(download) and download == "true" then
-- Download as file
sendHTTPContentTypeHeader('application/json', 'attachment; filename="configuration.json"')
print(resp)
else
-- Send as REST answer
rest_utils.answer(rest_utils.consts.success.ok, resp)
if (not succ) then
rest_utils.answer(rest_utils.consts.err.bad_content)
end
-- Download the file
if download then
sendHTTPContentTypeHeader('application/json', 'attachment; filename="configuration.json"')
print(rsp)
else
rest_utils.answer(rest_utils.consts.success.ok, rsp)
end
-- ##############################################