Yandex Cloud
Search
Contact UsTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • AI for business
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2025 Direct Cursus Technology L.L.C.
Tutorials
    • All tutorials
    • Unassisted deployment of the Apache Kafka® web interface
    • Upgrading a Managed Service for Apache Kafka® cluster to migrate from ZooKeeper to KRaft
    • Migrating a database from a third-party Apache Kafka® cluster to Managed Service for Apache Kafka®
    • Moving data between Managed Service for Apache Kafka® clusters using Data Transfer
    • Transferring data from Managed Service for MySQL® to Managed Service for Apache Kafka® using Data Transfer
    • Transferring data from Managed Service for MySQL® to Managed Service for Apache Kafka® using Debezium
    • Transferring data from Managed Service for PostgreSQL to Managed Service for Apache Kafka® using Data Transfer
    • Transferring data from Managed Service for PostgreSQL to Managed Service for Apache Kafka® using Debezium
    • Transferring data from Managed Service for YDB to Managed Service for Apache Kafka® using Data Transfer
    • Transferring data from Managed Service for Apache Kafka® to Managed Service for ClickHouse® using Data Transfer
    • Transferring data from Managed Service for Apache Kafka® to Yandex MPP Analytics for PostgreSQL using Data Transfer
    • Transferring data from Managed Service for Apache Kafka® to Yandex StoreDoc using Data Transfer
    • Transferring data from Managed Service for Apache Kafka® to Managed Service for MySQL® using Data Transfer
    • Transferring data from Managed Service for Apache Kafka® to Managed Service for OpenSearch using Data Transfer
    • Transferring data from Managed Service for Apache Kafka® to Managed Service for PostgreSQL using Data Transfer
    • Transferring data from Managed Service for Apache Kafka® to Managed Service for YDB using Data Transfer
    • Transferring data from Managed Service for Apache Kafka® to Data Streams using Data Transfer
    • Transferring data from Data Streams to Managed Service for YDB using Data Transfer
    • Transferring data from Data Streams to Managed Service for Apache Kafka® using Data Transfer
    • YDB change data capture and delivery to YDS
    • Configuring Kafka Connect to work with a Managed Service for Apache Kafka® cluster
    • Synchronizing Apache Kafka® topics in Object Storage with no web access
    • Monitoring message loss in an Apache Kafka® topic
    • Automating Query tasks with Managed Service for Apache Airflow™
    • Sending requests to the Yandex Cloud API via the Yandex Cloud Python SDK
    • Configuring an SMTP server to send e-mail notifications
    • Adding data to a ClickHouse® DB
    • Migrating data to Managed Service for ClickHouse® using ClickHouse® tools
    • Migrating data to Managed Service for ClickHouse® using Data Transfer
    • Transferring data from Managed Service for MySQL® to Managed Service for ClickHouse® using Data Transfer
    • Asynchronously replicating data from PostgreSQL to ClickHouse®
    • Exchanging data between Managed Service for ClickHouse® and Yandex Data Processing
    • Configuring Managed Service for ClickHouse® for Graphite
    • Fetching data from Managed Service for Apache Kafka® to Managed Service for ClickHouse®
    • Fetching data from Managed Service for Apache Kafka® to ksqlDB
    • Fetching data from RabbitMQ to Managed Service for ClickHouse®
    • Saving a data stream from Data Streams to Managed Service for ClickHouse®
    • Asynchronous replication of data from Yandex Metrica to ClickHouse® using Data Transfer
    • Using hybrid storage in Managed Service for ClickHouse®
    • Sharding Managed Service for ClickHouse® tables
    • Loading data from Yandex Direct to a Managed Service for ClickHouse® data mart using Cloud Functions, Object Storage, and Data Transfer
    • Loading data from Object Storage to Managed Service for ClickHouse® using Data Transfer
    • Migrating data from Managed Service for OpenSearch to Managed Service for ClickHouse® with a storage change using Data Transfer
    • Loading data from Managed Service for YDB to Managed Service for ClickHouse® using Data Transfer
    • Yandex Managed Service for ClickHouse® integration with Microsoft SQL Server via ClickHouse® JDBC Bridge
    • Migrating databases from Google BigQuery to Managed Service for ClickHouse®
    • Yandex Managed Service for ClickHouse® integration with Oracle via ClickHouse® JDBC Bridge
    • Configuring Cloud DNS to access a Managed Service for ClickHouse® cluster from other cloud networks
    • Migrating a Yandex Data Processing HDFS cluster to a different availability zone
    • Importing data from Managed Service for MySQL® to Yandex Data Processing using Sqoop
    • Importing data from Managed Service for PostgreSQL to Yandex Data Processing using Sqoop
    • Mounting Object Storage buckets to the file system of Yandex Data Processing hosts
    • Working with Apache Kafka® topics using Yandex Data Processing
    • Automating operations with Yandex Data Processing using Managed Service for Apache Airflow™
    • Shared use of Yandex Data Processing tables through Apache Hive™ Metastore
    • Transferring metadata across Yandex Data Processing clusters using Apache Hive™ Metastore
    • Importing data from Object Storage, processing it, and exporting it to Managed Service for ClickHouse®
    • Migrating collections from a third-party MongoDB cluster to Yandex StoreDoc
    • Migrating data to Yandex StoreDoc
    • Migrating Yandex StoreDoc cluster from 4.4 to 6.0
    • Sharding Yandex StoreDoc collections
    • Yandex StoreDoc performance analysis and tuning
    • Managed Service for MySQL® performance analysis and tuning
    • Syncing data from a third-party MySQL® cluster to Managed Service for MySQL® using Data Transfer
    • Migrating a database from Managed Service for MySQL® to a third-party MySQL® cluster
    • Migrating a database from Managed Service for MySQL® to Object Storage using Data Transfer
    • Migrating data from Object Storage to Managed Service for MySQL® using Data Transfer
    • Transferring data from Managed Service for MySQL® to Managed Service for Apache Kafka® using Data Transfer
    • Transferring data from Managed Service for MySQL® to Managed Service for Apache Kafka® using Debezium
    • Migrating a database from Managed Service for MySQL® to Managed Service for YDB using Data Transfer
    • MySQL® change data capture and delivery to YDS
    • Migrating data from Managed Service for MySQL® to Managed Service for PostgreSQL using Data Transfer
    • Migrating data from AWS RDS for PostgreSQL to Managed Service for PostgreSQL using Data Transfer
    • Migrating data from Managed Service for MySQL® to Yandex MPP Analytics for PostgreSQL using Data Transfer
    • Configuring an index policy in Managed Service for OpenSearch
    • Migrating data from a third-party OpenSearch cluster to Managed Service for OpenSearch using Data Transfer
    • Loading data from Managed Service for OpenSearch to Object Storage using Data Transfer
    • Migrating data from Managed Service for OpenSearch to Managed Service for YDB using Data Transfer
    • Copying data from Managed Service for OpenSearch to Yandex MPP Analytics for PostgreSQL using Yandex Data Transfer
    • Migrating data from Managed Service for PostgreSQL to Managed Service for OpenSearch using Data Transfer
    • Authenticating a Managed Service for OpenSearch cluster in OpenSearch Dashboards using Keycloak
    • Using the yandex-lemmer plugin in Managed Service for OpenSearch
    • Creating a PostgreSQL cluster for 1C:Enterprise
    • Searching for the Managed Service for PostgreSQL cluster performance issues
    • Managed Service for PostgreSQL performance analysis and tuning
    • Logical replication in PostgreSQL
    • Migrating a database from a third-party PostgreSQL cluster to Managed Service for PostgreSQL
    • Migrating a database from Managed Service for PostgreSQL
    • Transferring data from Managed Service for PostgreSQL to Managed Service for Apache Kafka® using Data Transfer
    • Transferring data from Managed Service for PostgreSQL to Managed Service for Apache Kafka® using Debezium
    • Transferring data from Managed Service for PostgreSQL to Managed Service for YDB using Data Transfer
    • Migrating a database from Managed Service for PostgreSQL to Object Storage
    • Migrating data from Object Storage to Managed Service for PostgreSQL using Data Transfer
    • PostgreSQL change data capture and delivery to YDS
    • Migrating data from Managed Service for PostgreSQL to Managed Service for MySQL® using Data Transfer
    • Migrating data from Managed Service for PostgreSQL to Managed Service for OpenSearch using Data Transfer
    • Fixing string sorting issues in PostgreSQL after upgrading glibc
    • Migrating a database from Greenplum® to ClickHouse®
    • Migrating a database from Greenplum® to PostgreSQL
    • Exporting Greenplum® data to a cold storage in Object Storage
    • Loading data from Object Storage to Yandex MPP Analytics for PostgreSQL using Data Transfer
    • Copying data from Managed Service for OpenSearch to Yandex MPP Analytics for PostgreSQL using Yandex Data Transfer
    • Creating an external table from an Object Storage bucket table using a configuration file
    • Getting data from external sources using named queries in Greenplum®
    • Migrating a database from a third-party Valkey™ cluster to Yandex Managed Service for Valkey™
    • Using a Yandex Managed Service for Valkey™ cluster as a PHP session storage
    • Loading data from Object Storage to Managed Service for YDB using Data Transfer
    • Loading data from Managed Service for YDB to Object Storage using Data Transfer
    • Processing Audit Trails events
    • Processing Cloud Logging logs
    • Processing Debezium CDC streams
    • Analyzing data with Jupyter
    • Processing files with usage details in Yandex Cloud Billing
    • Ingesting data into storage systems
    • Smart log processing
    • Data transfer in microservice architectures
    • Migrating data to Object Storage using Data Transfer
    • Migrating data from a third-party Greenplum® or PostgreSQL cluster to Yandex MPP Analytics for PostgreSQL using Data Transfer
    • Migrating Yandex StoreDoc clusters
    • Migrating MySQL® clusters
    • Migrating to a third-party MySQL® cluster
    • Migrating PostgreSQL clusters
    • Creating a schema registry to deliver data in Debezium CDC format from Apache Kafka®
    • Automating operations using Yandex Managed Service for Apache Airflow™
    • Working with an Object Storage table from a PySpark job
    • Integrating Yandex Managed Service for Apache Spark™ with Apache Hive™ Metastore
    • Running a PySpark job using Yandex Managed Service for Apache Airflow™
    • Using Yandex Object Storage in Yandex Managed Service for Apache Spark™

In this article:

  • Data migration using the remote function
  • Migrating data using backup and restore commands with an Object Storage bucket
  1. Building a data platform
  2. Migrating data to Managed Service for ClickHouse® using ClickHouse® tools

Migrating data to Managed Service for ClickHouse® using ClickHouse®

Written by
Yandex Cloud
Updated at December 5, 2025
  • Data migration using the remote function
  • Migrating data using backup and restore commands with an Object Storage bucket

You can migrate data from your ClickHouse® cluster to a Managed Service for ClickHouse® cluster by using:

  • Built-in remote function. This method is suitable for migrating individual tables.
  • Built-in backup/restore commands and an Yandex Object Storage bucket. This method can be used to migrate individual tables as well as an entire database.

You can also migrate a database from a ClickHouse® cluster to a Managed Service for ClickHouse® cluster using Data Transfer. For more information about this method, see this tutorial.

Data migration using the remote functionData migration using the remote function

You can use remote to migrate individual tables from a third-party ClickHouse® cluster. This method does not require installing ZooKeeper, additional tools, or upgrading the source cluster's ClickHouse® version.

Tip

Before migrating data, we recommend pausing merge operations on the source cluster using the STOP MERGES and STOP TTL MERGES commands. You should also disable all consumers.

To migrate a table from a third-party ClickHouse® cluster to a Managed Service for ClickHouse® cluster:

  1. Create a Managed Service for ClickHouse® target cluster.

  2. Connect to the source cluster.

  3. Get a DDL statement for table creation:

    SELECT create_table_query FROM system.tables WHERE database = '<name_of_DB_to_migrate>';
    

    For example, you might have a database named db1 with a list of tasks stored in a table named tasks. The response to your query will look as follows:

    CREATE TABLE db1.tasks (`task_id` Int32,
                            `title` String, 
                            `start_date` Date, 
                            `due_date` Date, 
                            `priority` Int8 DEFAULT 3, 
                            `description` String) 
                   ENGINE = MergeTree 
                   PRIMARY KEY tuple(task_id) 
                   ORDER BY tuple(task_id) 
                   SETTINGS index_granularity = 8192;
    
  4. Connect to the target Managed Service for ClickHouse® cluster and create a new table using the DDL statement you received earlier.

    If the source cluster did not use replicas, while the target cluster does, switch to a Replicated table engine.

    To create an object on all hosts of the target cluster, use the ON CLUSTER clause in the CREATE command.

  5. Run the following query on the source cluster:

    INSERT INTO FUNCTION
    remoteSecure('<Managed_Service_for_ClickHouse®_cluster_host_FQDN>:9440',
                 '<target_cluster_DB_name>.<target_table_name>',
                 '<username_in_target_cluster>',
                 '<user_password_in_target_cluster>')
    SELECT * from <DB_name>.<table_name>;
    

    To learn how to get a host FQDN, see this guide.

  6. On the target cluster, verify that the table from the source cluster has appeared in the database:

    SHOW TABLES FROM <DB_name>;
    
  7. Check that the target table contains the same data as the source table:

    SELECT * FROM <DB_name>.<table_name>;
    

For more details on using the remote function, see this ClickHouse® article.

Migrating data using backup and restore commands with an Object Storage bucketMigrating data using backup and restore commands with an Object Storage bucket

Warning

You need ClickHouse® version 22.10 or later to work with backup and restore commands in a third-party cluster.

You can use backup and restore commands with an Object Storage bucket to migrate individual tables or an entire database from a third-party ClickHouse® cluster. To do this:

  1. Create a Managed Service for ClickHouse® target cluster.

  2. Create a service account with the storage.editor role.

  3. Create a static key for the service account.

    Save both the key and its ID, as you will need them in the next steps.

  4. Create an Object Storage bucket.

  5. If encryption is enabled for the bucket, assign to the service account the kms.keys.encrypterDecrypter role for the encryption key linked to the bucket.

  6. Connect to the source cluster.

  7. Run the following command to back up your table to the Object Storage bucket:

    BACKUP TABLE <DB_name>.<table_name> TO S3('<Object_Storage_bucket_endpoint>', '<service_account_static_key_ID>', '<service_account_static_key>');
    

    To migrate the entire database, run the command below:

    BACKUP DATABASE <DB_name> TO S3('<Object_Storage_bucket_endpoint>', '<service_account_static_key_ID>', '<service_account_static_key>');
    
  8. Connect to the target Managed Service for ClickHouse® cluster.

  9. Run the following command to restore your table from a backup:

    RESTORE TABLE <DB_name>.<table_name> FROM S3('<Object_Storage_bucket_endpoint>', '<service_account_static_key_ID>', 'service_account_static_key>');
    

    To restore an entire database, use this command:

    RESTORE DATABASE <DB_name> FROM S3('<Object_Storage_bucket_endpoint>', '<service_account_static_key_ID>', 'service_account_static_key>');
    
  10. Verify that the restore operation was successful:

    • If you restored a table, run this command:

      SELECT * FROM <DB_name>.<table_name>;
      
    • If you restored the entire database, run this command:

      SHOW DATABASES;
      

For more details on using backup and restore commands with an S3 storage, see this ClickHouse® article.

Was the article helpful?

Previous
Adding data to a ClickHouse® DB
Next
Migrating data to Managed Service for ClickHouse® using Data Transfer
© 2025 Direct Cursus Technology L.L.C.