Redis db migration

A list of commands to do a quick migration for redis.

redis instance - source side

# persist current db data to disk
$ redis-cli bgsave
# stop redis server
$ /etc/init.d/redis-server stop
# copy/scp the dump.rdb and dump.rdb_save to a location
$ copy/scp /var/lib/redis/dump.* <new-location>
# [optional] also copy redis custom config if any
$ copy/scp /etc/redis/redis.config <new-location>

redis instance - destination side

# stop redis server !!! important
$ redis-server stop
# copy/scp the dump.* files to /var/lib/redis
$ copy/scp dump.* /var/lib/redis
# copy/scp the redis.config to /etc/redis/
$ copy/scp redis.config /etc/redis/
# start redis-server
$ redis-server start
# check db info to ensure migration is successful
$ redis-cli

See also an article redis backup and restore