英文:
Can't get information about DynamoDB backups using AWS Golang SDK
问题
我需要获取有关 DynamoDB 表备份的信息。
假设我在仪表板中列出了备份:
然而,我无法使用 Golang SDK 获取任何备份:
import (
...
"github.com/aws/aws-sdk-go/service/dynamodb"
...
)
...
svc := dynamodb.New(c.providerConfig.Session, regionConfig)
response, err := svc.ListBackupsWithContext(ctx, input)
// response.BackupSummaries is empty
backupArn := <从仪表板中选择任何一个备份的 ARN>
output, _ := svc.DescribeBackupWithContext(ctx, &dynamodb.DescribeBackupInput{BackupArn: &backupArn})
// 即使通过指定 ARN 请求备份,我们也没有运气
// output.BackupDescription is nil
其他函数(1. 使用 ListTablesPagesWithContext
获取表 2. 使用 DescribeContinuousBackups
获取连续备份描述)都可以正常工作。唯一无法获取的是(非连续)备份。
有人可以解释一下为什么我在仪表板中列出 DynamoDB 表备份,但仍然得到空响应吗?
英文:
I need to get information about DynamoDB tables backups.
So lets say I have backups listed in dashboard:
I can't get any backups using Golang SDK though:
import (
...
"github.com/aws/aws-sdk-go/service/dynamodb"
...
)
...
svc := dynamodb.New(c.providerConfig.Session, regionConfig)
response, err := svc.ListBackupsWithContext(ctx, input)
// response.BackupSummaries is empty
backupArn := <ARN of any of the backups from dashboard>
output, _ := svc.DescribeBackupWithContext(ctx, &dynamodb.DescribeBackupInput{BackupArn: &backupArn})
// even with requesting for a backup by specific ARN we have no luck
// output.BackupDescription is nil
Other functions (1. getting tables with ListTablesPagesWithContext
2. getting continuous backup description with DescribeContinuousBackups
) works perfectly. The only thing i can't get (non-continuous) backups.
Can someone help with explanation why I keep getting empty responses though DynamoDB table backups listed in dashboard?
答案1
得分: 3
ListBackups
的默认设置是 BackupType:USER
。这意味着当你调用 ListBackups 时,只会返回手动创建的备份。由于你的备份由 AWS Backup 维护,你应该将 BackupType
参数设置为 ALL
或 SYSTEM
。
希望能对你有所帮助。
注意,我尝试修复了你的代码,但 Go 不是我的强项(正确的概率为50% )。
backupArn := <仪表板上任何备份的ARN>
backupType := "ALL"
output, _ := svc.DescribeBackupWithContext(ctx, &dynamodb.DescribeBackupInput{BackupArn: &backupArn, BackupType: &backupType})
英文:
The default settings for ListBackups
is BackupType:USER
. This means when you call ListBackups you are only being returned ones that are manually created. As your backups are maintained by AWS Backup, you should set the BackupType
parameter to either ALL
or SYSTEM
.
Hope that helps.
Note I attempted to fix your code, but Go is not my strong point (50% chance of being correct )
backupArn := <ARN of any of the backups from dashboard>
backupType:= 'ALL'
output, _ := svc.DescribeBackupWithContext(ctx, &dynamodb.DescribeBackupInput{BackupArn: &backupArn, BackupType: &backupType})
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论