Created
November 30, 2024 22:05
-
-
Save AlcibiadesCleinias/81e0214f7e125b8792a23bdab9d6383d to your computer and use it in GitHub Desktop.
Redis: Load Dump into running 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
| # 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