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 dump.rdb
file. How can I do that?

- 7,093
- 4
- 33
- 65

- 2,134
- 3
- 19
- 24
9 Answers
For databases where the appendonly
flag is set to no
, you can do the following:
- Stop Redis (because Redis overwrites the current rdb file when it exits).
- 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 thedbfilename
config option. - Start Redis.
If, on the other hand, you need to restore an rdb file to the appendonly database, you should do something along the lines of:
- Stop Redis (because Redis overwrites the current rdb file when it exits).
- 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 thedbfilename
config option. - Change the Redis config
appendonly
flag tono
(otherwise Redis will ignore your rdb file when it starts). - Start Redis.
- Run
redis-cli BGREWRITEAOF
to create a new appendonly file. - Restore the Redis config
appendonly
flag toyes
.
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 appendonly mode is enabled Redis will load the data from the
# >> log file at startup ignoring the dump.rdb file.

- 5,297
- 5
- 39
- 59

- 8,689
- 4
- 44
- 43
-
8and dont forget the `chown redis:redis dump.rdb` and `chmod 644 dump.rdb` after copying the files – RickyA Jun 17 '15 at 16:16
-
Thanks! For me it was the `appendonly` flag set to `yes` that was causing the RDB file to be ignored and rewritten. – rubik Dec 30 '19 at 15:33
-
Thanks! After that you might still see empty result for "KEYS" in case of a large rdb file. Give it a few minutes. – ozma Jun 02 '22 at 09:18
There is nothing specific to do. Just install the redis server on the new machine, and edit the configuration file. You just need to change the following parameters to point to the location of the dump file you have just copied.
# The filename where to dump the DB
dbfilename mydump.rdb
# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
#
# Also the Append Only File will be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
dir /data/mydirectory/
Finally, the redis server can be started in the normal way.

- 70,911
- 12
- 189
- 154
-
8My dump was rewrited (100Mb -> 0Mb) after I edited configuration file and restarted redis-server. Where is my mistake? – Evgenii Jul 30 '14 at 10:16
-
19@Evgeny I think maybe you made the same mistake I did and tried to restart the server. Make sure to STOP redis first, copy the dump.rdb file to the right directory then START the server. If you restart, redis will write to the file, overwriting your copied dump, and then imports the file it wrote to instead of the file you moved as the backup. – akahunahi May 25 '15 at 22:51
-
We are successfully able to migrate db only when we first stopped redis server. – Pramod S. Nikam Jun 22 '16 at 10:24
-
I think @Ligemer comment is pretty important! Would be nice to have it in the answer (which is spot on beside that little thing) – mikey Nov 13 '18 at 01:23
-
4This is an extremely poor and dangerous answer without mentioning anything about the `appendonly` setting in the `redis.conf` file. Anytime you want to restore a redis `dump.rdb` files, you have to ensure that `appendonly` is set to `no` inside `redis.conf`. Otherwise, it will completely empty out your `dump.rdb` file and start fresh from point 0 as if nothing happened. Before careful folks! – Paul D. Apr 30 '21 at 10:20
Assuming that you run Redis 2.6 or higher, your Redis snapshot filename is dump.rdb
, and it exists in the directory /home/user/dbs
, the following command would do the trick:
redis-server --dbfilename dump.rdb --dir /home/user/dbs
Relevant section from the official documentation: Passing arguments via the command line

- 431
- 5
- 5
Or you can:
- Stop your redis server / instance, eg.,
service redis6379 stop
- Copy the dump.rdb file to the right location, eg.,
cp /path/to/dump-6379.rdb /var/lib/redis/dump-6379.rdb
. Give it the right permissions (user:group should be redis:redis and mode 644) - Start your redis server / instance, eg.,
service redis6379 start
It is important that you stop the redis server before copying the file to the right location, because Redis saves a snapshot before terminating, so it will replace your file.
Besides, you might want to back up the existing dump.rdb file first.

- 521
- 1
- 6
- 10
I would like to add here a tiny detail that did not get mentioned and I will not use config file but instead specify everything in the command line.
When both mydump.rdb and appendonly.aof files are specified when starting redis-server
, it will be the appendonly.aof
file that wins such that the data from appendonly.aof gets loaded. For example:
redis-server --dbfilename mydump001.rdb --dir /data --appendonly yes
The above start invocation will use the /dir
location to find the presence of mydump001.rdb
or appendonly.aof
files. In this case, redis-server
will load the contents from appendonly.aof
. If appendonly.aof
does not exists, it will create an empty /data/appendonly.aof
and the redis-server will be empty.
If you want to load a specific dump file, you can do:
redis-server --dbfilename mydump001.rdb --dir /data
I added this answer coz it is not obvious which is which. In the presence of 2 backup files, and this is often not mentioned.

- 3,794
- 2
- 36
- 38
start redis on your second server, like so:
$ > redis-server /path/to/my/redis/configuration/file/redis.conf
when redis starts, it will find your rdb file because it will look for the name and file path in the configuration file (redis.conf) that you supply when start the redis server, as above.
to supply the file name and path, just edit two lines in the redis.conf file template (supplied in the root directory of the redis source. Save your revised version as redis.conf in the directory location that you supplied upon starting the server.
You will find the settings you need in the redis.conf template in the source top-level directory, at lines 127 and 137 (redis version 2.6.9).
# The filename where to dump the DB
dbfilename dump.rdb
# The working directory
dir ./
as you can see, defaults are provided for both settings
so just change the first of these two lines (127) to identify your rdb file and in the second (137) substitute the default "./" for the actual file path for your snapshot rdb file; save the redis.conf with your changes, and start redis passing in this new conf file.

- 69,080
- 24
- 165
- 199
This solution work with redis-cluster, but should work too with redis.
Install this dependencie https://github.com/sripathikrishnan/redis-rdb-tools
pip install rdbtools python-lzf
after that execute this
rdb -c protocol /path/to/dump.rdb | redis-cli -h host -p port --pipe
If this is a cluster, the port should the master`s port.

- 4,825
- 7
- 38
- 84
Install https://github.com/leonchen83/redis-rdb-cli
rmt -s ./your-dump.rdb -m redis://host:port -r

- 71
- 5
try set appendonly no. In My case, *.aof file was empty(0 byte), must set appendonly=no then make it load the dump.rdb

- 367
- 1
- 3
- 7