How to backup AWS RDS databases for longer retention?

Being part of the fintech space means compliance and that entails having a good number of years of data backup. We previously hosted our postgres instance manually on an ec2 machine with master-slave setup with daily backups using scripts. But that was when RDS didn’t support postgres.

There are a lot of benefits of moving to RDS but our only concern was how to retain data backups longer than the maximum 30 days that amazon currently allows you. It turned out there is a pretty easy way to do that.

Create an IAM user (DatabaseBackups)

Give it following permissions

Setup a cronjob that runs the following script:

What the script essentially does is finds the latest automated snapshot of your database instance and creates a manual copy of it for the given day. In order for this script to actually work you need to:
1. Setup automated backups on your database instance (why would you not have already done this!!)
2. Setup the cron job time so that it runs after your automated snapshot occurs.

And that’s all thats required.

One thought on “How to backup AWS RDS databases for longer retention?

Comments are closed.

Top