BGSAVE
BGSAVE [SCHEDULE]
- Group
- Server
- Complexity
- O(1) to start; the save itself is O(N) in the number of keys
- Arity
- -1 (at least 1 words, counting the command name)
- Flags
- admin
- HotKV Cloud
- All plans
- On-Premise
- no license needed
BGSAVE starts writing a point-in-time snapshot of every database to the
snapshot file (dbfilename in dir) and replies right away. Clients keep
being served while the snapshot is written. Check progress with
rdb_bgsave_in_progress and the result with rdb_last_bgsave_status in
INFO persistence, or wait for
LASTSAVE to change.
The server also starts background saves on its own according to the save
setting.
Options
Section titled “Options”| Option | Effect |
|---|---|
SCHEDULE |
Accepted for compatibility. In Redis it delays the save while an AOF rewrite runs; in HotKV a rewrite does not stop a background save, so it starts at once either way. |
Return value
Section titled “Return value”| Case | Reply (RESP2 and RESP3) |
|---|---|
| Save started | Simple string Background saving started |
| A background save is already running | Error ERR Background save already in progress |
| Any other argument | Error ERR syntax error |
Examples
Section titled “Examples”127.0.0.1:6379> BGSAVEBackground saving started127.0.0.1:6379> BGSAVE(error) ERR Background save already in progressIn HotKV Cloud, the CLI tab of the panel does not run BGSAVE. Send it from
your own client connection.
Compatibility
Section titled “Compatibility”Same replies as Redis 7 and Valkey 8, except that SCHEDULE never delays the
save.
See also
Section titled “See also”Was this page helpful?
Thanks for the feedback.