aof

.aofAOF (Append-Only File) Format

Redis Labs · 2009

Developer
Redis Labs
Category
Database
MIME Type
application/x-aof
First Released
2009
Open Format
Yes
File Signature
The file starts with the Redis protocol commands, not a fixed magic number. For example, it might begin with `*3 $3 SET $5 mykey $7 myvalue` for a simple SET command.
At a Glance
.aof
AOF (Append-Only File) Format

The AOF format logs every write operation to a Redis database, ensuring data durability by allowing reconstruction of the dataset.

Reviewed on June 22, 2026
Compression
Varies (Commands are plain text, but can be compressed on disk if Redis is configured)
Transparency
Yes (Plain text commands)
Editability
Low (Manual editing can corrupt data; intended for Redis replay)
Best for
Data durability

Key Features

  • Records every write operation for high durability.
  • Allows for data reconstruction by replaying commands.
  • Supports different fsync policies for trade-offs.
  • Can be rewritten to optimize file size.

Best For

  • Users prioritizing data durability over disk space.
  • Applications requiring minimal data loss.
  • Maintaining a complete history of database modifications.

Less Ideal For

  • Situations where disk space is severely limited.
  • Very high-write environments where AOF growth is a concern.
  • When only occasional data backups are needed (RDB might be sufficient).

Common Use Cases

  • Ensuring data persistence for critical Redis databases.
  • Providing a highly durable storage mechanism for in-memory data.
  • Reconstructing database state after server restarts or crashes.
  • Auditing write operations performed on a Redis instance.

How to Open It

  1. Directly viewable as a text file in editors like `cat`, `less`, or Notepad++ to inspect commands.
  2. Replayed by a Redis server during startup if configured to load AOF.
  3. Can be processed by `redis-check-aof` for integrity checks.
  4. Use `redis-cli --pipe < aof_file.aof` for manual replay.

What is a .aof file?

The Append-Only File (AOF) format is a specialized file used by the Redis in-memory data structure store. Instead of storing a snapshot of the database, AOF records every write operation received by the server. This log of commands allows Redis to reconstruct the dataset accurately. While it can be larger than a snapshot, AOF typically offers better durability, ensuring fewer data losses in case of unexpected shutdowns. It's a core feature for ensuring data persistence in Redis deployments.

Programs That Open .aof Files

PlatformProgram
WindowsRedis ServerFreeOfficial
Notepad++Free
macOSRedis ServerFreeOfficial
TextEditFreeOfficial
LinuxRedis ServerFreeOfficial
GNU nanoFree

Common Problems with .aof Files

⚠️ AOF file grows very large over time.
Use `BGREWRITEAOF` command to rewrite the AOF file, which compacts it by removing redundant commands. Schedule this regularly if necessary.
⚠️ Data loss during unexpected shutdowns.
Ensure `appendfsync` is set to `always` (most durable but slowest) or `everysec` (good balance). Consider the trade-offs based on application requirements.

Frequently Asked Questions

What is the difference between AOF and RDB (Redis Database) persistence?

RDB creates point-in-time snapshots of the dataset, while AOF logs every write operation. AOF generally offers better durability as it records changes more frequently, reducing potential data loss.

Can I manually edit an AOF file?

While technically possible as it's a text file, it's strongly discouraged. Manual edits can easily corrupt the file and lead to data inconsistencies or complete loss when Redis tries to load it.

How does AOF rewriting work?

When `BGREWRITEAOF` is called, Redis forks a child process that builds a new, compacted AOF file containing only the commands necessary to reconstruct the current dataset, effectively removing obsolete commands.

Technical Details

AOF files are essentially a sequence of Redis commands (like SET, DEL, RPUSH) that, when replayed, rebuild the exact state of the database. Redis can use different AOF rewriting strategies (e.g., BGREWRITEAOF) to compact the file periodically, reducing its size by removing redundant commands. The file can be written in different modes, such as `always`, `everysec`, or `no`, affecting durability and performance trade-offs.

Did You Know?

The AOF persistence method in Redis was inspired by similar log-based persistence mechanisms in other database systems.
Redis offers both AOF and RDB persistence methods, and they can be used together for maximum data safety.

Security Information

AOF files contain a log of all write commands executed on a Redis instance. Treat them with the same security considerations as your database data. Ensure proper file permissions and access controls to prevent unauthorized viewing or modification.