I want to take backup of a particular key in my redis which have multiple keys. My redis has many keys and I don't want to take full backup of my redis data. I have been going through http://redis.io/commands. There I found that there is a command dump by which I can take the dump of a specific key as follows:
redis> dump "myKey"
But is giving output in hexadecimal format in redis console only. Is it possible to store the data for a specific key in a file and later import it to that key?
In case you are trying to dump/restore a key from the command line (which is what I needed to do when I found this question), Redis has some non-obvious quirks. Please see this answer for a more detailed explanation.
The short answer is to dump/restore as follows:
bwood@mybox:~$ redis-cli --raw dump mykey | head -c-1 > myfile
bwood@mybox:~$ cat myfile | redis-cli -x restore mynewkey 0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With