There is a reasonable simple way to move data between Redis servers: Simply temporarily configure the new server as a replica of the old server.
To do this:
- Make sure the new Redis server can access the old server. If they are on different networks, a simple SSH tunnel will do.
- Connect to the new server using
redis-cli
. - Tail the log of the redis server (found in
/var/logs/redis
) in another terminal. - Make sure the server is currently master and not already a replica (check
INFO replication
) - Enable replication with
REPLICAOF <host> <port>
(on older Redis versions this is calledSLAVEOF
). - Redis will then drop all current data and fetch everything from the master.
- Check the log. It will tell you if replication works and when it is done. It should usually only take a few seconds.
- Disable replication with
REPLICAOF no one
.
This even works if the new server is itself master to other replicas.
Posted by Tobias Kraze to makandra dev (2020-06-25 14:48)