mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 16:09:32 +00:00
parent
5bc4e4c35a
commit
574e941947
9 changed files with 445 additions and 15 deletions
37
scripts/lua/rest/v2/get/system/configurations/backup.lua
Normal file
37
scripts/lua/rest/v2/get/system/configurations/backup.lua
Normal 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
|
||||
|
||||
|
||||
-- ##############################################
|
||||
Loading…
Add table
Add a link
Reference in a new issue