Copying Redis Database from one server to another

20 / Feb / 2013 by raj 0 comments

In my recent project, I needed to copy the redis database from one server to another. Although redis provides SAVE and BGSAVE commands, I found another cool way of doing it.

Log in to the new server and execute the following command in terminal:

[bash]
redis-cli slaveof IP-ADDRESS-OF-OLD-SERVER 6379
[/bash]

The above command starts replicating the data stored in redis database of old server to redis database of new server. Here, 6379 is the default port which redis uses. Once the replication is done, we issue the following command :

[bash]
redis-cli slaveof no one
[/bash]

Now we have the entire redis database copied to the new server.

Raj Gupta
raj.gupta@intelligrape.com
@rajdgreat007

FOUND THIS USEFUL? SHARE IT

Leave a Reply

Your email address will not be published. Required fields are marked *