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
Written by Matjaz Muhic
Related protips
1 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
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#