`
sillycat
  • 浏览: 2539378 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Redis Backup Restore Parser with RDB

 
阅读更多
Redis Backup Restore Parser with RDB

We can backup any Redis DB in AWS console.

We can also directly export the backup to S3 as a RDB file. Select the backup Data and click ‘Copy’.

Sometimes, we need to give access permission to AWS to our S3.
Follow the link https://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/Snapshots.Exporting.html

I add
All other regions – 540804c33a284a299d2547575ce1010f2312ef3da9b3a053c8bc45bf233e4353

to our S3 bucket permission.

We can also create a Redis Cache Service seed from our RDB file. But for cluster, we need 3 shard files. So that means, we can backup our master-replica, then we can create a master-replica. We can back up 3 shard cluster, we can create a 3 shard cluster. But we can not do from master-replica to 3 shard cluster.

Another solution is that we can download the RDB file.

Then we can use a tool to parse the RDB file.
https://github.com/sripathikrishnan/redis-rdb-tools

Here is how I install it.

git clone https://github.com/sripathikrishnan/redis-rdb-tools
cd redis-rdb-tools
sudo python3 setup.py install

Check the size of one key
> redis-memory-for-key -s redishost -p 6379 job_787_2417109
Key job_787_2417109
Bytes 7292.0
Type hash
Encoding hashtable
Number of Elements 60
Length of Largest Element 1498

get all keys and values to a output file
> rdb --command justkeyvals --key "user*" ~/Downloads/stagejobs20170223.rdb -f output.json

get all value in JSON format
> rdb --command json ~/Downloads/stagejobs20170223.rdb

References:
https://github.com/sripathikrishnan/redis-rdb-tools

http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/Snapshots.Exporting.html
http://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/Snapshots.SeedingRedis.html
https://docs.aws.amazon.com/AmazonElastiCache/latest/UserGuide/Snapshots.Exporting.html
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics