Asynchronously saves the database(s) to disk.
BGSAVE
[SCHEDULE
]
Save the DB in background.
Normally the OK code is immediately returned. Valkey forks, the parent continues to serve the clients, the child saves the DB on disk then exits.
An error is returned if there is already a background save running or if there is another non-background-save process running, specifically an in-progress AOF rewrite.
If BGSAVE SCHEDULE
is used, the command will immediately
return OK
when an AOF rewrite is in progress and schedule
the background save to run at the next opportunity.
If BGSAVE CANCEL
is used, it will immediately terminate
any in-progress RDB save or replication full sync process. In case a
background save is scheduled to run (e.g. using
BGSAVE SCHEDULE
command) the scheduled execution will be
cancelled as well.
A client may be able to check if the operation succeeded using the
LASTSAVE
command.
Please refer to the persistence documentation for detailed information.
One of the following:
Simple string
reply: Background saving started
.
Simple string
reply: Background saving scheduled
.
O(1)
@admin @dangerous @slow
SCHEDULE
option.ACL, ACL CAT, ACL DELUSER, ACL DRYRUN, ACL GENPASS, ACL GETUSER, ACL HELP, ACL LIST, ACL LOAD, ACL LOG, ACL SAVE, ACL SETUSER, ACL USERS, ACL WHOAMI, BGREWRITEAOF, COMMAND, COMMAND COUNT, COMMAND DOCS, COMMAND GETKEYS, COMMAND GETKEYSANDFLAGS, COMMAND HELP, COMMAND INFO, COMMAND LIST, CONFIG, CONFIG GET, CONFIG HELP, CONFIG RESETSTAT, CONFIG REWRITE, CONFIG SET, DBSIZE, DEBUG, FAILOVER, FLUSHALL, FLUSHDB, INFO, LASTSAVE, LATENCY, LATENCY DOCTOR, LATENCY GRAPH, LATENCY HELP, LATENCY HISTOGRAM, LATENCY HISTORY, LATENCY LATEST, LATENCY RESET, LOLWUT, MEMORY, MEMORY DOCTOR, MEMORY HELP, MEMORY MALLOC-STATS, MEMORY PURGE, MEMORY STATS, MEMORY USAGE, MODULE, MODULE HELP, MODULE LIST, MODULE LOAD, MODULE LOADEX, MODULE UNLOAD, MONITOR, PSYNC, REPLCONF, REPLICAOF, RESTORE-ASKING, ROLE, SAVE, SHUTDOWN, SLOWLOG, SLOWLOG GET, SLOWLOG HELP, SLOWLOG LEN, SLOWLOG RESET, SWAPDB, SYNC, TIME.