如何解决文件还原后 AWS S3 副本存储桶中的不一致问题?

How do I work around inconsistency in AWS S3 replica bucket after file restore?

我已从源存储桶中删除了文件。源和副本同步,都有删除标记。我删除了源存储桶中的 删除标记 以恢复文件。但该文件在副本中被删除(具有 删除标记 )。这是设计使然:

If a DELETE request specifies a particular object version ID to delete, Amazon S3 deletes that object version in the source bucket, but it does not replicate the deletion in the destination bucket (in other words, it does not delete the same object version from the destination bucket). This behavior protects data from malicious deletions. https://docs.aws.amazon.com/AmazonS3/latest/dev/crr-what-is-isnot-replicated.html

我需要一个一致的副本来进行故障转移。如何防止副本不一致?

我看到保存一致性的唯一方法:

从不删除对象版本,包括删除标记

重新上传对象(创建新版本)以恢复它而不是删除删除标记

我理解这个问题并认为值得添加此信息,即使在您提出问题后很长一段时间。在源存储桶不可用且您想从副本恢复的灾难恢复场景中,"old" 文件仍然挂在副本中(应该被删除)是一个真正的问题。这与某人意外删除大文件的恢复场景不同(如果没有发生删除就好了)。

目前存储桶复制处于 V2。您可以 启用 V1 复制,它允许复制删除。似乎 AWS 想通过禁用删除复制来保护我们免受我们自己的伤害,但有时它是重要且正确的(尤其是当版本控制到位时)。

启用 V1 的相关 AWS 资源:

https://docs.aws.amazon.com/AmazonS3/latest/dev/crr-add-config.html#crr-backward-compat-considerations

https://docs.aws.amazon.com/cli/latest/reference/s3api/put-bucket-replication.html

希望对某人有所帮助。