Redis Managed Database

August 24, 2019 210 views
Redis Databases

Hello Everyone

I’m planning to migrate to Redis managed database once it is available in my current datacenter.

For the people whom already tried it, can you share your experience so far (I know it’s less than a week but let me know what do you think, did you move your production Redis or waiting? did you noticed any limitation or issues?)

Also, can I use Redis managed database to host my queue? I already use Redis queues in my own Redis and not sure if it’s supported in the managed Redis (nothing mentioned in the documentation)

1 Answer

Hello Everyone

I just finished the migration from Redis single instance to DO Redis Managed Database, everything went smooooooth :)

In case someone interested to copy his Redis data to another Redis server (aka DO Redis managed database) the below script will help you to do that

#!/bin/bash

# Credit goes to Elliot Chance https://medium.com/@elliotchance/migrating-data-between-redis-servers-without-downtime-429e4c8048e6

# Small change is done by AhmadT (ahmadt a.t. gmail.com)


if [ $# -eq 0 ]; then
  echo "select a db"
  exit 1
fi

export DBnumber="$1"

echo "DB ${DBnumber}"

export OLD="redis-cli -n ${DBnumber}"
export NEW="redis-cli -n ${DBnumber} -p MYPORT -a PASSWORD"


for KEY in $($OLD --scan); do
    $OLD --raw DUMP "$KEY" | head -c-1 > /tmp/dump
    TTL=$($OLD --raw TTL "$KEY")
    case $TTL in
        -2)
            $NEW DEL "$KEY"
            ;;
        -1)
            $NEW DEL "$KEY"
            cat /tmp/dump | $NEW -x RESTORE "$KEY" 0
            ;;
        *)
            $NEW DEL "$KEY"
            let TTLEX="$TTL*1000"
            cat /tmp/dump | $NEW -x RESTORE "$KEY" "$TTLEX"
            ;;
    esac
    echo "$KEY (TTL = $TTL)"
done

Have another answer? Share your knowledge.