Creating MongoDB export files for selective time periods or objects

If you wish to create MongoDB exports for selected periods of time or only create an export for certain objects, then Lua functions in the "syslib.MongoOps" library can be used. To export all archived data between certain timepoints the HIST_DUMPTIMESPANALL() function can be used. This function has the following arguments:

  • tstart – The start time for the selected time period (in ISO 8601 format)

  • tend – The end time for the selected time period (in ISO 8601 format)

  • dump_path – The path to a valid directory where the backup file will be exported to

  • use_test_archive – An optional flag to export test archive data

Example:

local mongoops = require('syslib.MongoOps')
local ok, docnumber = pcall(
    mongoops.HIST_DUMPTIMESPANALL,
    mongoops,
    "2017-01-01T00:00:00.000Z",
    "2019-01-01T12:00:00.000Z",
    "C:\\backups\\MongoDB_Export_Prod.json"
    )
return string.format("%s : %s", ok, docnumber)

If you wish to export data from test archives then:

local mongoops = require('syslib.MongoOps')
local ok, docnumber = pcall(
    mongoops.HIST_DUMPTIMESPANALL,
    mongoops,
    "2017-01-01T00:00:00.000Z",
    "2019-01-01T12:00:00.000Z",
    "C:\\backups\\MongoDB_Export_Test.json",
    true
    )
return string.format("%s : %s", ok, docnumber)
The directory specified in the file path must exist before execution for the script to work.

To only export the archived MongoDB data for selected objects, use the HIST_DUMPTIMESPAN() function. This function has the following arguments:

  • tstart – The start time for the selected time period (in ISO 8601 format)

  • tend – The end time for the selected time period (in ISO 8601 format)

  • obj_table – A Lua table containing the paths of all the objects whose archived data is to be exported

  • dump_path – The path to a valid directory where the backup file will be exported to

  • use_test_archive – An optional flag to export test archive data.

Example:

local mongoops = require('syslib.MongoOps')
local pathtable = {
    "/System/Core/Examples/DemoData/ProcessData/DC4711",
    "/System/Core/Examples/DemoData/ProcessData/DC666"
}
local ok, docnumber = pcall(
    mongoops.HIST_DUMPTIMESPAN,
    mongoops,
    "2017-01-01T00:00:00.000Z",
    "2019-01-01T12:00:00.000Z",
    pathtable,
    "C:\\backups\\MongoDB_Export_Prod.json"
)
return string.format("%s : %s", ok, docnumber)