Read more

Migrate data between Redis servers

Tobias Kraze
June 25, 2020Software engineer at makandra GmbH

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.

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

To do this:

  1. Make sure the new Redis server can access the old server. If they are on different networks, a simple SSH tunnel will do.
  2. Connect to the new server using redis-cli.
  3. Tail the log of the redis server (found in /var/logs/redis) in another terminal.
  4. Make sure the server is currently master and not already a replica (check INFO replication)
  5. Enable replication with REPLICAOF <host> <port> (on older Redis versions this is called SLAVEOF).
  6. Redis will then drop all current data and fetch everything from the master.
  7. Check the log. It will tell you if replication works and when it is done. It should usually only take a few seconds.
  8. 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 16:48)