sripathikrishnan / redis-rdb-tools

Parse Redis dump.rdb files, Analyze Memory, and Export Data to JSON
https://rdbtools.com
MIT License
5.07k stars 739 forks source link

Restoring a protocol snapshot without TTL #166

Closed Sekenre closed 4 years ago

Sekenre commented 4 years ago

I've added an option to the ProtocolCallback which skips setting the TTL on a key, even if it had an expiry set in the original .rdb file.

The reason for this is to copy a snapshot of a production redis instance where many keys are set to expire into a test redis instance where the keys can be safely examined.

Example usage, copying from a dump of a production database to a private redis running in Docker:

 ~/Projects/redis-rdb-tools $ rdb -c snapshot prod2.rdb | redis-cli -h 172.17.0.2 --pipe
oranagra commented 4 years ago

@Sekenre thanks for that patch, seems useful. The only thing i'm not sure about is the interface, i think i would rather add an optional argument such as --omit-expire rather than a new command. another idea that can be useful is to offset all expire times, so something like --amend-expire=30000 (in seconds). would you like to try have a go at that?

Sekenre commented 4 years ago

I will write a proper test case shortly.

oranagra commented 4 years ago

@Sekenre thanks a lot. all looks good. one last petty request, if you don't mind squashing this into one commit? Or alternatively i can squash when meting (and write a new commit comment)

oranagra commented 4 years ago

@Sekenre thanks a lot for the contribution and adding all the adjustments i asked for.

oranagra commented 4 years ago

@Sekenre FYI, just released 0.1.15 with your changes. thanks again.