Skip to content

Instantly share code, notes, and snippets.

@mkuehle
Created May 1, 2019 05:45
Show Gist options
  • Save mkuehle/50906ee1dcaf0b6cb6f0d94048f1d3b9 to your computer and use it in GitHub Desktop.
Save mkuehle/50906ee1dcaf0b6cb6f0d94048f1d3b9 to your computer and use it in GitHub Desktop.
Aktuellsten RDS Snapshot Identifier herausbekommen
AmazonRDS client = createAmazonRdsClient();
DescribeDBSnapshotsRequest describeDBSnapshotsRequest = new DescribeDBSnapshotsRequest();
describeDBSnapshotsRequest.withSnapshotType("automated");
describeDBSnapshotsRequest.setDBInstanceIdentifier(RDS_INSTANCE_IDENTIFIER);
List<DBSnapshot> snapshots = client.describeDBSnapshots(describeDBSnapshotsRequest).getDBSnapshots();
logger.info("{} RDS Snapshots gefunden für RDS Instance ID '{}'", snapshots.size(), RDS_INSTANCE_IDENTIFIER);
client.shutdown();
// Den letzten Eintrag verwenden, denn das ist der aktuellste Snaphshot. Liste ist aufsteigend sortiert (letzter Snapshot ganz unten).
String snapshotIdentifier = snapshots.get(snapshots.size() - 1).getDBSnapshotIdentifier();
if (snapshotIdentifier == null) {
throw new RuntimeException("Kann keinen Snapshot finden; DB Instanz Id: " + RDS_INSTANCE_IDENTIFIER);
}
logger.info("RDS Snapshot Identifier: {}", snapshotIdentifier);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment