Latest web development tutorials

Redis data backup and recovery

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

grammar

redis Save command basic syntax is as follows:

redis 127.0.0.1:6379> SAVE 

Examples

redis 127.0.0.1:6379> SAVE 
OK

This command creates dump.rdb file redis installation directory.


Data recovery

If you need to recover data, only the backup files (dump.rdb) moved to redis installation directory and start the service. Get redis directory can use theCONFIG command as follows:
 
redis 127.0.0.1:6379> CONFIG GET dir
1) "dir"
2) "/usr/local/redis/bin"

The above commandCONFIG GET dir output redis installation directory is / usr / local / redis / bin .


Bgsave

Redis create backup files can also use the commandBGSAVE, the command in the background.

Examples

127.0.0.1:6379> BGSAVE

Background saving started