Skip to content

Instantly share code, notes, and snippets.

@hsm207
Last active February 5, 2020 17:33
Show Gist options
  • Save hsm207/7d7d1bd21b77eb831a2f3ca98be57173 to your computer and use it in GitHub Desktop.
Save hsm207/7d7d1bd21b77eb831a2f3ca98be57173 to your computer and use it in GitHub Desktop.
Script to migrate all keys inside a redis instance into another redis instance
# source: https://stackoverflow.com/questions/37166947/copying-all-keys-in-redis-database-using-migrate
# make sure the redis in SOURCE_HOST and DESTINATION_HOST are identical!
SOURCE_HOST=127.0.0.1
SOURCE_PORT=6381
DESTINATION_HOST=foo.bar
DESTINATION_PORT=6379
redis-cli -h $SOURCE_HOST -p $SOURCE_PORT --raw KEYS '*' | \
xargs redis-cli -h $SOURCE_HOST -p $SOURCE_PORT MIGRATE $DESTINATION_HOST $DESTINATION_PORT "" 0 5000 KEYS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment