go-redismigrate
Fast, reliable Redis key migration with real-time progress monitoring
Migrate Redis keys between instances with streaming key scanning, conflict resolution, and a beautiful terminal interface.
Features β’
Installation β’
Quick Start β’
β¨ Features
- π High Performance: Pipeline-based operations with streaming key scanning
- π― Pattern Matching: Support for Redis glob patterns (
user:*, session:*, etc.)
- π Migration Modes: Copy or move keys between Redis instances
- β‘ Conflict Resolution: Error, skip, or overwrite existing keys
- π Real-time Progress: Beautiful terminal UI with live metrics
π¦ Installation
Using Go Install
go install github.com/pucke-dev/go-redismigrate@latest
From Source
git clone https://github.com/pucke-dev/go-redismigrate.git
cd go-redismigrate
go build -o redismigrate
π Quick Start
Basic Migration
# Copy all keys from db0 to db1
redismigrate --source redis://localhost:6379/0 --dest redis://localhost:6379/1
# Move user sessions to different Redis instance
redismigrate \
--source redis://localhost:6379/0 \
--dest redis://remote:6379/1 \
--pattern "session:*" \
--mode move
With Authentication
# Migrate with Redis AUTH
redismigrate \
--source redis://user:pass@source.redis.com:6379/0 \
--dest redis://user:pass@dest.redis.com:6379/0 \
--pattern "app:*"
π Usage
Usage: redismigrate [options]
Options:
--source Source Redis connection string REQUIRED
--dest Destination Redis connection string REQUIRED
--pattern Key pattern to match (Redis glob pattern) (default: *)
--mode Migration mode (default: copy)
--conflict Key conflict behavior (default: error)
--batch-size Number of keys to process in each batch (default: 100)
--concurrency Number of concurrent workers (default: 4)
--verbose Enable verbose logging (default: false)
--version Show version information
--help Show this help message
Examples:
Basic copy migration:
redismigrate -source redis://localhost:6379/0 -dest redis://localhost:6379/1
Move specific pattern:
redismigrate -source redis://src:6379/0 -dest redis://dst:6379/0 -pattern "user:*" -mode move
High throughput with custom batch size:
redismigrate -source redis://src:6379/0 -dest redis://dst:6379/0 -batch-size 500 -concurrency 8
Mode Options:
copy Copy keys to destination (keeps source)
move Move keys to destination (removes from source)
Conflict Options:
error Stop migration on key conflicts
skip Skip conflicting keys
overwrite Overwrite existing keys
π Migration Modes
| Mode |
Description |
Use Case |
copy |
Copy keys to destination, keep source |
Data replication, backup |
move |
Move keys to destination, delete from source |
Database migration, cleanup |
βοΈ Conflict Resolution
| Behavior |
Description |
Use Case |
error |
Stop migration on first conflict |
Safe migrations, data integrity |
skip |
Skip existing keys, continue migration |
Incremental updates |
overwrite |
Replace existing keys with source data |
Data synchronization |
Project Structure
βββ internal/
β βββ migrate/ # Core migration logic
β βββ redis/ # Redis client with pipelining
β βββ stats/ # Real-time metrics tracking
β βββ tui/ # Terminal user interface
βββ scripts/ # Development utilities
βββ main.go # CLI entry point
π License
This project is licensed under the MIT License - see the LICENSE file for details.
β Star this repo if you find it useful! β