Migrate a time range with the CLI
This example uses taosx run to migrate one minute of a supertable's historical data to a dedicated test database. The command exits when reading finishes. Prepare three known records, one at the end boundary. After migration, check the schema, the two records inside the interval, and the boundary record that was not migrated.
Where to operate: run taosx run in PowerShell or Bash. Run preparation and verification SQL in the corresponding cluster's Data Browser or taos CLI.
The command host must have taosX installed and be able to connect to source and target clusters through their taosAdapter WebSocket ports. The execution identity needs source schema and data read permissions, target schema creation and write permissions, and an enterprise license.
This example does not continuously track new records. For a first exercise, use two different databases in the same test cluster. Across clusters, connect preparation and query steps to the corresponding source and target.
1. Prerequisites
First run taosx --version and taosx run --help to confirm that the executable matches the version stated on the manual's home page. The default Windows installation location is C:\TDengine\taosx.exe. Use the full path if it is not in PATH.
Have an authorized TDengine TSDB administrator prepare isolated test objects in the taosExplorer Data Browser or taos CLI. Confirm the names below are unused. If they exist, choose new names and update commands and queries consistently; do not overwrite business objects. One test cluster can use two different databases. Across clusters, create source objects at the source and the target database at the target.
CREATE DATABASE taosx_demo_src PRECISION 'ms';
CREATE DATABASE taosx_demo_dst PRECISION 'ms';
CREATE STABLE taosx_demo_src.meters
(ts TIMESTAMP, value DOUBLE) TAGS (site VARCHAR(16));
CREATE TABLE taosx_demo_src.meter_1
USING taosx_demo_src.meters TAGS ('lab');
INSERT INTO taosx_demo_src.meter_1 VALUES
('2026-11-20T00:00:00Z', 10.5)
('2026-11-20T00:00:30Z', 11.5)
('2026-11-20T00:01:00Z', 12.5);
Timestamps must fall within source and target retention. Otherwise shift all times in the sample, commands, and verification queries together, keeping the three points 30 seconds apart. Both databases use the same millisecond precision. This example migrates the first minute, so the first two rows are included and the third row at the end boundary is excluded.
2. Minimal configuration and execution
The following commands are only for an isolated test: both databases are in the same test cluster, taosAdapter and the command-line tools run in the same environment, and the default root / taosdata credentials have not been changed. For production or cross-host use, substitute an authorized identity and actual addresses. URL-encode passwords containing DSN reserved characters first. Source and target identities may differ.
- Linux
- Windows
Open Bash on the Linux host with taosX installed and run:
taosx run -f 'taos+ws://root:taosdata@127.0.0.1:6041/taosx_demo_src?stables=meters&mode=history&start=2026-11-20T00:00:00Z&end=2026-11-20T00:01:00Z' -t 'taos+ws://root:taosdata@127.0.0.1:6041/taosx_demo_dst'
echo $?
Open PowerShell on the Windows host with taosX installed and run the following. Adjust the path if the installation location differs:
& 'C:\TDengine\taosx.exe' run -f 'taos+ws://root:taosdata@127.0.0.1:6041/taosx_demo_src?stables=meters&mode=history&start=2026-11-20T00:00:00Z&end=2026-11-20T00:01:00Z' -t 'taos+ws://root:taosdata@127.0.0.1:6041/taosx_demo_dst'
$LASTEXITCODE
Wait for the command to end, confirm exit code 0, then check the data. 127.0.0.1 refers to the environment executing taosX. In a container or WSL, do not assume it refers to the Windows host or another database host.
3. Configuration that must be explicit in this example
In the source DSN, stables=meters selects the supertable, mode=history explicitly selects historical migration, and start and end use times with a time zone. This example uses a left-closed, right-open range: it includes 00:00:00Z and excludes 00:01:00Z.
taos+ws connects through taosAdapter, on port 6041 in this example. Do not simply replace it with the native taosd port. Keep the quotes around the DSNs; otherwise, the shell treats & as a command separator or background operator.
These are the options used in this example. For other options, first check the actual program with taosx run --help. For migration method selection, see Choose a data transfer method.
4. Verification
Confirm exit code 0 and check that execution output contains no unhandled read or write errors. Then connect to the source cluster to check this migration's input:
SELECT ts, value, site
FROM taosx_demo_src.meter_1
WHERE ts >= '2026-11-20T00:00:00Z'
AND ts < '2026-11-20T00:01:00Z'
ORDER BY ts;
Connect to the target cluster and check the full target table, schema, and window boundaries:
SELECT ts, value, site
FROM taosx_demo_dst.meter_1
ORDER BY ts;
DESCRIBE taosx_demo_dst.meters;
SELECT COUNT(*) FROM taosx_demo_dst.meter_1
WHERE ts >= '2026-11-20T00:00:00Z'
AND ts < '2026-11-20T00:01:00Z';
SELECT COUNT(*) FROM taosx_demo_dst.meter_1
WHERE ts = '2026-11-20T00:01:00Z';
SELECT COUNT(*) FROM taosx_demo_dst.meter_1
WHERE ts < '2026-11-20T00:00:00Z'
OR ts >= '2026-11-20T00:01:00Z';
After completing this example with a dedicated empty target database, the following must hold:
- The source window query and full target table query both return two rows: value
10.5at00:00:00Zand11.5at00:00:30Z, both taggedlab. If client display time zones differ, compare the same UTC instants. - The target schema contains
ts TIMESTAMP,value DOUBLE, and tagsite VARCHAR(16), matching the source. - The target window count is
2. The end-boundary equality query and out-of-window query both return0. The third record, with value12.5, was not migrated.
If the target already contains data, the total table row count is not the count for this migration. Use the recorded pre-migration baseline to explain results. Exit code, row count, or successful table creation alone cannot replace the verification above.
If no records are found, start with No data on first ingestion. For full migration configuration and limitations, see TDengine query migration. For stopping and recovery, see Restarts, checkpoints, and store-and-forward. For other symptoms, see Troubleshooting by symptom.