[英]How can I get the name of the all snapshot of RDS DB instance created manually using the AWS CLI?
[英]Can I limit the results of an aws rds snapshot query to a certain timeframe?
我使用以下查詢來查找在特定日期之后創建的所有 rds 快照:
aws rds describe-db-snapshots --db-instance-identifier db-identifier --snapshot-type awsbackup --query 'DBSnapshots[?SnapshotCreateTime>=`Date`].{DBSnapshotIdentifier:DBSnapshotIdentifier,SnapshotCreateTime:SnapshotCreateTime}.sort_by(@,&SnapshotCreateTime)' --output json
我現在要做的是將結果限制在所需時間點的兩小時內,例如 >= Date1
,但 <= Date2
。
到目前為止,我的方法是嘗試向查詢添加第二個參數,如下所示:
aws rds describe-db-snapshots --db-instance-identifier db-identifier --snapshot-type awsbackup --query 'DBSnapshots[?SnapshotCreateTime>=`Date1`<=`Date2`].{DBSnapshotIdentifier:DBSnapshotIdentifier,SnapshotCreateTime:SnapshotCreateTime}.sort_by(@,&SnapshotCreateTime)' --output json
但這會導致返回一個空列表。
在不使用 jq 的情況下,我在這里嘗試做的事情是否可行?
最后答案很簡單,不同的查詢條件可以很容易地用一個 && 運算符組合起來。 所以在這種情況下,解決方案是:
aws rds describe-db-snapshots --db-instance-identifier db-identifier --snapshot-type awsbackup --query 'DBSnapshots[?SnapshotCreateTime>=`Date1`&&SnapshotCreateTime<=`Date2`].{DBSnapshotIdentifier:DBSnapshotIdentifier,SnapshotCreateTime:SnapshotCreateTime}.sort_by(@,&SnapshotCreateTime)' --output json
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.