问题
Given a snapshot of an existing redis database in a dump.rdb (or in .json format) file, I want to restore this data in my own machine to run some tests on it.
Any pointers on how to do this would be greatly appreciated.
I have resorted to trying to parse the data in the dump.rdb and then save it in a redis DB manually. I feel like there is/should be a cleaner way.
回答1:
If you want to restore the entire file, simply copy it to the right directory specified in redis.conf
and restart redis server. But if you want to load a subset of keys/databases, you'd have to parse the dump file.
回答2:
SO:
I continued doing it the "hacky" way and found that using the parser code found here: https://github.com/sripathikrishnan/redis-rdb-tools was a great help.
using the parser sample code i could: 1) set up a redis client 2) use the parser to parse the data 3) use the client to "set" parsed data into a new redis database.
回答3:
the rdd tools can also do that,
it work independantly of .rdb files and dump/restore working redis instances
it can apply merge, split, rename, search, filter, insert, delete on dumps and/or redis
来源:https://stackoverflow.com/questions/10842470/linking-redis-database-with-a-dump-rdb-or-dump-json-file