-
-
Save sloppycoder/0a3e63897d8b106d50c0169c9c34b67f to your computer and use it in GitHub Desktop.
export and import data from redis
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
| redis-cli --scan --pattern "openai*" | while read key; do redis-cli PERSIST $key; done | |
| redis-cli KEYS 'openai*' | while read key; do | |
| echo "Key: $key" >> redis_data.txt | |
| redis-cli DUMP "$key" | xxd -p >> redis_data.txt | |
| echo "" >> redis_data.txt | |
| done | |
| while read line; do | |
| if [[ $line == Key:* ]]; then | |
| key=${line#Key: } | |
| read line | |
| value=$(echo $line | xxd -r -p) | |
| redis-cli -h [destination_host] -p [destination_port] RESTORE "$key" 0 "$value" | |
| fi | |
| done < redis_data.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment