Redis- Backup and Restore

Backup and Restore in Redis: Backup of database play an important role when due to some issue, you loose your data either it can be DB crash, VM crash or some human error.

If  you have a backup available you can easily restore your database and bring the application live. `

In PostgreSQL world, there are various way to take backup ..like logical or physical, So today we gone cover we will take the backup in Redis and Restore it backup in case of any issue.


Since in Redis, every things is stored in Key format. so there are certain key which you want to take backups and restore in case of any issue.

  • Create a sample key.
  • Dump the key.
  • Delete the key.
  • Restore the key.

In Redis, dump command will convert the key in special serialize format and we can use that serialize.

Commands:

    Set key <value>

    Get key 

    Dump key

    Del Key 

    Restore Key <key-expiry> <serialize value>




When you have already exist s and you want to replace the value.
     
    Restore Key <key-expiry> <serialize value> <replace>



In above screenshot, we are trying the replace the dump of another key to previous key to overwrite the value.