Created
June 3, 2017 00:56
-
-
Save blainsmith/2171dc3a9f002ac32a48d828573ad8af to your computer and use it in GitHub Desktop.
Copy keys from one Redis instance to another
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set variables accordingly | |
source_host=ecfoo.amazonaws.com | |
source_password=foo | |
source_port=6666 | |
source_db=0 | |
target_host=ecbar.amazonaws.com | |
target_password=bar | |
target_port=6777 | |
target_db=0 | |
redis-cli -h $source_host -a $source_password -p $source_port -n $source_db keys \* | while read key; do | |
echo "Copying $key"; | |
redis-cli --raw -h $source_host -a $source_password -p $source_port -n $source_db DUMP "$key" | head -c -1|redis-cli -x -h $target_host -a $target_password -p $target_port -n $target_db RESTORE "$key" 0; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't use
KEYS
, useSCAN
instead (or the cli's--scan
switch).