![](/img/trans.png)
[英]How to list all the RDS snapshots through CLI and import some of those fields into a spreadsheet
[英]How to get a list of rds snapshots older than x days
我正在尝试获取早于 x 天的 rds 快照列表。 使用 describe-snsapshots cli。
https://docs.aws.amazon.com/cli/latest/reference/rds/describe-db-snapshots.html
expiry_date=$(date -d "-10 days" +'%Y-%m-%d')
aws rds --region us-east-2 describe-db-snapshots --filters Name=db-instance-id,Values=acme --query 'DBSnapshots[?SnapshotCreateTime<`2023-01-10`].DBSnapshotIdentifier'expiry_date
但是我无法用变量expiry_date
替换原始日期
aws rds --region us-east-2 describe-db-snapshots --filters Name=db-instance-id,Values=acme --query 'DBSnapshots[?SnapshotCreateTime<`$expiry_date`].DBSnapshotIdentifier'
变量不会在单引号 ( '
) 内展开。 请改用双引号 ( "
):
aws rds --region us-east-2 describe-db-snapshots --filters Name=db-instance-id,Values=acme --query "DBSnapshots[?SnapshotCreateTime<\`$expiry_date\`].DBSnapshotIdentifier"
请注意,反引号是反斜杠转义的,因为它们在双引号内展开(一种古老的命令替换形式 ( $(...)
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.