Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AlcibiadesCleinias/81e0214f7e125b8792a23bdab9d6383d to your computer and use it in GitHub Desktop.
Save AlcibiadesCleinias/81e0214f7e125b8792a23bdab9d6383d to your computer and use it in GitHub Desktop.
Redis: Load Dump into running Redis
# Create script
cat << 'EOT' > load-dump-redis.py
import redisdl
#json_text = '...'
#redisdl.loads(json_text)
with open('dump.json') as f:
# streams data if ijson or jsaone are installed
redisdl.load(f, host="redis")
EOT
# Add script to docker
docker cp load-dump-redis.py {{argument_1}}:{{argument_2}}load-dump-redis.py
# 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"
# Copy dump to docker
docker cp dump.json {{argument_1}}:{{argument_2}}dump.json
docker exec {{argument_1}} sh -c "python load-dump-redis.py"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment