Redis Data Migration

Redis Migration

Possible use cases

  • Copying Database in same redis cluster

    • Easily achieved riot-redis opensource tool.

  • Copying database between two clusters of same vpc

    • We can use riot-redis tool to copy given db between two clusters of same vpc

  • Copying database between two clusters of different vpc

    • First take a snapshot of the cluster

    • Restore it with the vpc configuration that you want the data to be copied

    • Now use riot-redis tool to copy between two clusters of same vpc

  • Also read about SWAPDB, if you want to swap dbs of the cluster.

Install riot-redis

  • Launch an EC2 ubuntu instance which has access to the redis cluster

  • Install java, since riot-redis needs it.

sudo apt update
sudo apt install default-jre
  • Download riot-redis source from this link. Unzip and copy to the desired location.

  • Now launch bin/riot-redis

Live mode

  • You need keyspace-notifications enabled for live mode. Ref: Enable Keyspace-notifications

  • To replicate specific db in live mode, run below command

bin/riot-redis -h <src host> -p <src port> --db <src db index> replicate -h <dest port> -p <dest port> --db <dest db index> --mode live

Normal Mode

  • To replicate specific db without applying live changes

bin/riot-redis -h <src host> -p <src port> --db <src db index> replicate -h <dest port> -p <dest port> --db <dest db index>

References

Last updated