script to download database log files from aws rds to local linux box
To download all the PostgreSQL error logs from RDS instance to Linux machine use the below script.
for i in `aws rds describe-db-log-files –db-instance-identifier $instancename –query ‘DescribeDBLogFiles[*].[LogFileName]’ –output text`
do
file_name=`echo $i | cut -d’/’ -f2`
aws rds download-db-log-file-portion –db-instance-identifier –log-file-name $i –starting-token 0 –output text > $file_name
done