Export/Import Data From Storage Services
Endpoints
To import and export data from/to storage services, you can use the following endpoints:
/v1/dyn/AuthStorage/.*— For interaction with the user account storage service in RDBMS./v1/dyn/CampaignResultStorage/.*— For interaction with the campaign execution results storage service./v1/dyn/CampaignStorage/.*— For interaction with the campaign object storage service in RDBMS./v1/dyn/ConfigTemplateStorage/.*— For interaction with the configuration template storage service./v1/dyn/CpeDbService/.*— For interaction with the CPE object storage service./v1/dyn/FirmwareResultStorage/.*— For interaction with the firmware update results storage service./v1/dyn/FirmwareStorage/.*— For interaction with the firmware update rules storage service in the built-in RDBMS./v1/dyn/ScenarioHistoryStorage/.*— For interaction with the storage service containing scenario execution results initiated by DMS and completed on the CPE device.
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
| Parameter | Type | Required | Description |
|---|---|---|---|
| limit | int | no | Number of campaigns returned per request (pagination). |
| offset | int | no | Pagination 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
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string | yes | Unique user record identifier. |
| username | string | yes | Username that uniquely identifies the user in the system. |
| password | string | yes | User password. Minimum 8 characters, at least 1 uppercase letter and 1 special character. |
| claims | object | no | Reserved field for additional user properties. |
| roles | array | no | Access roles defining the user's permissions on the platform. Possible values: Admin, Level3, API, Files. |
| access_path | string | no | Access group for CPE devices. |
| create_record_ts | integer | no | Record creation timestamp. |
| ts | integer | no | Last record update timestamp. |
| author | string | no | Username of the user who created the record. |
| editor | string | no | Username of the user who last edited the record. |
CampaignResultStorage
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string | yes | Unique identifier of the campaign execution result record. |
| exit_code | integer | yes | Execution status of the scenario (exit code). |
| campaignid | string | yes | Unique identifier of the campaign record. |
| ts | integer | yes | Campaign completion time (as a timestamp). |
| cpeid | string | yes | Serial number of the CPE device. |
| result | string/number/boolean/object/array | no | Scenario execution result. Can be a string, number, boolean, object, or array. May be null. |
CampaignStorage
| Parameter | Type | Required | Description |
|---|---|---|---|
| enabled | boolean | no | Campaign status — enabled (true) or disabled (false). |
| active | boolean | no | Initiates a CPE session via Connection Request. |
| id | string | no | Unique identifier of the campaign record. |
| name | string | yes | Human-readable campaign name. |
| condition | object | yes | CPE filtering condition for the campaign. Arbitrary structure. |
| events | array | no | List 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. |
| method | string | yes | Name of the script executed as part of the campaign. |
| args | object/array | yes | Arguments for the script. Can be an object or an array of objects. |
| executions | integer | no | Number of campaign executions per CPE device. |
| cron | string | no | Cron expression defining the campaign execution schedule. |
| period | integer | no | Campaign activation interval in seconds. |
| batch | integer | no | Number of CPE devices processed per activation period. |
| priority | integer | no | Campaign execution priority on CPEs. A lower value means higher priority. |
| create_record_ts | integer | no | Record creation timestamp. |
| ts | integer | no | Last record update timestamp. |
| author | string | no | Username of the user who created the record. |
| editor | string | no | Username of the user who last edited the record. |
ConfigTemplateStorage
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string | yes | Unique identifier of the configuration template. |
| name | string | yes | Template name. |
| path | string | yes | Template path. |
| parent | string | yes | Parent template. |
| version | string | yes | Template version. |
| enable | boolean | no | Template availability status (enabled/disabled). |
| vendor | string | no | Device manufacturer the template is intended for. |
| model | string | no | Device model. |
| hv | string | no | Device hardware version. |
| sv | string | no | Device firmware version. |
| content_type | string | no | Template content type. |
| content | string (byte) | no | Template content as a byte string. |
| created | integer | no | Template creation timestamp. |
| edited | integer | no | Template last edit timestamp. |
| author | string | no | Username of the user who created the template. |
| editor | string | no | Username of the user who last modified the template. |
CpeDbService
| Parameter | Type | Required | Description |
|---|---|---|---|
| state | integer | yes | Current status of the CPE device. |
| cpeid | string | yes | Serial number of the CPE device. |
| type | string | no | Protocol version used by the CPE. |
| location | string | no | Location identifier of the CPE. |
| access_path | string | no | Identifier used to restrict CPE access for users outside the permitted group. |
| datamodel | string | no | Data model used by the device. |
| vendor | string | no | Manufacturer or vendor of the device. |
| model | string | no | Device model. |
| mac | string | no | Device MAC address. |
| hw | string | no | Device hardware version. |
| sw | string | no | Firmware version installed on the device. |
| ip | string | no | Device IP address. |
| ip2 | string | no | Additional IP address. |
| ip3 | string | no | Additional IP address. |
| upstream | string | no | Serial number of the device located higher in the network hierarchy. |
| protocol | string | no | Protocol name used by the CPE. |
| firstseen | integer | no | Timestamp of the first CPE interaction with the ACS. |
| lastseen | integer | no | Timestamp of the last CPE interaction with the ACS. |
| ts | integer | no | Timestamp of the last record update. |
| params | object | no | Object containing additional parameters. |
| customparams | object | no | Object containing user-defined parameters. |
| events | array | no | Array of events. Each element includes: CommandKey (string) and EventCode (string). |
| info | string | no | Reserved field for user-defined information about the device. |
| tags | array | no | List of device tags. Possible values: supportedFW, unsupportedFW, needUpgradeFW, upgradingFW, failedFWUpgrade, PD128. |
| customtags | array | no | List of user-defined tags. |
| cpe_classes | array | no | List of CPE classes. Possible value: cpe_class. |
| cid | string | no | Client identifier. |
| cid2 | string | no | Additional client identifier. |
| cid3 | string | no | Additional client identifier. |
| imsi | string | no | International Mobile Subscriber Identity. |
| imei | string | no | International Mobile Equipment Identity. |
| msisdn | string | no | Mobile Station International Subscriber Directory Number. |
FirmwareResultStorage
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string | yes | Unique identifier of the firmware update result record. |
| status | boolean | yes | Status of the firmware update procedure (true — success, false — failure). |
| ts | integer | yes | Timestamp of the firmware update procedure completion. |
| cpeid | string | yes | Serial number of the CPE device. |
| rule_description | string | no | Human-readable description of the firmware update rule. |
| campaignid | string | yes | Unique identifier of the firmware update rule record (campaign). |
| result | string\number\boolean\object\array | no | Result of the firmware update procedure. Can be a string, number, boolean, object, or array. Can be null. |
FirmwareStorage
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string | yes | Unique identifier of the firmware update rule. |
| enabled | boolean | yes | Enables or disables updates according to this rule. |
| automatic | boolean | no | Background automatic update (enabled/disabled). |
| description | string | no | Human-readable description of the firmware update rule. |
| file | string | yes | URL of the firmware file to be applied to the device(s). |
| create_record_ts | integer | no | Timestamp of record creation. |
| ts | integer | no | Timestamp of the last update of the record. |
| condition | object/array | no | Rule application condition. Can be an object or an array of objects. |
| executions | integer | no | Number of times the rule has been executed per device. |
| priority | integer | no | Priority of this rule relative to other rules. |
| author | string | yes | Name of the user who created the record. |
| editor | string | no | Name of the user who last modified the record. |
ScenarioHistoryStorage
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | string | yes | Unique identifier of the executed scenario. |
| exit_code | integer | yes | Scenario execution status (exit code). |
| ts | integer | yes | Timestamp of the result record. |
| start_ts | number | yes | Scenario start time. |
| end_ts | number | yes | Scenario end time. |
| cpeid | string | yes | Serial number of the CPE device. |
| scenario | string | yes | Name of the executed scenario. |
| initargs | object/array | no | Arguments passed at scenario start. Can be an object or an array of objects. |
| result | string/number/boolean/object/array | no | Scenario execution result. Can be a string, number, boolean, object, or array. Can also be null. |
| author | string | no | Name 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
- Create a file with the script, e.g.
main.py. - Create and activate the virtual environment:
pipenv shell
- Install dependencies:
pipenv install requests pydantic pydantic-settings
- Configure environment variables.
The script reads configuration from environment variables or a
.envfile.
Environment variables
Required:
| Variable | Purpose |
|---|---|
| DMS_BASE_URL | Base API URL |
| DMS_USERNAME | Username for authentication |
| DMS_PASSWORD | Password for authentication |
| STORAGE_NAME | Storage 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:
| Variable | Default | Purpose |
|---|---|---|
| EXPORT_FILE | export_data.json | Path to the file for export/import |
| PAGE_LIMIT | 100 | Number 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:
- To export data:
python main.py -a export
- 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.
-