Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Redis Data Backup and Recovery

Redis Data Backup and Recovery

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

Syntax

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



redis 127.0.0.1:6379> SAVE 

Example



redis 127.0.0.1:6379> SAVE 

OK

This command creates the dump.rdb file in the redis installation directory.


Restore Data

If you need to restore data, simply move the backup file (dump.rdb) to the redis installation directory and start the service. To get the redis directory, you can use

CONFIG

the command, as shown below:

 

redis 127.0.0.1:6379> CONFIG GET dir

1) "dir"

2) "/usr/local/redis/bin"



The above command CONFIG GET dir outputs the redis installation directory as /usr/local/redis/bin.


Bgsave

You can also use the command to create a redis backup file BGSAVE, which runs in the background.

Example



127.0.0.1:6379> BGSAVE



Background saving started