DEV Community

Dmitry Romanoff
Dmitry Romanoff

Posted on

How to download AWS RDS Postgres log files?

The following bash script downloads AWS RDS Postgres log files, appending them to one single file. It uses aws-cli.

the_region="us-east-1"
the_db_instance="my-db-instance"

for filename in $( aws rds describe-db-log-files --region $the_region --db-instance-identifier $the_db_instance | jq -r '.DescribeDBLogFiles[] | .LogFileName' )
do
aws rds download-db-log-file-portion --region $the_region --db-instance-identifier $the_db_instance --output text --no-paginate --log-file $filename  >> /tmp/postgres_aws_rds_logs_$the_db_instance.log
done
Enter fullscreen mode Exit fullscreen mode

Top comments (0)