Migrate into ClickHouse
Tested with: ClickHouse 26.8 on Databasezy · zb CLI 0.1
Sources: Self-hosted ClickHouse, ClickHouse Cloud and Aiven (connection string), .sql / .sql.gz scripts, CSV and Parquet files, another Databasezy instance.
How the copy works
Section titled “How the copy works”The migration Job runs clickhouse-client against both sides, one table at a time:
CREATE DATABASE IF NOT EXISTSon the target;- per table,
SHOW CREATE TABLEon the source, rewritten soReplicated*MergeTreeand ClickHouse CloudShared*MergeTreeengines become their single-node*MergeTreeequivalents, then run on the target; - per table,
SELECT * FORMAT Nativepiped intoINSERT ... FORMAT Native(column types are kept exactly); - views and materialized views last, so they do not fire on the copied rows.
HTTP(S) URLs are accepted and mapped to the native port (8443 to 9440 with TLS, 8123 to 9000); add
?native_port= if yours differs. .sql scripts run with --multiquery through the same engine rewrite; CSV and
Parquet files go into an existing table with INSERT ... FORMAT CSVWithNames / Parquet.
Run it
Section titled “Run it”# --dry-run prints the preflight checklist and the exact plan without changing anythingzb migrate --from "clickhouses://default:[email protected]:9440/analytics" --engine clickhouse --to inst_abczb migrate --from ./events.parquet --engine clickhouse --include events --to inst_abczb migrate --from ./schema-and-data.sql.gz --engine clickhouse --to inst_abcFollow it with zb migrate status <mig_id>, or in the portal under the instance’s Migrate in tab.
What is verified
Section titled “What is verified”total_rows per table from system.tables (reported as approximate). Mismatches are listed in the result; nothing is switched for you.
Not carried over
Section titled “Not carried over”- Copy only; rows written to the source during the copy may be missed.
- Materialized views without a
TOtable are recreated empty; with aTOtable, the target table is copied as data. - Dictionaries, users, roles, quotas and row policies are not copied.
- Table names containing quotes or backticks stop the copy; exclude or rename them.
How migrations work covers preflight, verification and cutover; engine conversions covers moves between engines.