Migrating Redis Data with redis-dump and redis-load: Ruby Setup and Step‑by‑Step Guide
This guide explains three Redis migration methods, focuses on using the third‑party tools redis‑dump and redis‑load, and provides detailed steps to upgrade Ruby, install RVM, set up redis‑dump, and export/import data in JSON format.
There are generally three ways to migrate Redis data: using third‑party tools such as redis-dump and redis-load , enabling the AOF (Append‑Only File) mechanism, or using the RDB snapshot mechanism.
The example below demonstrates data export with redis-dump and import with redis-load . Because redis-dump depends on Ruby (version > 2.2.2), the Ruby environment must be upgraded first.
1. Add the Aliyun RubyGems mirror and verify the current sources:
gem sources -a http://mirrors.aliyun.com/rubygems/
gem sources --remove https://rubygems.org/
gem sources -l # shows only the Aliyun source
Current source:
http://mirrors.aliyun.com/rubygems/
2. Install RVM (Ruby Version Manager) to manage Ruby versions easily:
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
source /etc/profile.d/rvm.sh
Verify RVM installation:
rvm -v
Output example: rvm 1.29.10 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin https://rvm.io
3. Install a Ruby version higher than 2.2.2 (e.g., 2.6):
rvm list known # list available Ruby versions
... (list of versions) ...
rvm install 2.6
Verify the installation:
ruby -v
Expected output: ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]
4. Install redis-dump (which also provides redis-load and redis-report ):
gem install redis-dump -V
Check the installed binaries:
ll /usr/local/rvm/gems/ruby-2.6.5/bin/
Typical output shows:
-rwxr-xr-x 1 root rvm 567 Jan 20 12:32 redis-dump
-rwxr-xr-x 1 root rvm 567 Jan 20 12:32 redis-load
-rwxr-xr-x 1 root rvm 571 Jan 20 12:32 redis-report
5. Export and import data:
Export data to a JSON file (replace yourpassword with the actual password or omit the password part if none):
redis-dump -u:[email protected]:6380 > /tmp/redis-mv.json
Import the JSON file into the target Redis instance:
cat /tmp/redis-mv.json | redis-load -u :[email protected]:6383
After the import finishes, verify the data on the destination Redis server.
Practical DevOps Architecture
Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.