Skip to content

Feature Request: rmt sync from cluster to single redis #33

@sgohl

Description

@sgohl

Hi,

I am looking for the best way to export a full redis-cluster to a single redis instance.

I know: rmt is able to sync a (given) cluster node to a single redis.
I also know that rmt is able to fetch the list of CLUSTER NODES and get only the masters with their IPs and Ports, because it's presumably what -m does, otherwise it would not work without the cluster.conf

AFAIK, there is no good/short/clean way to get the cluster masters into a bash list.

look how ugly it would be, to sync all keys from all cluster masters into a single redis:

HOSTS=$(redis-cli -a ${REDIS_DEST_PASS} -h ${REDIS_DEST} -p ${REDIS_DEST_PORT} -c cluster nodes | grep master | awk '{ print $2 }' | cut -f1 -d'@')

for HOST in $HOSTS
do
  rmt -s redis://default:${REDIS_DEST_PASS}@${HOST} -m redis://${REDIS_STAGE} -r -d 0
done

This works, but I'm curious if you could

  1. provide a command to output the list of cluster masters in a cleaner approach,
    and possibly,
  2. implement this loop (i mean, the complete sync/migration) with rmt , like this:
rmt -s redis://default:password@AnyClusterMember:Port -m redis://Target-Single-Redis:Port -r

I think, rmt should safely be able to always check if the source is a cluster or not and proceed to work as "expected"
where in case source is a single, proceed as usual.
in case its a cluster, fetch the masters, and loop over them repeating the usual bgsave and dump to target. This should seemlessly work, even if the target is also a cluster

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions