Last active
October 17, 2018 08:52
-
-
Save h2rd/fc236b218861770cd214d1203b8f64e5 to your computer and use it in GitHub Desktop.
Copy keys from one redis to another
This file contains 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
source_host=localhost | |
source_port=6379 | |
source_db=0 | |
target_host=localhost | |
target_port=6379 | |
target_db=1 | |
#copy all keys without preserving ttl! | |
redis-cli -h $source_host -p $source_port -n $source_db keys * | while read key; do echo "Copying $key"; redis-cli --raw -h $source_host -p $source_port -n $source_db DUMP "$key" | head -c -1|redis-cli -x -h $target_host -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