These are the steps I took to create local backup of a Heroku Redis instance, but this should be valid for other providers like RedisToGo and RedisCloud.
On the machine where you'd like to make the backup, jump to the redis CLI:
redis-cli
Password?
If your master Redis DB (the one you want to replicate) has a password:
config set masterauth <password>
Start replication
Run the following to begin replication:
SLAVEOF <host> <port>
To check the replication is underway run:
INFO replication
And you should see something like this:
# Replication
role:slave
master_host:some-host.compute-1.amazonaws.com
master_port:6519
master_link_status:up
master_last_io_seconds_ago:3
master_sync_in_progress:0
slave_repl_offset:35492914
slave_priority:100
slave_read_only:1
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
Note the master_link_status
should be up
.
Checking sync progress
When the sync is complete, the INFO replication
should show:
master_sync_in_progress:0
To sense check the dataset has been synced you could compare the size of the database:
DBSIZE
Saving a data dump to disk
Given the number of keys in the follower & master DB match, then save the DB to disk:
BGSAVE
CONFIG GET dir
And you should find the dump.rdb
listed by the config command.
Halting replication
Finally, you can stop replication with:
SLAVEOF NO ONE
Reference: Redis replication guide