How to Migrate from Redis to Valkey on Ubuntu 24.04 (Step by Step)

Introduction
In March 2024, Redis Ltd. changed the license for Redis modules from BSD to a source-available license. By 2026, the community fork Valkey - backed by the Linux Foundation, adopted by AWS, Google Cloud, and Oracle - has become the standard open-source replacement. It is a drop-in compatible fork that is 8% faster on average and costs 20% less on AWS ElastiCache.
If you run Redis on your own servers, this guide walks you through migrating to Valkey on Ubuntu 24.04 with zero data loss using the RDB-safe method.
Why Migrate
- License certainty. Valkey is BSD-licensed. No risk of future license changes.
- Performance. Valkey 7.2.11 runs 5-10% faster than Redis 7.2 on identical hardware due to IO threading improvements.
- Active development. The Linux Foundation, AWS, and Google contribute to Valkey. Redis Ltd.'s community contributions have slowed since the license change.
- Drop-in compatible. Same protocol, same commands, same config format. Your application code does not change.
Prerequisites
- Ubuntu 24.04 server
- Redis 7.x installed and running
- Root or sudo access
- A maintenance window (the migration requires a Redis restart)
Check your current Redis version:
redis-server --version
redis-cli INFO server | grep redis_version
Step 1: Install Valkey
Add the Valkey repository and install:
curl -fsSL https://packages.valkey.io/valkey-key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/valkey-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/valkey-archive-keyring.gpg] https://packages.valkey.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/valkey.list
apt update
apt install valkey -y
This installs Valkey alongside Redis. They use different config files and ports by default.
Step 2: Configure Valkey to Match Your Redis Setup
Edit /etc/valkey/valkey.conf. Copy these critical settings from your /etc/redis/redis.conf:
# Port (Valkey defaults to 6379, same as Redis - change if you want to run both during migration)
port 6380
# Memory
maxmemory 512mb
maxmemory-policy allkeys-lru
# Persistence
save 900 1
save 300 10
save 60 10000
dir /var/lib/valkey
# Network
bind 127.0.0.1
protected-mode yes
# Auth (copy your Redis requirepass if set)
requirepass your-password-here
Key difference: Valkey stores data in /var/lib/valkey/ by default, not /var/lib/redis/.
Step 3: Migration - RDB-Safe Method
This method exports data from Redis, imports to Valkey, and then cuts over. Zero data loss if done correctly.
3a. Verify Redis data
redis-cli DBSIZE
Note the key count. You will verify this after migration.
3b. Trigger a fresh RDB dump
redis-cli BGSAVE
redis-cli LASTSAVE
Wait for the timestamp to update. Check /var/lib/redis/dump.rdb exists.
3c. Import RDB into Valkey
Stop Valkey, copy the dump file, and start Valkey:
systemctl stop valkey
cp /var/lib/redis/dump.rdb /var/lib/valkey/dump.rdb
chown valkey:valkey /var/lib/valkey/dump.rdb
systemctl start valkey
3d. Verify migration
redis-cli -p 6380 DBSIZE
redis-cli -p 6380 PING
The key count should match. Run a few random key checks:
redis-cli GET some-key-name
redis-cli -p 6380 GET some-key-name
Both should return identical values.
Step 4: Cutover - Switch Your Application to Valkey
4a. Stop Redis
systemctl stop redis
4b. Switch Valkey to port 6379
Edit /etc/valkey/valkey.conf:
port 6379
Restart Valkey:
systemctl restart valkey
4c. Update your application
If your app connects to localhost:6379, no changes needed. If you configured a custom port, update the connection string.
Test your application thoroughly. Run health checks. Watch logs for connection errors.
4d. Final verification
redis-cli PING
redis-cli INFO server | grep redis_version
Should return PONG and show the Valkey version.
Step 5: Clean Up Redis
Once you confirm everything works:
systemctl disable redis
apt purge redis-server redis-tools -y
rm -rf /var/lib/redis/
Rollback Plan
If something goes wrong:
systemctl stop valkey
systemctl start redis
# Switch your app back to Redis port
Redis and Valkey RDB files are compatible. You can copy /var/lib/valkey/dump.rdb back to /var/lib/redis/ if needed.
Post-Migration Tuning
Valkey supports additional config options not in Redis:
# IO threads (Redis is single-threaded for commands, Valkey can use multiple)
io-threads 4
io-threads-do-reads yes
# Active defrag (more efficient than Redis)
activedefrag yes
active-defrag-threshold-lower 10
active-defrag-cycle-min 5
active-defrag-cycle-max 75
Test these with your workload before enabling in production.
Monitoring After Migration
Update your monitoring to track Valkey-specific metrics. If using Prometheus, switch to the Valkey exporter:
apt install prometheus-valkey-exporter -y
systemctl enable prometheus-valkey-exporter --now
Check your dashboards. Key counts, memory usage, and hit rates should be identical to before migration.
How ServerGurus Helps
Our managed VPS and bare metal servers run Valkey out of the box on Ubuntu 24.04. We pre-configure IO threading and active defrag for optimal performance. If you need help migrating a production Redis instance or want a managed database solution, talk to our team.
Quick Reference
# Install
curl -fsSL https://packages.valkey.io/valkey-key.gpg | gpg --dearmor -o /usr/share/keyrings/valkey-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/valkey-archive-keyring.gpg] https://packages.valkey.io/deb noble main" | tee /etc/apt/sources.list.d/valkey.list
apt update && apt install valkey -y
# Migrate
redis-cli BGSAVE
systemctl stop valkey
cp /var/lib/redis/dump.rdb /var/lib/valkey/dump.rdb
chown valkey:valkey /var/lib/valkey/dump.rdb
systemctl start valkey
# Verify
redis-cli -p 6380 DBSIZE
# Cleanup after cutover
systemctl disable redis --now
apt purge redis-server -y