Fork this blog on GitHub Fork this blog on GitHub

How to Restore an Append-Only Redis Master With a dump.rdb

How to Restore an Append-Only Redis Master With a dump.rdb

Follow these steps to restore a dump.rdb into a Redis master that is running in append-only mode. For some reason this is not documented very well. The master in this case had an issue and was unable to write to disk. I was able to get the dump.rdb from a slave.

Step 1 - Obtain a dump.rdb & check the size for later comparison

redis-cli -p $PORT save
redis-cli -p $PORT dbsize

Step 2 - Stop the master & all slaves

/etc/init.d/redis stop

Step 3 - Update the Redis working directory

Remove any old dump.rdb files and any old appendonly.aof files. Place the dump.rdb that is to be restored in this directory.

Step 4 - Update the master conf file

Turn off appendonly or else Redis will create a new zero-size appendonly.aof and a new dump.rdb.
daemonize no
loglevel verbose
logfile stdout
appendonly no       #Important part

Step 5 - Start Redis in the foreground and watch for errors

redis-server /etc/redis/$REDIS_CONF

Step 6 - Connect to Redis in a separate console

DBSIZE should return the same size as before. The BGREWRITEAOF command generates a new aof file.
redis-cli -p $PORT

Step 7 - Put everything back the way it was

Once the aof file has been completely written, update the redis.conf file options back to appendonly=yes and daemonize=yes.

I hope this was useful!

Next entry

Previous entry

Similar entries


No comments yet.

Post your comment


Pingbacks are closed.