Yandex Cloud
Search
Contact UsGet started
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • AI Studio
    • 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
    • Education and Science
    • Yandex Cloud Partner program
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
© 2025 Direct Cursus Technology L.L.C.
Yandex Managed Service for Valkey™
  • Getting started
    • All tutorials
    • Storing PHP sessions in Yandex Managed Service for Valkey™
    • Migrating a database to Yandex Managed Service for Valkey™
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Public materials
  • Release notes
  • FAQ

In this article:

  • Required paid resources
  • Getting started
  • Prepare the infrastructure
  • Install additional software
  • Connect to the source cluster and create a logical dump
  • (Optional) Upload the dump to the intermediate virtual machine
  • Restore the dump on the target cluster
  • Make sure that the dump is restored completely
  • Delete the resources you created
  1. Tutorials
  2. Migrating a database to Yandex Managed Service for Valkey™

Migrating a database from a third-party Valkey™ cluster

Written by
Yandex Cloud
Updated at May 5, 2025
  • Required paid resources
  • Getting started
    • Prepare the infrastructure
    • Install additional software
  • Connect to the source cluster and create a logical dump
  • (Optional) Upload the dump to the intermediate virtual machine
  • Restore the dump on the target cluster
  • Make sure that the dump is restored completely
  • Delete the resources you created

For data migration, Valkey™ uses a logical dump: this is a file with a sequence of commands to restore the state of databases in the cluster. There are several ways to create a dump. The following example will use redis-dump-go.

Note

A binary RDB dump cannot be used for migration, because Yandex Managed Service for Valkey™ does not permit accessing file systems on cluster hosts.

To migrate Valkey™ databases from the source cluster to the target cluster:

  1. Connect to the source cluster and create a logical dump.

  2. (Optional) Upload the dump to the intermediate virtual machine.

    You must transfer data to Yandex Compute Cloud using a virtual machine if:

    • Your Yandex Managed Service for Valkey™ cluster is not accessible from the internet.
    • Your hardware or connection to the cluster in Yandex Cloud is not very reliable.
  3. Restore the dump on the target cluster.

  4. Make sure the dump is fully restored.

If you no longer need the resources you created, delete them.

Required paid resourcesRequired paid resources

The support cost includes:

  • Yandex Managed Service for Valkey™ target cluster fee: Using computing resources allocated to hosts, and its disk space (see Valkey™ pricing).
  • Fee for using public IP addresses if public access is enabled for cluster hosts (see Virtual Private Cloud pricing).
  • When creating a VM to download a dump: Fee for using the computing resources, storage, OS (for specific operating systems), and, optionally, public IP address (see Compute Cloud pricing).

Getting startedGetting started

Prepare the infrastructurePrepare the infrastructure

Manually
Terraform
  1. Create a Yandex Managed Service for Valkey™ cluster with any suitable configuration. To connect to a cluster from a user's local machine rather than a Yandex Cloud cloud network, enable TLS support and public host access when creating your cluster.

  2. (Optional) Create an intermediate Linux virtual machine in Yandex Compute Cloud on the same network as the Yandex Managed Service for Valkey™ cluster using the following configuration:

    • Under Boot disk image, select the Ubuntu 20.04 image.

    • Under Network settings:

      • Public IP address: Auto.
      • Internal IPv4 address: Auto.
      • Security groups: Select the same security group as for the Yandex Managed Service for Valkey™ cluster.
  3. If you use Virtual Private Cloud security groups, configure them.

  1. If you do not have Terraform yet, install it.

  2. Get the authentication credentials. You can add them to environment variables or specify them later in the provider configuration file.

  3. Configure and initialize a provider. There is no need to create a provider configuration file manually, you can download it.

  4. Place the configuration file in a separate working directory and specify the parameter values. If you did not add the authentication credentials to environment variables, specify them in the configuration file.

  5. Download the configuration file for the appropriate cluster type to the same working directory:

    • redis-cluster-non-sharded.tf: For an unsharded cluster.
    • redis-cluster-sharded.tf: For a sharded cluster.

    Each file describes the following:

    • Network.
    • Subnet.
    • Default security group and rules required to connect to the cluster and the virtual machine.
    • Yandex Managed Service for Valkey™ cluster with public internet access.
    • (Optional) Virtual machine with public internet access.
  6. Specify the following in the configuration file:

    • Password to access the Yandex Managed Service for Valkey™ cluster.

    • (Optional) VM parameters:

      • Public virtual machine image ID, e.g., for Ubuntu 20.04 LTS.
      • Login and absolute path to the public SSH key for accessing the virtual machine. By default, the specified username is ignored in the Ubuntu 20.04 LTS image. A user with the ubuntu username is created instead. Use it to connect to the VM.
  7. Make sure the Terraform configuration files are correct using this command:

    terraform validate
    

    If there are any errors in the configuration files, Terraform will point them out.

  8. Create the required infrastructure:

    1. Run this command to view the planned changes:

      terraform plan
      

      If you described the configuration correctly, the terminal will display a list of the resources to update and their parameters. This is a verification step that does not apply changes to your resources.

    2. If everything looks correct, apply the changes:

      1. Run this command:

        terraform apply
        
      2. Confirm updating the resources.

      3. Wait for the operation to complete.

    All the required resources will be created in the specified folder. You can check resource availability and their settings in the management console.

Install additional softwareInstall additional software

  1. (Optional) Install utilities on the local machine for downloading and uploading files over SSH, such as:

    • WinSCP
    • Putty SCP
  2. Make sure that GNU Screen is installed on the source cluster.

    It might take a long time to create and restore a dump. To keep these processes alive when your SSH session times out, start them using this utility. If your SSH connection breaks while creating or restoring the dump, reconnect and restore the session state using the command:

    screen -R
    

Connect to the source cluster and create a logical dumpConnect to the source cluster and create a logical dump

  1. Connect to the source cluster's master host via SSH.

  2. Download the archive with redis-dump-go from the project page. The examples below use version 0.5.1.

    wget https://github.com/yannh/redis-dump-go/releases/download/v0.5.1/redis-dump-go_0.5.1_linux_amd64.tar.gz
    
  3. Unpack the archive to the current directory:

    tar xf redis-dump-go_0.5.1_linux_amd64.tar.gz
    
  4. Get familiar with the utility launch parameters:

    ./redis-dump-go -h
    
  5. If connecting to the Valkey™ cluster requires a password, enter it in the REDISDUMPGO_AUTH environment variable:

    export REDISDUMPGO_AUTH="<Valkey™_password>"
    
  6. Start an interactive screen session:

    screen
    
  7. Launch the creation of a logical dump:

    ./redis-dump-go \
        -host <master_host_IP_address_or_FQDN_in_Valkey™_cluster> \
        -port <Valkey™_port> > <dump_file>
    

    Tip

    As the dump is created, the number of processed keys is shown on the screen. Remember or write down the last output value: you will need it to check whether the dump has been restored completely in the target cluster.

  8. When the dump has been created, download it to your computer.

  9. Complete the interactive screen session:

    exit
    

(Optional) Upload the dump to the intermediate virtual machine(Optional) Upload the dump to the intermediate virtual machine

  1. Connect to the intermediate VM via SSH.

  2. Upload the dump from your computer to an intermediate virtual machine however is convenient.

Restore the dump on the target clusterRestore the dump on the target cluster

  1. Connect to the cluster and run an interactive screen session:

    screen
    
  2. Start the dump recovery process:

    Connecting without TLS
    Connecting via TLS

    Before connecting, install the dependencies:

    sudo apt update && sudo apt install -y redis-tools
    

    Connecting via Sentinel

    host=$(redis-cli \
      -h <FQDN_of_any_Valkey™_host> \
      -p 26379 \
      sentinel \
      get-master-addr-by-name \
      no-shards-no-tls | head -n 1)
    redis-cli \
      -h ${host} \
      -p 6379 \
      -a <target_cluster_password> \
      --pipe < <dump_file>
    

    Connecting directly to the master host

    redis-cli \
      -h <master_host_FQDN> \
      -p 6379 \
      -a <target_cluster_password> \
      --pipe < <dump_file>
    

    When connecting to a non-sharded cluster, instead of the master host's FQDN, you can use special FQDNs.

    Connecting to a sharded cluster

    1. Create a script containing the dump-loading commands:

      load-dump.sh

      shards=('<FQDN_of_master_host_in_shard_1>' \
              ...
              '<FQDN_of_master_host_in_shard_N>')
      
      for shard in "${shards[@]}" ; do
        redis-cli -h "${shard}" \
                  -p 6379 \
                  -a "<target_cluster_password>" \
                  --pipe < <dump_file>
      done
      
    2. Run the script:

      bash ./load-dump.sh
      

      As you run the script, you will see messages about data insertion errors. This is normal behavior for the redis-cli command, because in a sharded cluster, each shard stores only a certain part of the data. To learn more, see Sharding in Yandex Managed Service for Valkey™.

    Before connecting, install the dependencies:

    Build the redis-tools utility with TLS support in one of two ways:

    • From a repository

      1. Connect a repository:

        sudo apt-add-repository ppa:redislabs/redis
        

        Packages in this repository have already been built with the BUILD_TLS=yes flag.

      2. Install the utility:

        sudo apt update && sudo apt install -y redis-tools
        
    • Manually

      Go to the directory you want to download the distribution to. Download the stable version of the utility, then build and install it:

      wget https://download.redis.io/redis-stable.tar.gz && \
      tar -xzvf redis-stable.tar.gz && \
      cd redis-stable && \
      make BUILD_TLS=yes && \
      sudo make install && \
      sudo cp ./src/redis-cli /usr/bin/
      

    Connecting via Sentinel

    host=$(redis-cli \
           -h <FQDN_of_any_Valkey™_host> \
           -p 26379 \
           sentinel \
           get-master-addr-by-name \
           no-shards-tls | head -n 1)
    redis-cli \
        -h ${host} \
        -p 6380 \
        -a <target_cluster_password> \
        --tls \
        --cacert ~/.redis/YandexInternalRootCA.crt \
        --pipe < <dump_file>
    

    Connecting directly to the master host

    redis-cli \
        -h c-<cluster_ID>.rw.mdb.yandexcloud.net \
        -p 6380 \
        -a <target_cluster_password> \
        --tls \
        --cacert ~/.redis/YandexInternalRootCA.crt \
        --pipe < <dump_file>
    

    When connecting to a non-sharded cluster, instead of the master host's FQDN, you can use special FQDNs.

    Connecting to a sharded cluster

    1. Create a script containing the dump-loading commands:

      load-dump.sh

      shards=('<FQDN_of_master_host_in_shard_1>' \
              ...
              '<FQDN_of_master_host_in_shard_N>')
      
      for shard in "${shards[@]}" ; do
        redis-cli -h "${shard}" \
                  -p 6380 \
                  -a "<target_cluster_password>" \
                  --tls \
                  --cacert ~/.redis/YandexInternalRootCA.crt \
                  --pipe < <dump_file>
      done
      
    2. Run the script:

      bash ./load-dump.sh
      

      As you run the script, you will see messages about data insertion errors. This is normal behavior for the redis-cli command, because in a sharded cluster, each shard stores only a certain part of the data. To learn more, see Sharding in Yandex Managed Service for Valkey™.

  3. Complete the interactive screen session:

    exit
    

Make sure that the dump is restored completelyMake sure that the dump is restored completely

  1. In the management console, go to the folder to restore the cluster in.
  2. From the list of services, select Yandex Managed Service for Valkey™.
  3. Click the cluster name and open the Monitoring tab.

Pay attention to the DB Keys chart showing the number of keys stored in the cluster. If the cluster is sharded, the chart will show the number of keys in each shard. In this case, the number of keys in the cluster is equal to the total number of keys in the shards.

The total number of keys in the cluster must be equal to the number of keys processed by redis-dump-go when creating the dump.

Delete the resources you createdDelete the resources you created

Delete the resources you no longer need to avoid paying for them:

Manually
Terraform
  • Delete the Yandex Managed Service for Valkey™ cluster.
  • If you created an intermediate virtual machine, delete it.
  • If you reserved public static IP addresses, release and delete them.
  1. In the terminal window, go to the directory containing the infrastructure plan.

    Warning

    Make sure the directory has no Terraform manifests with the resources you want to keep. Terraform deletes all resources that were created using the manifests in the current directory.

  2. Delete resources:

    1. Run this command:

      terraform destroy
      
    2. Confirm deleting the resources and wait for the operation to complete.

    All the resources described in the Terraform manifests will be deleted.

Was the article helpful?

Previous
Storing PHP sessions in Yandex Managed Service for Valkey™
Next
Resource relationships
© 2025 Direct Cursus Technology L.L.C.