Access denied when hot backup to s3

I got a access denied error when I trying to backup to s3, while I can make bucket and list bucket with aws cli, here is my command:
db.runCommand({createBackup: 1, s3: {bucket: “mongodb-dumpdata”, path: “testdump”} , endpoint: “the endpoint”, region: “the region name”, accessKeyId: “the access key id”, secretAccessKey:“the secret key”})

And here is the error message:

*{"t":{"$date":"2021-10-26T10:48:00.575+08:00"},"s":"I",  "c":"STORAGE",  "id":29011,   "ctx":"conn1","msg":"{statement}","attr":{"s*
*tatement":"[INFO] 2021-10-26 02:48:00.575 CurlHandleContainer [140510085871360] Cleaning up CurlHandleContainer.\n"}}*
*{"t":{"$date":"2021-10-26T10:48:00.578+08:00"},"s":"I",  "c":"COMMAND",  "id":51803,   "ctx":"conn1","msg":"Slow query","attr":{"type":"command","ns":"admin.$cmd","appName":"MongoDB Shell","command":{"createBackup":1.0,"s3":{"bucket":"mongodb-dump","path":"testdump"},"endpoint":"xxxxxxxxxxxxx","region":"xxxxxxx","accessKeyId":"xxxxxx","secretAccessKey":"xxxxxxxx","lsid":{"id":{"$uuid":"xxxxxx"}},"$db":"admin"},"numYields":0,"ok":0,"errMsg":"Cannot create 'mongodb-dump' bucket for the backup : AccessDenied : Access Denied","errName":"UnknownError","errCode":8,"reslen":132,"locks":{},"protocol":"op_msg","durationMillis":8904}}*

My question is the bucket should be existed or not existed? I think the bucket should be existed and the path should not be existed, right?
The fact is that the error occurred no matter the bucket exists or does not exist.

What is the correct way? What should I do? Your help is highly appreciated.

1 Like