- Published on
Migrate Redis Keys Without RDB Files
- Authors

- Name
- Kevin van Zonneveld
- @kvz
Recently we moved the Transloadit status page from an unmanaged EC2 instance to the Nodejitsu platform. We kept status uptime history in redis, and obviously I wanted to preserve that data.
For the new setup I did not have access to the filesystem, I only had a redis
port to talk to. So instead of rsyncing the .rdb file I used Redis replication
to migrate the data between instances.
Here's the redacted terminal transcript, the sending host is old-redis.transloadit.com, the receiving host is new-redis.transloadit.com.
$ # First let's connect to the new host
$ redis-cli -h new-redis.transloadit.com
redis new-redis.transloadit.com:6379> AUTH ...:...
OK
# Let's start with a clean slate, first make sure it stands alone
redis new-redis.transloadit.com:6379> SLAVEOF NO ONE
OK
# WARNING! This will trash all existing data on the receiving host
redis new-redis.transloadit.com:6379> FLUSHALL
OK
# Now setup replication so that redis copies all keys from old to new
redis new-redis.transloadit.com:6379> SLAVEOF old-redis.transloadit.com 6379
OK
# Wait until INFO shows `role:slave`, and the
# same amount of keys as on the old server.
redis new-redis.transloadit.com:6379> INFO
...
role:slave
...
OK
# Check some random keys to see if you have all the data.
redis new-redis.transloadit.com:6379> LRANGE history 0 1
1) "{\"message\":\"All services operational\",\"date\":\"2013-04-15\"}"
OK
# Looks good, now let's disable slave mode, make it stand alone again
redis new-redis.transloadit.com:6379> SLAVEOF NO ONE
OK
And that's it, you've copied all the redis keys without using .rdb files.
Hope this helps, let me know if you have suggestions.
Legacy Comments (4)
These comments were imported from the previous blog system (Disqus).
Nice post!
Nice post, Just been doing this myself, although I think the sentence " I used rync replication" should read " I used redis replication"
Thanks a lot I corrected the article!
Nice post. I thought your readers would like to know that I just published a command line interface utility to npm and github that allows you to copy keys that match a given pattern (even *) from one Redis database to another.
You can find the utility here: