The Redis Migrator is a Golang-based tool designed to migrate database keys from one Redis cluster to another.
Since Redis 5.0.0, you can use REPLICAOF command to replicate data from one redis to another.
This application is developed for the older version of Redis or AWS ElastiCache instances that do not support REPLICAOF command (AWS docs).
(This repo is forked from opstree/redis-migration. The original repo has been inactive for over 3 years, so I decided to continue its development without creating pull requests.)
- String
- Hash
- List
- Set
- Sorted Set
go install github.com/huantt/redis-migrator@latestdocker run \
--rm \
-v /path/to/migrate.yaml:/data/migrate.yaml \
huanttok/redis-migrator migrate \
--config.file=/data/migrate.yaml \
--log.level=debugTo call localhost while using Docker, use host.docker.internal instead.
For using redis-migrator, we have to create a configuration file and provide some needful information to it. An example configuration file will look like this
---
old_redis:
host: localhost # IP redis server
port: 6379 # Port redis server
password: "" # Password of redis server, leave empty if there is no password
new_redis:
host: localhost
port: 6380
password: ""
migration_databases: [0,1,2,3,4,5,6,7,8] # Databases list which needs to be migrated
concurrent_workers: 5
clear_before_migration: trueThere are help page available for redis-migrator which can be called by help or --help command.
$ redis-migrator help
A tool for migrating redis database and its keys.
Usage:
redis-migrator [flags]
redis-migrator [command]
Available Commands:
help Help about any command
migrate Runs redis-migrator to run migration
version Prints the current version.
Flags:
-h, --help help for redis-migrator
--log.format string redis-migrator log format. (default "text")
--log.level string redis-migrator logging level. (default "info")
Use "redis-migrator [command] --help" for more information about a command.Simply we have to specify the path of config.yaml
$ redis-migrator migrate --config.file config.yaml --log.level=debug