ElastiCache Migration
This recipe contains step-by-step instructions to migrate an ElastiCache (EC) database to Redis Cloud or Redis Software.
The following scenarios are covered:
-
One-time (snapshot) migration
-
Online (live) migration
It is recommended to read the Replication section to familiarize yourself with its usage and architecture. |
Setup
Prerequisites
For this recipe you will require the following resources:
-
AWS ElastiCache: Primary Endpoint in case of Single Master and Configuration Endpoint in case of Clustered EC. Refer to this link to learn more
-
An Amazon EC2 instance to run RIOT-X (for manual CLI migration)
For automated migration using the CloudFormation template, you only need the ElastiCache cluster ID (the template handles all networking and infrastructure setup automatically). |
Keyspace Notifications
For a live migration you need to enable keyspace notifications on your ElastiCache instance (see AWS Knowledge Center). |
Migration Host
To run the migration tool we will need an EC2 instance.
You can either create a new EC2 instance or leverage an existing one if available. In the example below we first create an instance on AWS Cloud Platform. The most common scenario is to access an ElastiCache cluster from an Amazon EC2 instance in the same Amazon Virtual Private Cloud (Amazon VPC). We have used Ubuntu 16.04 LTS for this setup but you can choose any Ubuntu or Debian distribution of your choice.
SSH to this EC2 instance from your laptop:
ssh -i βpublic keyβ <AWS EC2 Instance>
Install redis-cli
on this new instance by running this command:
sudo apt update
sudo apt install -y redis-tools
Use redis-cli
to check connectivity with the ElastiCache database:
redis-cli -h <ec primary endpoint> -p 6379
Ensure that the above command allows you to connect to the remote ElastiCache database successfully.
Installing RIOT-X
Let’s install RIOT-X on the EC2 instance we set up previously. For this we’ll follow the steps in Manual Installation.
Performing Migration
We are now all set to begin the migration process. The options you will use depend on your source and target databases, as well as the replication mode (snapshot or live).
Live ElastiCache Single Master → Redis
riotx replicate source:port target:port --mode live
In case ElastiCache is configured with AUTH TOKEN enabled, you need to pass
|
ElastiCache Cluster → Redis
riotx replicate source:port target:port --source-cluster
--cluster is an important parameter used ONLY for ElastiCache whenever cluster-mode is enabled.
Do note that the source database is specified first and the target database is specified after the replicate command and it is applicable for all the scenarios.
|
ElastiCache Single Master → Redis (with specific database index)
riotx replicate redis://source:port/db target:port
Important Considerations
-
It is recommended to test migration in UAT before production use.
-
Once migration is completed, ensure that application traffic gets redirected to Redis endpoint successfully.
-
It is recommended to perform the migration process during low traffic hours so as to avoid chances of data loss.
CloudFormation
For the easiest migration experience, use the CloudFormation template that automates the entire process. This template automatically discovers your ElastiCache configuration and handles all the infrastructure setup.
Step-by-Step Migration Guide
Step 1: Gather Required Information
Before starting, you’ll need:
-
ElastiCache Cluster ID:
-
Go to AWS Console β ElastiCache
-
Find your Redis cluster and copy the Name (not the endpoint)
-
Examples:
my-redis-cluster
,production-cache-001
-
-
Target Redis URI:
-
Get this from your Redis Cloud or Redis Enterprise provider
-
Format:
redis://username:password@host:port
orrediss://username:password@host:port
-
Example:
redis://default:mypassword@redis-12345.c1.us-west-2.ec2.redns.redis-cloud.com:12345
-
Step 2: Deploy the Migration Template
-
Open the CloudFormation Console:
-
Click this link: π Deploy Migration Template
-
This opens AWS CloudFormation with the template pre-loaded
-
-
Configure the Stack:
-
Stack name: Keep
riotx-elasticache-sync
or choose your own name -
Click Next
-
-
Fill Required Parameters:
-
Source ElastiCache Cluster ID: Enter your ElastiCache cluster name from Step 1
-
Target Redis URI: Enter your Redis Cloud/Enterprise URI from Step 1
-
Leave all other settings as defaults (they work for most cases)
-
Click Next
-
-
Review and Deploy:
-
Scroll down and check β I acknowledge that AWS CloudFormation might create IAM resources
-
Click Submit
-
Step 3: Monitor the Migration
The migration starts automatically when the CloudFormation stack is created.
-
Watch Stack Progress:
-
Stay on the CloudFormation console
-
Watch the Events tab - you’ll see resources being created
-
The stack typically takes 5-10 minutes to complete
-
-
Check Migration Status:
-
When the stack shows CREATE_COMPLETE, go to the Outputs tab
-
Look for
MigrationExecutionMessage
- it will show "migration completed successfully"
-
-
View Migration Logs (optional):
-
In the Outputs tab, click the
LogGroupUrl
link -
This takes you directly to CloudWatch logs showing migration details
-
Or copy the
ViewLogsCommand
and run it in AWS CLI
-
Step 4: Verify Migration Success
-
Check Your Target Redis:
-
Connect to your Redis Cloud/Enterprise database
-
Verify that your data has been migrated
-
Check key counts:
INFO keyspace
-
-
Review Migration Details:
-
The CloudFormation Outputs tab shows discovered source configuration
-
Check
SourceRedisURI
,SourceClusterMode
,SourceTransitEncryption
-
Verify these match your ElastiCache setup
-
Advanced Configuration (Optional)
If you need to customize the migration, expand the parameter sections when filling the template:
Migration Settings:
-
Sync Mode: Choose
SCAN
(one-time),LIVE
(continuous), orLIVEONLY
-
Compare Mode: Choose
QUICK
for basic verification orFULL
for complete comparison -
Dry Run: Set to
true
to test without actually copying data
Performance Tuning:
-
Batch Size: Increase from 50 to 200+ for faster migration of small keys
-
Thread Count: Increase from 1 to 4+ for parallel processing
Authentication (if needed):
-
Source User/Password: Only if your ElastiCache has AUTH enabled
-
Target Cluster Mode: Set to
true
if your target Redis uses cluster mode
What the Template Does Automatically
-
β Discovers your ElastiCache VPC, subnets, and security groups
-
β Configures network access between ElastiCache and the migration container
-
β Creates ECS infrastructure to run the migration
-
β Runs the migration automatically during stack creation
-
β Sets up CloudWatch logging for monitoring
-
β Reuses existing infrastructure if available
Typical Workflow
For comprehensive testing and migration:
-
Prerequisites for Live Migration:
-
Ensure your ElastiCache cluster has keyspace notifications enabled (required for LIVE mode)
-
-
Migrate Data:
-
Deploy
ec-sync.yaml
to migrate from ElastiCache to target Redis -
Choose migration mode: SCAN (snapshot), LIVE (scan + live changes), or LIVEONLY (live only)
-
Monitor progress via CloudWatch logs
-
-
Verify Migration:
-
Check CloudFormation stack outputs for completion status
-
Review CloudWatch logs for any errors
-
Verify data in target Redis database
-
Monitoring and Logging
Both CloudFormation templates include enhanced logging capabilities that make it easy to monitor and troubleshoot RIOT-X container operations:
Enhanced Logging Features:
-
CloudWatch Log Group: Automatically created with 14-day retention
-
Direct Log Access URLs: CloudFormation outputs include direct links to view logs
-
AWS CLI Commands: Ready-to-use commands for viewing and tailing logs
-
Enhanced Log Configuration: Better timestamping and buffering
Accessing Logs:
After deploying a CloudFormation stack, you can access logs in several ways:
Via CloudFormation Outputs:
-
Go to CloudFormation console β your stack β Outputs tab
-
Look for these outputs:
-
LogGroupUrl
: Direct link to CloudWatch logs in AWS Console -
ViewLogsCommand
: AWS CLI commands to view recent logs -
LogGroup
: Name of the CloudWatch log group
-
Via AWS Console:
-
Go to CloudWatch in the AWS Console
-
Navigate to "Log groups"
-
Find the log group (default:
/ecs/riot-migration
or/ecs/riot-generation
) -
Click on log streams to view container output
Via AWS CLI:
# List recent log streams
aws logs describe-log-streams --log-group-name "/ecs/riot-migration" --order-by LastEventTime --descending
# View latest logs (real-time tailing)
aws logs tail "/ecs/riot-migration" --follow
# Get specific log events
aws logs get-log-events --log-group-name "/ecs/riot-migration" --log-stream-name "ecs/container-name/task-id"
Log Stream Naming Convention:
ECS creates log streams with this format: ecs/[container-name]/[task-id]
For example: ecs/riot-migration/a1b2c3d4-e5f6-7890-abcd-ef1234567890
What You’ll See in the Logs:
-
Migration progress information ("Scanning", "Comparing")
-
Connection details (source ElastiCache, target Redis Cloud)
-
Job execution status and timing
-
Configuration parameters and validation
-
Error messages and troubleshooting information
Troubleshooting
Common Issues:
-
Stack Creation Failed: Check CloudWatch logs for detailed error messages
-
Permission Errors: Ensure your AWS user has CloudFormation and ECS permissions
-
Network Connectivity: Verify security groups allow Redis connectivity
-
ElastiCache Not Found: Double-check cluster ID and AWS region
-
Target Redis Unreachable: Verify Redis Cloud URI and credentials
Logging Troubleshooting:
If you don’t see logs:
-
Check ECS Task Status: Ensure the task started successfully
-
Verify IAM Permissions: The task execution role needs CloudWatch Logs permissions
-
Check Network Connectivity: Tasks need internet access to pull container images
-
Review Task Definition: Ensure the log configuration is properly set
Getting Help:
-
CloudWatch Logs:
/ecs/riot-migration
log group contains detailed execution logs -
CloudFormation Events: Check stack events for resource creation details
-
Stack Outputs: Review outputs for auto-discovered configuration and status