Skip to content

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.

The migration Job runs clickhouse-client against both sides, one table at a time:

  1. CREATE DATABASE IF NOT EXISTS on the target;
  2. per table, SHOW CREATE TABLE on the source, rewritten so Replicated*MergeTree and ClickHouse Cloud Shared*MergeTree engines become their single-node *MergeTree equivalents, then run on the target;
  3. per table, SELECT * FORMAT Native piped into INSERT ... FORMAT Native (column types are kept exactly);
  4. 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.

shell
# --dry-run prints the preflight checklist and the exact plan without changing anything
zb migrate --from "clickhouses://default:[email protected]:9440/analytics" --engine clickhouse --to inst_abc
zb migrate --from ./events.parquet --engine clickhouse --include events --to inst_abc
zb migrate --from ./schema-and-data.sql.gz --engine clickhouse --to inst_abc

Follow it with zb migrate status <mig_id>, or in the portal under the instance’s Migrate in tab.

total_rows per table from system.tables (reported as approximate). Mismatches are listed in the result; nothing is switched for you.

  • Copy only; rows written to the source during the copy may be missed.
  • Materialized views without a TO table are recreated empty; with a TO table, 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.