Last active
November 6, 2025 16:34
-
-
Save mucaho/e21f3f0d11230a282aa2d19a058b5c0b to your computer and use it in GitHub Desktop.
Dump diffs (Darwin)
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
| # Instructions for darwin coreutils | |
| # credits: https://stackoverflow.com/questions/3840908/how-do-i-see-the-differences-between-2-mysql-dumps | |
| cd /to/appropriate/working/dir | |
| docker exec -ti mysql5.7 /bin/bash | |
| > mysqldump --skip-opt DB_NAME > prior.sql | |
| > exit | |
| docker cp mysql5.7:/prior.sql prior.sql | |
| sed -i='' -e "s/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]/0000-00-00 00:00:00/g" prior.sql | |
| # DO THE NECESSARY CHANGES IN YOUR DB | |
| docker exec -ti mysql5.7 /bin/bash | |
| > mysqldump --skip-opt DB_NAME > post.sql | |
| > exit | |
| docker cp mysql5.7:/post.sql post.sql | |
| sed -i='' -e "s/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]/0000-00-00 00:00:00/g" post.sql | |
| diff --normal --suppress-common-lines prior.sql post.sql > dump.sql.diff | |
| sed -i='' -e "s/^[0-9].*$//g" dump.sql.diff | |
| sed -i='' -e "s/> INSERT INTO/INSERT INTO/" dump.sql.diff | |
| mv dump.sql.diff dump.sql | |
| # Open dump.sql in your favorite editor, e.g. VS Code |
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
| # Instructions for darwin coreutils | |
| # install rdb and coreutils via homebrew | |
| # credits: | |
| # https://stackoverflow.com/questions/11180999/redis-dump-rdb-saving-small-files | |
| # https://stackoverflow.com/questions/339483/how-can-i-remove-the-first-line-of-a-text-file-using-bash-sed-script | |
| # https://stackoverflow.com/questions/4881930/remove-the-last-line-from-a-file-in-bash | |
| # https://stackoverflow.com/questions/26774816/how-to-sort-file-lines-in-bash | |
| docker exec -ti redis /bin/bash | |
| > redis-cli save | |
| > mv dump.rdb prior.rdb | |
| > exit | |
| docker cp redis:/data/prior.rdb prior.rdb | |
| rdb -c json -o prior.json prior.rdb | |
| sed -i='' -e "s/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]\+[0-9][0-9]:[0-9][0-9]/0000-00-00T00:00:00.000+00:00/g" prior.json | |
| sed -i='' -e "s/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9]\+[0-9][0-9]:[0-9][0-9]/0000-00-00T00:00:00.000+00:00/g" prior.json | |
| sed -i='' -e "s/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]\+[0-9][0-9]:[0-9][0-9]/0000-00-00T00:00:00.000+00:00/g" prior.json | |
| tail -n +2 prior.json > prior.json.mod | |
| mv prior.json.mod prior.json | |
| ghead -n -1 prior.json > prior.json.mod | |
| mv prior.json.mod prior.json | |
| sort prior.json > prior.json.mod | |
| mv prior.json.mod prior.json | |
| # DO THE NECESSARY CHANGES IN REDIS | |
| docker exec -ti redis /bin/bash | |
| > redis-cli save | |
| > mv dump.rdb post.rdb | |
| > exit | |
| docker cp redis:/data/post.rdb post.rdb | |
| rdb -c json -o post.json post.rdb | |
| sed -i='' -e "s/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]\+[0-9][0-9]:[0-9][0-9]/0000-00-00T00:00:00.000+00:00/g" post.json | |
| sed -i='' -e "s/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9]\+[0-9][0-9]:[0-9][0-9]/0000-00-00T00:00:00.000+00:00/g" post.json | |
| sed -i='' -e "s/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]\+[0-9][0-9]:[0-9][0-9]/0000-00-00T00:00:00.000+00:00/g" post.json | |
| tail -n +2 post.json > post.json.mod | |
| mv post.json.mod post.json | |
| ghead -n -1 post.json > post.json.mod | |
| mv post.json.mod post.json | |
| sort post.json > post.json.mod | |
| mv post.json.mod post.json | |
| diff --normal --suppress-common-lines prior.json post.json > dump.json.diff | |
| mv dump.json.diff dump.json | |
| # Open dump.json in your favorite editor, e.g. VS Code | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment