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`
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

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s