DBAtlas · Database operations atlas

Repair Redis that will not start because of a corrupt AOF (redis-check-aof, redis-check-rdb)

RedisPersistence

Command

# With Redis stopped, copy the files first:
cp -a /var/lib/redis/appendonlydir /var/lib/redis/appendonlydir.bak
# Check (7.0+ multi-part AOF: pass the manifest file):
redis-check-aof /var/lib/redis/appendonlydir/appendonly.aof.manifest
# Repair by truncating everything after the first corrupt point (asks for confirmation):
redis-check-aof --fix /var/lib/redis/appendonlydir/appendonly.aof.manifest
# Verify the RDB file:
redis-check-rdb /var/lib/redis/dump.rdb

What it does

Validates the AOF files (base + incr + manifest) and the RDB file; truncates the incomplete or corrupt tail of the AOF so Redis can start again.

When to use it

When Redis fails to start with 'Bad file format reading the append only file' or 'Unexpected EOF' after a power cut, a full disk or a sudden shutdown.

Caution

--fix deletes everything from the first corrupt point to the end of the file; if the corruption is in the middle of the file, all later writes are lost. Check how many bytes will be truncated in the output (ok_up_to, diff) before confirming. An incomplete last command (e.g. a large HSET) is dropped entirely. Always take a copy first.

Open in DBAtlas →

Related