How to recover redis data from snapshot(rdb file) copied from another machine?

前端 未结 7 1680

I transferred my redis snapshot (dump.rdb file) using scp to a remote server. I need to run a redis server on this remote and recover the data from the

相关标签:
7条回答
  • 2021-01-30 04:41

    For databases where the appendonly flag is set to no, you can do the following:

    1. Stop redis (because redis overwrites the current rdb file when it exits).
    2. Copy you backup rdb file to the redis working directory (this is the dir option in your redis config). Also make sure your backup filename matches the dbfilename config option.
    3. Start redis.

    If, on the other hand, you need to restore a rdb file to an append only database, you should do something along the lines of:

    1. Stop redis (because redis overwrites the current rdb file when it exits).
    2. Copy your backup rdb file to the redis working directory (this is the dir option in your redis config). Also make sure your backup filename matches the dbfilename config option.
    3. Change the redis config appendonly flag to no (otherwise redis will ignore your rdb file when it starts).
    4. Start redis.
    5. Run redis-cli BGREWRITEAOF to create a new appendonly file.
    6. Restore redis config appendonly flag to yes.

    Specifically, this is the relevant bit of documentation from the redis config file comments:

    # Note that you can have both the async dumps and the append only file if you                                                     
    # like (you have to comment the "save" statements above to disable the dumps).                                                    
    # >> Still if append only mode is enabled Redis will load the data from the                                                          
    # >> log file at startup ignoring the dump.rdb file. 
    
    0 讨论(0)
提交回复
热议问题