Skip to content

Instantly share code, notes, and snippets.

@sloppycoder
Created November 16, 2023 07:17
Show Gist options
  • Select an option

  • Save sloppycoder/0a3e63897d8b106d50c0169c9c34b67f to your computer and use it in GitHub Desktop.

Select an option

Save sloppycoder/0a3e63897d8b106d50c0169c9c34b67f to your computer and use it in GitHub Desktop.
export and import data from redis
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