Created
November 30, 2024 22:04
-
-
Save AlcibiadesCleinias/00b9aaf8ec15bbbc73b34b454acdfba7 to your computer and use it in GitHub Desktop.
Redis: dump to json from python docker container
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
| # 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