Created
June 27, 2016 23:51
-
-
Save longlostnick/e8d608b57f62be0ae86cd780c30a6527 to your computer and use it in GitHub Desktop.
Migrate redis key/values by key match
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'redis' | |
redisSrc = Redis.connect url: "redis://<src>:6379" | |
redisDest = Redis.connect url: "redis://<dest>:6379" | |
redisSrc.keys("*").each do |key| | |
begin | |
data = redisSrc.dump key | |
ttl = redisSrc.pttl key # milleseconds | |
redisDest.restore key, ttl, data | |
rescue => e | |
p key, e | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment