Skip to content

Instantly share code, notes, and snippets.

@albertofem
Created February 6, 2015 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save albertofem/ead7eb36ce8bbf2f6150 to your computer and use it in GitHub Desktop.
Save albertofem/ead7eb36ce8bbf2f6150 to your computer and use it in GitHub Desktop.
redis-copy-network
#!/bin/bash
source_host=localhost
source_port=6379
source_db=0
target_host=localhost
target_port=23123
target_db=0
# copy all keys (no TTL)
redis-cli 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