Skip to content

Commit

Permalink
Improve RDB to AOF conversion docs (#2521)
Browse files Browse the repository at this point in the history
Add warning about RDB to AOF conversion and some other improvements to that documentation section.

Removed section for Redis < 2.2.

Related to redis/redis#12484.
  • Loading branch information
threema-danilo committed Dec 19, 2023
1 parent f996053 commit b4eac7e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
29 changes: 16 additions & 13 deletions docs/management/persistence.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,26 +259,30 @@ and starts appending new data into the new file.

### How I can switch to AOF, if I'm currently using dump.rdb snapshots?

There is a different procedure to do this in version 2.0 and later versions, as you
can guess it's simpler since Redis 2.2 and does not require a restart at all.
If you want to enable AOF in a server that is currently using RDB snapshots, you need to convert the data by enabling AOF via CONFIG command on the live server first.

**IMPORTANT:** not following this procedure (e.g. just changing the config and restarting the server) can result in data loss!

**Redis >= 2.2**

Preparations:

* Make a backup of your latest dump.rdb file.
* Transfer this backup to a safe place.
* Issue the following two commands:
* `redis-cli config set appendonly yes`
* `redis-cli config set save ""`
* Make sure your database contains the same number of keys it contained.
* Make sure writes are appended to the append only file correctly.

The first CONFIG command enables the Append Only File persistence.
Switch to AOF on live database:

The second CONFIG command is used to turn off snapshotting persistence. This is optional, if you wish you can take both the persistence methods enabled.
* Enable AOF: `redis-cli config set appendonly yes`
* Optionally disable RDB: `redis-cli config set save ""`
* Make sure writes are appended to the append only file correctly.
* **IMPORTANT:** Update your `redis.conf` (potentially through `CONFIG REWRITE`) and ensure that it matches the configuration above.
If you forget this step, when you restart the server, the configuration changes will be lost and the server will start again with the old configuration, resulting in a loss of your data.

Next time you restart the server:

**IMPORTANT:** remember to edit your redis.conf to turn on the AOF, otherwise
when you restart the server the configuration changes will be lost and the
server will start again with the old configuration.
* Before restarting the server, wait for AOF rewrite to finish persisting the data.
You can do that by watching `INFO persistence`, waiting for `aof_rewrite_in_progress` and `aof_rewrite_scheduled` to be `0`, and validating that `aof_last_bgrewrite_status` is `ok`.
* After restarting the server, check that your database contains the same number of keys it contained previously.

**Redis 2.0**

Expand All @@ -294,7 +298,6 @@ server will start again with the old configuration.

## Interactions between AOF and RDB persistence


Redis >= 2.4 makes sure to avoid triggering an AOF rewrite when an RDB
snapshotting operation is already in progress, or allowing a `BGSAVE` while the
AOF rewrite is in progress. This prevents two Redis background processes
Expand Down
1 change: 1 addition & 0 deletions wordlist
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ codenamed
Collina's
commandstats
commnad
CONFIG
Config
config
config-file
Expand Down

0 comments on commit b4eac7e

Please sign in to comment.