Skip to content

Instantly share code, notes, and snippets.

@lmmendes
Last active May 28, 2021 07:36
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lmmendes/15c65fb77aec523e836d032b48eee77b to your computer and use it in GitHub Desktop.
Save lmmendes/15c65fb77aec523e836d032b48eee77b to your computer and use it in GitHub Desktop.
Save Amazon ElastiCache Redis to file dump.rdb

Instructions to DUMP localy a Elasticache Redis database

Connect to Redis CLI

$ redis-cli

Enable the current redis as a slave for the master node

127.0.0.1:6379> SLAVEOF master-node-address.0001.euw1.cache.amazonaws.com 6379

Issue a sync command, starting sync operations

127.0.0.1:6379> SYNC

Start save the sabe to the dump.rdb file

127.0.0.1:6379> BGSAVE
127.0.0.1:6379> SLAVEOF NO ONE
127.0.0.1:6379> EXIT

Usefull commands

Fetch the number of keys inside the database

127.0.0.1:6379> DBSIZE

Find the location of the configuration file we need this to find out where is Redis data folder

$ redis-cli INFO | grep file
config_file:/usr/local/etc/redis.conf

Location where the .rdb data files are stored

$ cat /usr/local/etc/redis.conf | grep dir --color
dir /usr/local/var/db/redis/
@exNewbie
Copy link

exNewbie commented Jun 1, 2018

the logic is good. however, AWS doesn't seem to support SYNC and PSYNC command. https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/RestrictedCommands.html

have you got it working by any chance?

here is some debug.

127.0.0.1:6379> SYNC     
Entering slave output mode...  (press Ctrl-C to quit)                               
SYNC with master failed: -NOMASTERLINK Can't SYNC while not connected with my master
19194:S 01 Jun 11:45:22.395 * Connecting to MASTER 172.31.11.41:6379                                   
19194:S 01 Jun 11:45:22.396 * MASTER <-> SLAVE sync started                                            
19194:S 01 Jun 11:45:22.397 * Non blocking connect for SYNC fired the event.                           
19194:S 01 Jun 11:45:22.422 * Master replied to PING, replication can continue...                      
19194:S 01 Jun 11:45:22.460 * Partial resynchronization not possible (no cached master)                
19194:S 01 Jun 11:45:22.479 * Master does not support PSYNC or is in error state (reply: -ERR unknown command 'PSYNC')          
19194:S 01 Jun 11:45:22.479 * Retrying with SYNC...                                                    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment