There is a possibility that redis-server might crash or memory problems and the user can lose the data that he is working. To overcome this issue Redis Developer added BGSAVE option or can be said as a feature which can be used for taking backup in the background. Yes, BGSAVE means background save. Using BGSAVE is very easy.

 

There is another command SAVE which also does the same thing as BGSAVE. BGSAVE and SAVE both commands save the progress in dump.rdb on the disk, but the working mechanism behind both are totally different. We will explain you the difference between both commands.

 

The difference is only the database saving mechanism in both and, the outcome of command is the same. When we use BGSAVE it will trigger the save progress to database i.e dump. rdb function to the Redis Server and then it is checked if any redis instance is running and working with the database like any undergoing query functions. If it’s idle then saving to RDB starts backing up in dump. rdb whereas,  when SAVE command is executed the next moment it starts backing up closing all processings that are going on in other instance and this might lead to data loss for other opened instances. SAVE doesn’t respect any operation ongoing it gets its work done immediately after its triggered.

 

If you are looking for Redis Installation guide then head over to this link.

 

Requirements

redis installed and redis-server active

 

Procedure

1. Run Redis CLI

redis-cli

 

2. To start background save run

bgsave

 

3. Now your progress will be saved in memory in the background.

 

4. If you want to use save command then run save instead of bgsave. Difference we have explained before procedure.

 

Hjälpte svaret dig? 0 användare blev hjälpta av detta svar (0 Antal röster)