4

I have a node.js app, using RedisToGo and running in Heroku. I would like to copy the Redis To Go database to localhost for testing.

When developing Ruby on Rails app, I can use heroku db:pull command. Is there any similiar command which I can use for node.js and Redis?

Thanks.

Victor Lam
  • 3,646
  • 8
  • 31
  • 43

3 Answers3

5

There was a guide available from the redistogo support knowledge base but it got deleted, I used the way back machine to grab it's content and made a gist: https://gist.github.com/mmcdaris/29cfe920c846ae6dd5c6eb354c9abdd2 Same result different method.

mogramer
  • 602
  • 5
  • 11
4

You can slave your local instance of Redis to the RedisToGo instance - http://redistogo.com/documentation/exporting

John Beynon
  • 37,398
  • 8
  • 88
  • 97
1

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

odlp
  • 4,984
  • 2
  • 34
  • 45