Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Redis data backup and recovery


May 16, 2021 Redis


Table of contents


Redis data backup and recovery

The Redis SAVE command is used to create a backup of the current database.

Grammar

The basic syntax of the redis Save command is as follows:

redis 127.0.0.1:6379> SAVE 

Instance

redis 127.0.0.1:6379> SAVE 
OK

The command creates a dump.rdb file in the redis installation directory.


Recover the data

If you need to recover data, simply move the backup file (dump.rdb) to the redis installation directory and start the service. G etting the redis directory can use the CONFIG command, as follows:
 
redis 127.0.0.1:6379> CONFIG GET dir
1) "dir"
2) "/usr/local/redis/bin"

The redis installation directory for the above command CONFIG GET dir output is /usr/local/redis/bin.


Bgsave

Creating a redis backup file can also use the command BGSAVE, which executes in the background.

Instance

127.0.0.1:6379> BGSAVE

Background saving started