我可以调用aws rds describe-db-snapshots --db-instance-identifier {my_db_instance}
并对所有自动快照进行排序,以找到最新创建的快照,但我希望有人对此有更好的主意。
最佳答案
对我来说,这有效:
aws rds describe-db-snapshots \
--query="reverse(sort_by(DBSnapshots, &SnapshotCreateTime))[0]"
query参数自动对它们进行排序,并且仅返回最新的参数。
如果只需要Arn,这可能会有所帮助:
aws rds describe-db-snapshots \
--query="reverse(sort_by(DBSnapshots, &SnapshotCreateTime))[0]|DBSnapshotArn" \
--output text
以及特定数据库实例的所有内容:
aws rds describe-db-snapshots \
--db-instance-identifier={instance identifier} \
--query="reverse(sort_by(DBSnapshots, &SnapshotCreateTime))[0]|DBSnapshotArn" \
--output text
关于amazon-web-services - 如何查找最新或最新的AWS RDS快照?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38463085/