leonchen83/redis-rdb-cli

merge two rdb files with repeated key

lnnt opened this issue · 2 comments

lnnt commented

dump1.rdblike this:
[{"key":"device","value":{"device1":"IOS"},"db":0,"type":"hash"}]

dump2.rdblike this:
[{"key":"device","value":{"device2":"macOS"},"db":0,"type":"hash"}]

After rdt -m ./dump1.rdb ./dump2.rdb -o ./dump.rdb -t hash I got:

[
{"key":"device","value":{"device1":"IOS"},"db":0,"type":"hash"},
{"key":"device","value":{"device2":"macOS"},"db":0,"type":"hash"}
]

But I want:
[{"key":"device","value":{"device1":"IOS","device2":"macOS"},"db":0,"type":"hash"}]

Can redis-rdb-cli do it?
Thank u very much!

yes rdt -m exactly means concat not merge

if you want merge hash key. do with following steps
step1 : perpare an empty redis
step2 : save dump1.rdb and dump2.rdb to that empty redis

rct -f resp -s /path/to/dump1.rdb -o /path/to/dump1.aof 
cat /path/to/dump1.aof | /redis/src/redis-cli -p 6379 --pipe

rct -f resp -s /path/to/dump2.rdb -o /path/to/dump2.aof
cat /path/to/dump2.aof | /redis/src/redis-cli -p 6379 --pipe

step3 : get the final rdb from that redis

rdt -b redis://127.0.0.1:6379 -o /path/to/dump.rdb
lnnt commented

yes rdt -m exactly means concat not merge

if you want merge hash key. do with following steps step1 : perpare an empty redis step2 : save dump1.rdb and dump2.rdb to that empty redis

rct -f resp -s /path/to/dump1.rdb -o /path/to/dump1.aof 
cat /path/to/dump1.aof | /redis/src/redis-cli -p 6379 --pipe

rct -f resp -s /path/to/dump2.rdb -o /path/to/dump2.aof
cat /path/to/dump2.aof | /redis/src/redis-cli -p 6379 --pipe

step3 : get the final rdb from that redis

rdt -b redis://127.0.0.1:6379 -o /path/to/dump.rdb

It woks well ! Appreciate it !