Search code examples
redisrecovery

Can I restore a Redis key when overwrite it by RENAME command


I made a horrible mistake by using the command RENAME key1 key2. The data in key2 was completely wiped out. Is there anyway to restore the data that was stored in key2?


Solution

  • Unless you don't have a dump'ed value of key2, key2's data is gone. If you have the dumped value, then you can restore it by RESTORE command.

    RESTORE key2 0 "<dumped value.>"
    

    Check out the following links>