Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AlcibiadesCleinias/00b9aaf8ec15bbbc73b34b454acdfba7 to your computer and use it in GitHub Desktop.
Save AlcibiadesCleinias/00b9aaf8ec15bbbc73b34b454acdfba7 to your computer and use it in GitHub Desktop.
Redis: dump to json from python docker container
# Create simple dump script
cat << 'EOT' > dump-redis.py
import redisdl
#json_text = redisdl.dumps()
with open('dump.json', 'w') as f:
# streams data
redisdl.dump(f, host="redis")
EOT
# Add script to docker
docker cp dump-redis.py {{argument_1}}:{{argument_2}}dump-redis.py
# Hack to run command and ignore ^[i
# Install redisdl inside docker and run script and copy file to host
docker exec {{argument_1}} sh -c "python -m pip install redis-dump-load==1.1"
docker exec {{argument_1}} sh -c "python dump-redis.py"
docker cp {{argument_1}}:{{argument_2}}dump.json .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment