Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find latest or most recent AWS RDS snapshot?

Tags:

I can call aws rds describe-db-snapshots --db-instance-identifier {my_db_instance} and sort all automated snapshots to find the most recently created one but I was hoping someone has a better idea out there.

like image 690
Itamar Bitton Avatar asked Jul 19 '16 15:07

Itamar Bitton


People also ask

Where are AWS RDS snapshots stored?

Amazon RDS DB snapshots and automated backups are stored in S3. You can use the AWS Management Console, the ModifyDBInstance API, or the modify-db-instance command to manage the period of time your automated backups are retained by modifying the RetentionPeriod parameter.

What is latest RDS recovery?

This functionality exposes a Latest Restorable Time, which is the latest point in time you create the copy from. RDS usually keeps this value within 5 minutes of the current time, but if it falls behind, you will have to contact AWS support to have the problem looked into.

What is RDS snapshot identifier?

-s, --db-snapshot-identifier VALUE User-supplied snapshot identifier, this is the unique key that identifies a specific snapshot of a database instance. Must be 1 to 255 alphanumeric characters or underscores. -t, --snapshot-type VALUE If specified, filters the results by the specified snapshot type.

What is RDS snapshot in AWS?

By default, Amazon RDS creates and saves automated backups of your DB instance securely in Amazon S3 for a user-specified retention period. In addition, you can create snapshots, which are user-initiated backups of your instance that are kept until you explicitly delete them.


1 Answers

For me, this one works:

aws rds describe-db-snapshots \   --query="max_by(DBSnapshots, &SnapshotCreateTime)" 

The query parameter returns only the most recent one.

If only the Arn is needed, this one might help:

aws rds describe-db-snapshots \   --query="max_by(DBSnapshots, &SnapshotCreateTime).DBSnapshotArn" \   --output text 

And all that for a specific database instance:

aws rds describe-db-snapshots \   --db-instance-identifier={instance identifier} \   --query="max_by(DBSnapshots, &SnapshotCreateTime).DBSnapshotArn" \   --output text 
like image 190
hey Avatar answered Oct 20 '22 06:10

hey