Commands icon
Docker icon
Fail icon
Log icon
If icon
Get icon
OutputValues icon
Set icon
RedisCLI icon
LoopUntil icon
Pause icon
Delete icon
SlackIncomingWebhook icon
Schedule icon

Migrate Redis to Valkey or a newer Redis with a verified cutover

Migrate Redis to Valkey or a newer Redis with replication. Write protect the source, compare every key, promote the target and keep a rollback.

Categories
Data

A Redis move to Valkey or to a new major version usually means a downtime window or a blind copy. Replication keeps the new server current while the old one serves. The last steps are the risky ones: stopping writers, waiting for the exact catch-up point, proving that no key is missing and keeping the old server from taking writes after the switch. This flow runs those steps in order and records the result.

How it works

PREPARE checks the versions, because Valkey replicates only from Redis OSS 7.2 or older. It sets the replication login on the empty target, starts REPLICAOF and waits until the link is up.

CUTOVER asks for approval through a Pause. It sets min-replicas-to-write above the replica count so the source refuses writes with NOREPLICAS and proves that with a probe write. CLIENT PAUSE holds writes and expirations while the match is proved. The flow waits until the target reached the source offset. A read-only Lua digest then compares every key on both servers by type, value and expiry. Only then does it promote the target with REPLICAOF NO ONE and check that it takes writes.

ROLLBACK restores the source. After a completed cutover it re-attaches the target and refuses when the target changed, unless you confirm. FINALIZE ends the migration.

What you get

A target that matches the source key for key at a recorded replication offset. A source that refuses writes after the switch. A state record in the KV store for each step, so every mode can run again after a failure.

Who it's for

Teams that move Redis to Valkey, upgrade a Redis major version or change hosts and cannot accept a long outage.

Why orchestrate this with Kestra

Pause holds the approval. LoopUntil waits for the sync and the catch-up. The KV store keeps the migration state between runs. A failed step leaves a defined state with a rerun or a rollback.

Tested end to end

Kestra 2.0.6 and 2.0.5 with Redis 7.2 to Valkey 8.1, Redis 7.2 to Redis 8.6 and Valkey 8.1 to Valkey 9. Writers ran during the sync and the cutover. A limited user whose fence failed, a target that no longer matched, a stale approval, rollback and finalize were exercised. Each result was compared with DEBUG DIGEST.

Prerequisites

A source that is a master and an empty target on the same network. An ACL user that may run CONFIG on the source. Docker workers with the redis-cli image. The Redis, Shell scripts and Slack plugins.

Secrets

REDIS_SOURCE_PASSWORD, REDIS_TARGET_PASSWORD and SLACK_WEBHOOK_URL.

Inputs

mode selects PREPARE, CUTOVER, ROLLBACK or FINALIZE. dry_run defaults to true and auto_remediate to false, so nothing changes until both are flipped. freeze_seconds bounds the write hold. verify_percent samples the keys when a full read is too slow.

Quick start

  1. Run PREPARE as a dry run and read the plan. Run it again with dry_run false and auto_remediate true.
  2. Run CUTOVER and approve it. Applications that write to the source wait for the hold and are then refused.
  3. Repoint the applications when it reports the cutover.
  4. Run FINALIZE when the old server is no longer needed.

How to extend

Add TLS flags to the redis-cli calls for a managed service. Redis Cluster, modules and stream consumer groups are outside the flow. The key comparison reads whole values, so sample very large datasets.

Links

This blueprint was created by zkasuran.

See How

New to Kestra?

Use blueprints to kickstart your first workflows.