我编写了一个简单的bash脚本来下载我的RDS postgres文件。但关键是,所有这些都可以正常工作,但是当我在脚本中尝试相同的内容时,我会得到一个错误:
An error occurred (DBLogFileNotFoundFault) when calling the DownloadDBLogFilePortion operation: DBLog File: "error/postgresql.log.2017-11-05-23", is not found on the DB instance有关命令如下:
aws rds download-db-log-file-portion --db-instance-identifier foobar --starting-token 0 --output text --log-file error/postgresql.log.2017-11-05-23 >> test.log这一切都很好,但是当我在bash脚本中放置完全相同的一行时,我会得到错误消息,即没有db日志文件--这是胡说八道,它们就在那里。
这是bash脚本:
download_generate_report() {
for filename in $( aws rds describe-db-log-files --db-instance-identifier $1 | awk {'print $2'} | grep $2 )
do
echo $filename
echo $1
aws rds download-db-log-file-portion --db-instance-identifier $1 --starting-token 0 --output text --log-file $filename >> /home/ubuntu/pgbadger_script/postgres_logs/postgres_$1.log.$2
done
}Tnx,Tom
发布于 2018-12-19 18:23:23
我重写了你的剧本,它似乎对我有用。它在grep附近吠叫。这使用了jq。
for filename in $( aws rds describe-db-log-files --db-instance-identifier $1 | jq -r '.DescribeDBLogFiles[] | .LogFileName' )
do
aws rds download-db-log-file-portion --db-instance-identifier $1 --output text --no-paginate --log-file $filename >> /tmp/postgres_$1.log.$2
done发布于 2021-12-23 13:01:45
谢谢伊恩,我有一个问题,aws cli 2.4,因为日志文件下载截断。
为了解决这个问题,我更改了--使用不分页的--启动令牌0在RDS参考中的更多信息。
最后,在bash:
#/bin/bash
set -x
for filename in $( aws rds describe-db-log-files --db-instance-identifier $1 | jq -r '.DescribeDBLogFiles[] | .LogFileName' )
do
aws rds download-db-log-file-portion --db-instance-identifier $1 --output text --starting-token 0 --log-file $filename >> $filename
done https://stackoverflow.com/questions/47140873
复制相似问题