eclzyg
Last Updated: February 25, 2016
·
2.748K
· 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://some.host.com:11111"
redisDest = Redis.connect :url => "redis://other.host.com:22222"

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

1 Response
Add your response

26824

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:

https://www.npmjs.com/package/redis-utils-cli

over 1 year ago ·