Last active
May 21, 2021 17:33
-
-
Save rluisr/a120063e2dcbdf10157901e75abae6c5 to your computer and use it in GitHub Desktop.
Download binary logs from Amazon RDS.
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 | |
set -eux | |
MYSQL_HOST='' | |
MYSQL_USER='' | |
MYSQL_PASS='' | |
EXEC_MYSQL="docker run -e MYSQL_PWD=${MYSQL_PASS} -it --rm mysql:5.6 mysql" | |
EXEC_MYSQLBINLOG="docker run -e MYSQL_PWD=${MYSQL_PASS} -v ${PWD}:/dump -it --rm mysql:5.6 mysqlbinlog" | |
binlog_files=$( eval "${EXEC_MYSQL} -h ${MYSQL_HOST} -u ${MYSQL_USER} -e 'show master logs' | grep 'mysql-bin' | awk '{print \$2}'" ) | |
for binlog_file in $binlog_files | |
do | |
eval "${EXEC_MYSQLBINLOG} -h ${MYSQL_HOST} -u ${MYSQL_USER} --read-from-remote-server ${binlog_file} --raw --result-file=/dump/" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment