Skip to content

Instantly share code, notes, and snippets.

@fern4lvarez
Last active February 7, 2017 18:26
Show Gist options
  • Save fern4lvarez/9a1743a072518306715e761fd8ecd9d4 to your computer and use it in GitHub Desktop.
Save fern4lvarez/9a1743a072518306715e761fd8ecd9d4 to your computer and use it in GitHub Desktop.
Download RDS slow query logs and zip it into a single file
#!/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