Last active
February 7, 2017 18:26
-
-
Save fern4lvarez/9a1743a072518306715e761fd8ecd9d4 to your computer and use it in GitHub Desktop.
Download RDS slow query logs and zip it into a single file
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 -ex | |
instanceID=$1 | |
date=$(date +%Y%m%d) | |
function downloadLog () { | |
local log=$1 | |
aws rds download-db-log-file-portion \ | |
--output text \ | |
--db-instance-identifier $instanceID \ | |
--log-file-name $log | |
} | |
downloadLog slowquery/mysql-slowquery.log > slow-$instanceID-$date.log | |
for i in $(seq 0 23); do | |
downloadLog slowquery/mysql-slowquery.log.$i >> slow-$instanceID-$date.log | |
done | |
zip -r slow-$instanceID-$date.log.zip slow-$instanceID-$date.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment