AWS RDS logs bulk download

I think most of the time people just go to the console and download a single log. Maybe two or three?

Well, I needed to download lot’s of them.

This is something I would never do it over the console …

So here is my script to bulk download logs from AWS RDS:

First list all logs available:

aws rds describe-db-log-files --db-instance-identifier production-db > slowlogs-production.log

Then use grep to download only the ones needed:

for a in `grep slowquery slowlogs-production.log | awk '{ print $3 }' | grep -v 2023-05-30 | cut -d '/' -f2`
do
	aws rds download-db-log-file-portion \
    --db-instance-identifier production-db \
    --starting-token 0 --output text \
    --log-file-name slowquery/$a > $a
done

Hope it helps.

AWS RDS MySQL Blue/Green Deployments

AWS introduced Blue/Green deployments for RDS on December/2022.

It is a fully automated way to:

  1. Easily create a production-ready staging environment.
  2. Automatically replicate database changes from the production environment to the staging environment.
  3. Test database changes in a safe staging environment without affecting the production environment.
  4. Stay current with database patches and system updates.
  5. Implement and test newer database features.
  6. Switch over your staging environment to be the new production environment without changes to your application.
  7. Safely switch over through the use of built-in switchover guardrails.
  8. Eliminate data loss during switchover.
  9. Switch over quickly, typically under a minute depending on your workload.

I’ve used it to perform a near-zero downtime upgrade from MySQL 5.7 to MySQL 8.

I was going to follow the instructions from here but this new feature is much better and it is now the recommended way to accomplish the upgrade.

Create a new blue/green deployment using AWS console, go to actions -> create blue/green deployment – new option.

A screen like this will appear:

Origin is MySQL 5.7 and the new “blue” deployment is already 8.0.32 🙂

Check out the docs for more detailed info like best practices and limitations.

Finally, just to remember folks out there MySQL 5.7 end of life is October/2023.