Skip to content

Commit b4eac7e

Browse files
Improve RDB to AOF conversion docs (#2521)
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.
1 parent f996053 commit b4eac7e

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

docs/management/persistence.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -259,26 +259,30 @@ and starts appending new data into the new file.
259259

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

262-
There is a different procedure to do this in version 2.0 and later versions, as you
263-
can guess it's simpler since Redis 2.2 and does not require a restart at all.
262+
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.
263+
264+
**IMPORTANT:** not following this procedure (e.g. just changing the config and restarting the server) can result in data loss!
264265

265266
**Redis >= 2.2**
266267

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

275-
The first CONFIG command enables the Append Only File persistence.
273+
Switch to AOF on live database:
276274

277-
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.
275+
* Enable AOF: `redis-cli config set appendonly yes`
276+
* Optionally disable RDB: `redis-cli config set save ""`
277+
* Make sure writes are appended to the append only file correctly.
278+
* **IMPORTANT:** Update your `redis.conf` (potentially through `CONFIG REWRITE`) and ensure that it matches the configuration above.
279+
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.
280+
281+
Next time you restart the server:
278282

279-
**IMPORTANT:** remember to edit your redis.conf to turn on the AOF, otherwise
280-
when you restart the server the configuration changes will be lost and the
281-
server will start again with the old configuration.
283+
* Before restarting the server, wait for AOF rewrite to finish persisting the data.
284+
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`.
285+
* After restarting the server, check that your database contains the same number of keys it contained previously.
282286

283287
**Redis 2.0**
284288

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

295299
## Interactions between AOF and RDB persistence
296300

297-
298301
Redis >= 2.4 makes sure to avoid triggering an AOF rewrite when an RDB
299302
snapshotting operation is already in progress, or allowing a `BGSAVE` while the
300303
AOF rewrite is in progress. This prevents two Redis background processes

wordlist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ codenamed
183183
Collina's
184184
commandstats
185185
commnad
186+
CONFIG
186187
Config
187188
config
188189
config-file

0 commit comments

Comments
 (0)