Last active
October 11, 2017 17:06
-
-
Save victorpendleton/253e69a3edd2672e7308b17d4e5d4a5f to your computer and use it in GitHub Desktop.
Pull DML from MySQL binary logs (Optional time range)
This file contains 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
#!/bin/bash | |
## Pull INSERTs | |
/usr/local/mysql/bin/mysqlbinlog server-bin.1 --base64-output=DECODE-ROWS | |
--start-datetime="YYYY-MM-DD HH:MM:SS" | |
--stop-datetime="YYYY-MM-DD HH:MM:SS" | |
-vv | grep -iI "INSERT INTO \`database-name" | sort -n | uniq -c | sort -rn | |
## Pull UPDATEs | |
/usr/local/mysql/bin/mysqlbinlog server-bin.1 --base64-output=DECODE-ROWS | |
--start-datetime="YYYY-MM-DD HH:MM:SS" | |
--stop-datetime="YYYY-MM-DD HH:MM:SS" | |
-vv | grep -iI "UPDATE \`database-name" | sort -n | uniq -c | sort -rn | |
## Pull DELETEs | |
/usr/local/mysql/bin/mysqlbinlog server-bin.1 --base64-output=DECODE-ROWS | |
--start-datetime="YYYY-MM-DD HH:MM:SS" | |
--stop-datetime="YYYY-MM-DD HH:MM:SS" | |
-vv | grep -iI "DELETE FROM \`database-name" | sort -n | uniq -c | sort -rn | |
## Grabs INSERT,DELETE,UPDATE as well as time | |
/usr/local/mysql/bin/mysqlbinlog server-bin.1 --base64-output=DECODE-ROWS | |
--start-datetime="YYYY-MM-DD HH:MM:SS" | |
--stop-datetime="YYYY-MM-DD HH:MM:SS" | |
-vv | grep -B 1 -iI --no-group-separator "[INSERT INTO|DELETE|UPDATE] \`database-name\`" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment