BGREWRITEAOF
BGREWRITEAOF
- Group
- Server
- Complexity
- O(1) to start; the rewrite itself is O(N) in the number of keys
- Arity
- 1 (exactly, counting the command name)
- Flags
- admin
- HotKV Cloud
- All plans
- On-Premise
- no license needed
The append-only file (AOF) grows with every write. BGREWRITEAOF starts
rewriting it in the background as the shortest sequence of commands that
recreates the current data set, then replaces the old file. Clients keep
being served, and writes made during the rewrite are kept.
The server also rewrites the AOF on its own when it has grown by
auto-aof-rewrite-percentage since the last rewrite and is larger than
auto-aof-rewrite-min-size. Check progress with aof_rewrite_in_progress
and the result with aof_last_bgrewrite_status in INFO
persistence.
Return value
Section titled “Return value”| Case | Reply (RESP2 and RESP3) |
|---|---|
| Rewrite started | Simple string Background append only file rewriting started |
| A rewrite is already running | Error ERR Background append only file rewriting already in progress |
Examples
Section titled “Examples”127.0.0.1:6379> BGREWRITEAOFBackground append only file rewriting startedIn HotKV Cloud, the CLI tab of the panel does not run BGREWRITEAOF. Send
it from your own client connection.
Compatibility
Section titled “Compatibility”Same replies as Redis 7 and Valkey 8. HotKV’s AOF file format is its own; see persistence.
See also
Section titled “See also”BGSAVE, WAITAOF,
CONFIG SET (appendonly, appendfsync)
Was this page helpful?
Thanks for the feedback.