Database backup, using the Save command, the DUMP.RDB will be generated in the Redis installation directory
For example: in my directory Redis/src/dump.rdb
Use the command config get dir to get the current Redis installation directory
For example:
127.0.0.1:6379> Config get dir
1) "Dir"
2) "/tsh/redis-3.0.0/src"
Use command Bgsave to perform backup operations in the background
For example:
127.0.0.1:6379> Bgsave
Background Saving started
To recover the data, simply put the Dump.rdb file in the Redis installation directory, start the service, and the data will be restored
After my test, did not execute the Save command, when manually closed Redis-server, the Dump.rdb file will be created automatically, and then open the service, the client query data is not lost
Redis The persistence of
Snapshotting (snapshot)
Modify the configuration file, the number of keys modified in the specified time is greater than the set value to execute save, parameter: Number of seconds, the number of keys modified
For example:
Save 20 1
Save 900 1
Save 300 10
Save 60 10000
The configuration file does not work because there are no parameters to the configuration file at the time of the reboot, for example:
Redis-server/tsh/redis-3.0.0/redis.conf
Append only file (aof mode)
Modify configuration file Redis.conf,appendonly Yes
Restart the service, must have the parameters of the configuration file
At this point in the SRC directory generated file appendonly.aof, this file records each step of the operation, the efficiency is slightly slower but more secure
[Redis] Redis Data backup recovery and persistence