Add configurations backup. (#5780) (#7390)

This commit is contained in:
Nicolò Maio 2023-04-12 17:01:08 +02:00 committed by GitHub
parent 5bc4e4c35a
commit 574e941947
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 445 additions and 15 deletions

View file

@ -0,0 +1,37 @@
--
-- (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
-- ##############################################
local rest_utils = require("rest_utils")
local backup_config = require("backup_config")
-- ##############################################
local download = _GET["download"]
local epoch = _GET["epoch"]
local resp = 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)
end
-- ##############################################