Last Updated: February 25, 2016
· depy

Redis to redis data copy

There will be times when you won't have access to the server runing your redis (heroku for example). And many of those services don't have an option to import data from file.

If you're using ruby you can copy data between two redis servers directly using redis commands DUMP and RESTORE.

Here's how I did it (it's not fast, it's actually pretty slow but it works):

redisSrc = Redis.connect :url => "redis://"
redisDest = Redis.connect :url => "redis://"

redisSrc.keys("*").each do |key| 
  data = redisSrc.dump key 
  redisDest.restore key, 0, data 

1 Response
Add your response

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:

over 1 year ago ·