Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement