Skip to main content

Export/Import Data From Storage Services

Endpoints

To import and export data from/to storage services, you can use the following endpoints:

Important note: Records in ScenarioHistoryStorage, FirmwareResultStorage, and CampaignResultStorage are log/history data. They can be exported for analysis, but importing them is not recommended.

Important note:
The list of available storage services depends on the installed configuration and may differ from the documentation.


Export

Method: GET
Authentication: Basic Auth (DMS_USERNAME:DMS_PASSWORD)

Query Parameters

ParameterTypeRequiredDescription
limitintnoNumber of campaigns returned per request (pagination).
offsetintnoPagination offset (default is 0).

Examples

Request Example

curl -X 'GET' \
'http://DMS_BASE_URL:PORT/v1/dyn/CampaignStorage/.*?limit=10000' \
-H 'accept: application/json' \
-H 'Authorization: Basic BASIC_AUTH'

Where DMS_BASE_URL:PORT — the address and port of the DMS server, and BASIC_AUTH — Base64-encoded credentials in the format username:password.

Response Example

{
"code": 200,
"message": "response from CampaignStorage",
"details": [
{
"enabled": true,
"active": true,
"id": "8ee32049-1077-429a-add1-743cb2560b76",
"name": "Campaign1",
"condition": {
"cpeid": "DM*"
},
"events": [],
"method": "CWMP.Reboot",
"args": {},
"executions": 1,
"cron": "",
"period": 60,
"batch": 100,
"priority": 5,
"create_record_ts": 1760970122,
"ts": 1760970122,
"author": "admin",
"editor": ""
},
{
"enabled": false,
"active": false,
"id": "bec52ee2-9bcc-40c6-bb9f-a7ce5935d8a5",
"name": "Campaign2",
"condition": {
"model": "ALPHA 001"
},
"events": [],
"method": "CWMP.GetParameterValues",
"args": [
"InternetGatewayDevice.ManagementServer."
],
"executions": 0,
"cron": "",
"period": 60,
"batch": 100,
"priority": 5,
"create_record_ts": 1760970229,
"ts": 1760970303,
"author": "admin",
"editor": "admin"
}
]
}

Import

Method: POST

Authentication: Basic Auth (DMS_USERNAME:DMS_PASSWORD)

Important: Not all storage services are suitable for import. Some services are log/history storages intended only for recording events; importing them is not recommended.

Request Body Parameters

See the section Storage Services Parameters

Examples

Request Example

curl -X 'POST' \
'http://DMS_BASE_URL:PORT/v1/dyn/CampaignStorage/.*' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Basic BASIC_AUTH' \
-d '{
"enabled": true,
"active": true,
"id": "8ee32049-1077-429a-add1-743cb2560b76",
"name": "Campaign1",
"condition": {
"cpeid": "DM*"
},
"events": [],
"method": "CWMP.Reboot",
"args": {},
"executions": 1,
"cron": "",
"period": 60,
"batch": 100,
"priority": 5,
"create_record_ts": 1760970122,
"ts": 1760970122,
"author": "admin",
"editor": ""
}'

Where DMS_BASE_URL:PORT — the address and port of the DMS server, and BASIC_AUTH — Base64-encoded credentials in the format username:password.

Response Example

{
"code": 204,
"message": "response from CampaignStorage",
"details": ""
}

Storage Services Parameters

AuthStorage

ParameterTypeRequiredDescription
idstringyesUnique user record identifier.
usernamestringyesUsername that uniquely identifies the user in the system.
passwordstringyesUser password. Minimum 8 characters, at least 1 uppercase letter and 1 special character.
claimsobjectnoReserved field for additional user properties.
rolesarraynoAccess roles defining the user's permissions on the platform. Possible values: Admin, Level3, API, Files.
access_pathstringnoAccess group for CPE devices.
create_record_tsintegernoRecord creation timestamp.
tsintegernoLast record update timestamp.
authorstringnoUsername of the user who created the record.
editorstringnoUsername of the user who last edited the record.

CampaignResultStorage

ParameterTypeRequiredDescription
idstringyesUnique identifier of the campaign execution result record.
exit_codeintegeryesExecution status of the scenario (exit code).
campaignidstringyesUnique identifier of the campaign record.
tsintegeryesCampaign completion time (as a timestamp).
cpeidstringyesSerial number of the CPE device.
resultstring/number/boolean/object/arraynoScenario execution result. Can be a string, number, boolean, object, or array. May be null.

CampaignStorage

ParameterTypeRequiredDescription
enabledbooleannoCampaign status — enabled (true) or disabled (false).
activebooleannoInitiates a CPE session via Connection Request.
idstringnoUnique identifier of the campaign record.
namestringyesHuman-readable campaign name.
conditionobjectyesCPE filtering condition for the campaign. Arbitrary structure.
eventsarraynoList of TR-069/USP events used to filter CPEs for campaign participation. An empty list means all events. Possible values: 0 BOOTSTRAP, 1 BOOT, 2 PERIODIC, 3 SCHEDULED, 4 VALUE CHANGE, 6 CONNECTION REQUEST, 7 TRANSFER COMPLETE, 8 DIAGNOSTICS COMPLETE, 9 REQUEST DOWNLOAD, 10 AUTONOMOUS TRANSFER COMPLETE, 11 DU STATE CHANGE COMPLETE, 12 AUTONOMOUS DU STATE CHANGE COMPLETE, 13 WAKEUP, 14 HEARTBEAT.
methodstringyesName of the script executed as part of the campaign.
argsobject/arrayyesArguments for the script. Can be an object or an array of objects.
executionsintegernoNumber of campaign executions per CPE device.
cronstringnoCron expression defining the campaign execution schedule.
periodintegernoCampaign activation interval in seconds.
batchintegernoNumber of CPE devices processed per activation period.
priorityintegernoCampaign execution priority on CPEs. A lower value means higher priority.
create_record_tsintegernoRecord creation timestamp.
tsintegernoLast record update timestamp.
authorstringnoUsername of the user who created the record.
editorstringnoUsername of the user who last edited the record.

ConfigTemplateStorage

ParameterTypeRequiredDescription
idstringyesUnique identifier of the configuration template.
namestringyesTemplate name.
pathstringyesTemplate path.
parentstringyesParent template.
versionstringyesTemplate version.
enablebooleannoTemplate availability status (enabled/disabled).
vendorstringnoDevice manufacturer the template is intended for.
modelstringnoDevice model.
hvstringnoDevice hardware version.
svstringnoDevice firmware version.
content_typestringnoTemplate content type.
contentstring (byte)noTemplate content as a byte string.
createdintegernoTemplate creation timestamp.
editedintegernoTemplate last edit timestamp.
authorstringnoUsername of the user who created the template.
editorstringnoUsername of the user who last modified the template.

CpeDbService

ParameterTypeRequiredDescription
stateintegeryesCurrent status of the CPE device.
cpeidstringyesSerial number of the CPE device.
typestringnoProtocol version used by the CPE.
locationstringnoLocation identifier of the CPE.
access_pathstringnoIdentifier used to restrict CPE access for users outside the permitted group.
datamodelstringnoData model used by the device.
vendorstringnoManufacturer or vendor of the device.
modelstringnoDevice model.
macstringnoDevice MAC address.
hwstringnoDevice hardware version.
swstringnoFirmware version installed on the device.
ipstringnoDevice IP address.
ip2stringnoAdditional IP address.
ip3stringnoAdditional IP address.
upstreamstringnoSerial number of the device located higher in the network hierarchy.
protocolstringnoProtocol name used by the CPE.
firstseenintegernoTimestamp of the first CPE interaction with the ACS.
lastseenintegernoTimestamp of the last CPE interaction with the ACS.
tsintegernoTimestamp of the last record update.
paramsobjectnoObject containing additional parameters.
customparamsobjectnoObject containing user-defined parameters.
eventsarraynoArray of events. Each element includes: CommandKey (string) and EventCode (string).
infostringnoReserved field for user-defined information about the device.
tagsarraynoList of device tags. Possible values: supportedFW, unsupportedFW, needUpgradeFW, upgradingFW, failedFWUpgrade, PD128.
customtagsarraynoList of user-defined tags.
cpe_classesarraynoList of CPE classes. Possible value: cpe_class.
cidstringnoClient identifier.
cid2stringnoAdditional client identifier.
cid3stringnoAdditional client identifier.
imsistringnoInternational Mobile Subscriber Identity.
imeistringnoInternational Mobile Equipment Identity.
msisdnstringnoMobile Station International Subscriber Directory Number.

FirmwareResultStorage

ParameterTypeRequiredDescription
idstringyesUnique identifier of the firmware update result record.
statusbooleanyesStatus of the firmware update procedure (true — success, false — failure).
tsintegeryesTimestamp of the firmware update procedure completion.
cpeidstringyesSerial number of the CPE device.
rule_descriptionstringnoHuman-readable description of the firmware update rule.
campaignidstringyesUnique identifier of the firmware update rule record (campaign).
resultstring\number\boolean\object\arraynoResult of the firmware update procedure. Can be a string, number, boolean, object, or array. Can be null.

FirmwareStorage

ParameterTypeRequiredDescription
idstringyesUnique identifier of the firmware update rule.
enabledbooleanyesEnables or disables updates according to this rule.
automaticbooleannoBackground automatic update (enabled/disabled).
descriptionstringnoHuman-readable description of the firmware update rule.
filestringyesURL of the firmware file to be applied to the device(s).
create_record_tsintegernoTimestamp of record creation.
tsintegernoTimestamp of the last update of the record.
conditionobject/arraynoRule application condition. Can be an object or an array of objects.
executionsintegernoNumber of times the rule has been executed per device.
priorityintegernoPriority of this rule relative to other rules.
authorstringyesName of the user who created the record.
editorstringnoName of the user who last modified the record.

ScenarioHistoryStorage

ParameterTypeRequiredDescription
idstringyesUnique identifier of the executed scenario.
exit_codeintegeryesScenario execution status (exit code).
tsintegeryesTimestamp of the result record.
start_tsnumberyesScenario start time.
end_tsnumberyesScenario end time.
cpeidstringyesSerial number of the CPE device.
scenariostringyesName of the executed scenario.
initargsobject/arraynoArguments passed at scenario start. Can be an object or an array of objects.
resultstring/number/boolean/object/arraynoScenario execution result. Can be a string, number, boolean, object, or array. Can also be null.
authorstringnoName of the user who initiated the scenario execution.

Automation Example

As an example, we provide a script that can assist with exporting and importing data to/from storage services:

import json
import argparse

import requests
from pydantic import ValidationError
from pydantic_settings import BaseSettings


class Settings(BaseSettings):
DMS_BASE_URL: str
STORAGE_NAME: str
DMS_USERNAME: str
DMS_PASSWORD: str
EXPORT_FILE: str = "export_data.json"
PAGE_LIMIT: int = 100
IMPORT_NAME_PREFIX: str = ""

@property
def AUTH(self) -> tuple[str, str]:
"""Return auth tuple for requests"""
return (self.DMS_USERNAME, self.DMS_PASSWORD)

class Config:
env_file = ".env"


def export_data(settings: Settings) -> None:
"""Export data to JSON file"""
records = []
offset = 0

while True:
resp = requests.get(
f"{settings.DMS_BASE_URL}/v1/dyn/{settings.STORAGE_NAME}/.*",
auth=settings.AUTH,
params={"limit": settings.PAGE_LIMIT, "offset": offset},
)
resp.raise_for_status()
data = resp.json()

items = data.get("details")
if not items or not isinstance(items, list):
break

records.extend(items)
print(f"{len(items)} records exported (offset={offset})")

if len(items) < settings.PAGE_LIMIT:
break

offset += settings.PAGE_LIMIT

with open(settings.EXPORT_FILE, "w", encoding="utf-8") as f:
json.dump(records, f, ensure_ascii=False, indent=2)

print(f"✅ {len(records)} records exported to {settings.EXPORT_FILE}")


def import_data(settings: Settings) -> None:
"""Import data from JSON file"""
with open(settings.EXPORT_FILE, "r", encoding="utf-8") as f:
records = json.load(f)

c = 0

for record in records:
# Remove keys that server should recreate
for key in {"id", "create_record_ts", "ts", "executions", "author", "editor"}:
record.pop(key, None)
# Add optional name prefix
record["name"] = f"{settings.IMPORT_NAME_PREFIX}{record['name']}"

# Import
resp = requests.post(
f"{settings.DMS_BASE_URL}/v1/dyn/{settings.STORAGE_NAME}/.*", auth=settings.AUTH, json=record
)
if resp.status_code == 200:
c += 1
print(f"✅ Record imported: {record['name']}")
else:
print(f"❌ Error during record import {record['name']}: {resp.text}")

print(f"✅ {c} records imported from {settings.EXPORT_FILE}")


if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Export or import records from Storage")
parser.add_argument(
"-a",
"--action",
choices=["export", "import"],
help="Action: export or import",
required=True,
)
args = parser.parse_args()

try:
settings = Settings.model_validate({})
except ValidationError as e:
print("❌ Missing required environment variables:")
for err in e.errors():
print(f" - {err['loc'][0]}")
exit(1)

if args.action == "export":
export_data(settings)
elif args.action == "import":
import_data(settings)

It can be used as a standalone administrative tool and as part of migration or backup procedures.

Requirements

  • Python 3.13
  • Pipenv (for managing virtual environment and dependencies)

Environment setup

  1. Create a file with the script, e.g. main.py.
  2. Create and activate the virtual environment:
pipenv shell
  1. Install dependencies:
pipenv install requests pydantic pydantic-settings
  1. Configure environment variables. The script reads configuration from environment variables or a .env file.

Environment variables

Required:

VariablePurpose
DMS_BASE_URLBase API URL
DMS_USERNAMEUsername for authentication
DMS_PASSWORDPassword for authentication
STORAGE_NAMEStorage service name

Possible values for STORAGE_NAME

  • AuthStorage
  • CampaignResultStorage
  • CampaignStorage
  • ConfigTemplateStorage
  • CpeDbService
  • FirmwareResultStorage
  • FirmwareStorage
  • ScenarioHistoryStorage

Important note: The list of available storage services corresponds to the installed components and may differ from the documentation.

Optional:

VariableDefaultPurpose
EXPORT_FILEexport_data.jsonPath to the file for export/import
PAGE_LIMIT100Number of records to fetch per request
IMPORT_NAME_PREFIX"" (empty)Prefix to prepend to imported record names

Example .env file

DMS_BASE_URL=http://example.com/api
DMS_USERNAME=admin
DMS_PASSWORD=secret
EXPORT_FILE=campaigns.json
PAGE_LIMIT=200
IMPORT_NAME_PREFIX=imported_
STORAGE_NAME=CampaignStorage

Usage

Run from the activated virtual environment:

  1. To export data:
python main.py -a export
  1. To import data:
python main.py -a import

How the script works

  • Export (export)

    • Connects to the storage service API.

    • Retrieves records in pages (by PAGE_LIMIT) until all records are fetched.

    • Saves the collected records to EXPORT_FILE in JSON format.

  • Import (import)

    • Loads records from EXPORT_FILE.

    • Removes technical fields (id, ts, executions, author, editor, etc.) so the server will recreate them.

    • Optionally prepends IMPORT_NAME_PREFIX to the record name.

    • Sends each record to the storage service API via POST.