Created
April 28, 2016 18:22
-
-
Save davedash/ac5c0ab06f34004373e713dccd2c3f19 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# Script to download all RDS logs for a DB instance | |
# requires AWS cli and jq. | |
DB=${1} | |
if [ -z ${DB} ]; then | |
echo "Please pass an argument for the database. E.g.:" | |
echo " ${0} my_rds_db" | |
fi | |
if [ -z ${SKIP_LOGFILES} ]; then | |
echo "Downloading list of logfiles" | |
aws rds describe-db-log-files --db-instance-identifier ${DB} | \ | |
jq ".DescribeDBLogFiles[].LogFileName" -r > logfiles | |
fi | |
test -d logs || mkdir logs | |
while IFS='' read -r file; do | |
portion="logs/$(basename ${file})" | |
if [ ! -f "${portion}" ]; then | |
echo "Downloading ${file}" | |
aws rds download-db-log-file-portion --db-instance-identifier ${DB} \ | |
--log-file-name ${file} | jq -r ".LogFileData" > ${portion} | |
fi | |
done < logfiles |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment