Migrate your Redis deployment to Northflank | Migrate Data to Northflank | Databases And Persistence | Northflank Application docs

Databases And Persistence / Migrate Data to Northflank /

Migrate your Redis deployment to Northflank

You can import your existing Redis data to Northflank either as a snapshot of the database or by using live replication to transfer existing and new keys to your Northflank Redis addon.

You should first create a Northflank Redis addon to import to.

Import a snapshot using RIOT-redis

You can import your current Redis instance's keys and values using RIOT-Redis . Download and install the tool on your local machine, or on the server with your existing Redis instance.

It is recommended that you make both the source Redis instance and the Northflank Redis addon publicly accessible over the internet. Alternatively, you can forward the Northflank addon to your local machine or existing Redis deployment and use the non-external command to connect securely.

The exact command you will need to run depends on your existing Redis provider and your Redis usage. You may need to configure reader options if you store a lot of keys, or big sets.

From managed service to Northflank

You can migrate from an existing service provider using the URI for your existing Redis instance, and the URI for your Northflank Redis addon (REDIS_MASTER_URL, found on the connection details page).

## without TLS (forwarding Northflank addon)
riot-redis -u <SOURCE_REDIS_URI> replicate -u <REDIS_MASTER_URL>

## with TLS enabled on Redis source and Northflank addon
riot-redis -u <SOURCE_REDIS_URI> --tls --tls-verify=NONE replicate -u <REDIS_MASTER_URL> --tls --tls-verify=NONE

The Redis URI should take the format rediss://<USER>:<PASSWORD>@<HOST>:<PORT>, or redis://<USER>:<PASSWORD>@<HOST>:<PORT> for connections not secured using TLS.

From local machine to Northflank

You can migrate from your local machine, or via the terminal on your server, by specifying the hostname and port of the local instance, while giving the Northflank URI as the target.

riot-redis -h <SOURCE_HOST> -p <SOURCE_PORT> replicate -u <REDIS_MASTER_URL> --tls --tls-verify=NONE

RIOT-Redis should import all keys and values from the source Redis instance to your Northflank addon, you can double-check that the import has run as you expected it to by accessing the addon.

Live replication using RIOT-redis

You can configure live replication between your existing and Northflank Redis instances using RIOT-Redis's live replication mode .

This method will allow you to seamlessly migrate a Redis instance, as new keys will be transferred to your new Northflank Redis instance. This method uses pub/sub which means delivery is not guaranteed, and it may also fail if trying to copy big sets repeatedly. You should evaluate your Redis store for big sets before using these methods to migrate.

Before using live replication you will need to enable keyspace notifications in each Redis instance. You can do this by logging into each instance using redis-cli and entering the command CONFIG SET notify-keyspace-events KA.

You can use the same commands as to import a snapshot, adding the required mode flag at the end of the command:

Live only --mode liveonly

Live only mode will only replicate keys added or updated in your source Redis instance after the process has started, and not keys that currently exist in your source Redis.

Initial and live --mode live

Live mode will copy your current keys from your source Redis instance, as well as replicate any new keys and updates to keys from your source Redis while the process is running.

Verification and migration

You can double-check that replication is working as expected by accessing the addon manually, or running RIOT-Redis's compare command .

You can now configure your applications and infrastructure to use the Northflank Redis addon. Once your changes are live, you can terminate the RIOT-Redis replicate process and shut down your source Redis instance.

© 2023 Northflank Ltd. All rights reserved.