Redis › Persistence (RDB/AOF)

What is RDB persistence in Redis, and how does it work?

Beginner

Answer

RDB persistence periodically saves a complete point in time snapshot of your entire dataset to a single compact file on disk, based on configured save rules, such as saving automatically if a certain number of changes have been made within a given time period, giving you a compact backup you can use to restore your data if Redis restarts.
SAVE -- creates an RDB snapshot immediately
BGSAVE -- creates a snapshot in the background
CONFIG SET save '900 1'
Real-world example A company configures Redis to automatically save an RDB snapshot every fifteen minutes if at least one key has changed, giving them a reasonably recent backup without needing to save constantly and impact performance.

Common follow-ups: What is the difference between SAVE and BGSAVE?;How much data could potentially be lost if Redis crashes right before a scheduled RDB save?